Skip to content

Commit 4f2bb91

Browse files
authored
Merge pull request #193 from aboutcode-org/pin-actions
chore: pin workflow dependencies and publish using trusted publisher
2 parents f94ff10 + d889e83 commit 4f2bb91

3 files changed

Lines changed: 101 additions & 22 deletions

File tree

.github/workflows/docs-ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@ on: [push, pull_request]
44

55
jobs:
66
build:
7-
runs-on: ubuntu-22.04
7+
runs-on: ubuntu-24.04
88

99
strategy:
1010
max-parallel: 4
1111
matrix:
12-
python-version: ["3.10",]
12+
python-version: ["3.11",]
1313

1414
steps:
1515
- name: Checkout code
16-
uses: actions/checkout@v5
16+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
1717
with:
1818
fetch-depth: 0
1919

2020
- name: Set up Python ${{ matrix.python-version }}
21-
uses: actions/setup-python@v4
21+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
2222
with:
2323
python-version: ${{ matrix.python-version }}
2424

.github/workflows/main.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: run tests
2+
3+
on: [push, pull_request]
4+
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-24.04
9+
permissions:
10+
contents: read
11+
12+
strategy:
13+
max-parallel: 4
14+
matrix:
15+
python-version: ["3.10", "3.11", "3.12"]
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
20+
21+
- name: Set up Python ${{ matrix.python-version }}
22+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
26+
- name: Install dependencies
27+
run: make dev
28+
29+
- name: Run tests
30+
run: |
31+
source venv/bin/activate
32+
make test

.github/workflows/pypi-release.yml

Lines changed: 65 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,69 @@ on:
77
- "v*.*.*"
88

99
jobs:
10-
build-and-publish-to-pypi:
11-
name: Build and publish library to PyPI
12-
runs-on: ubuntu-22.04
10+
build-pypi-distribs:
11+
name: Build for publishing
12+
runs-on: ubuntu-24.04
13+
permissions:
14+
contents: read
15+
16+
steps:
17+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
18+
- name: Set up Python
19+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
20+
with:
21+
python-version: 3.10
22+
23+
- name: Install pypa/build
24+
run: python -m pip install build --user
25+
26+
- name: Build a binary wheel and a source tarball
27+
run: python -m build --sdist --wheel --outdir dist/
28+
29+
- name: Upload built archives
30+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
31+
with:
32+
name: pypi_archives
33+
path: dist/*
34+
35+
create-gh-release:
36+
name: Create GH release
37+
needs:
38+
- build-pypi-distribs
39+
runs-on: ubuntu-24.04
40+
41+
steps:
42+
- name: Download built archives
43+
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0
44+
with:
45+
name: pypi_archives
46+
path: dist
47+
48+
- name: Create GH release
49+
uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2.5.0
50+
with:
51+
draft: false
52+
generate_release_notes: true
53+
files: dist/*
54+
55+
create-pypi-release:
56+
name: Create PyPI release
57+
needs:
58+
- create-gh-release
59+
runs-on: ubuntu-24.04
60+
environment: pypi-publish
61+
permissions:
62+
id-token: write
63+
1364
steps:
14-
- uses: actions/checkout@v4
15-
- name: Set up Python
16-
uses: actions/setup-python@v5
17-
with:
18-
python-version: 3.9
19-
- name: Install pypa/build
20-
run: python -m pip install build --user
21-
- name: Build a binary wheel and a source tarball
22-
run: python -m build --sdist --wheel --outdir dist/
23-
- name: Publish distribution to PyPI
24-
if: startsWith(github.ref, 'refs/tags')
25-
uses: pypa/gh-action-pypi-publish@release/v1
26-
with:
27-
password: ${{ secrets.PYPI_API_TOKEN }}
28-
65+
- name: Download built archives
66+
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0
67+
with:
68+
name: pypi_archives
69+
path: dist
70+
71+
- name: Publish to PyPI
72+
if: startsWith(github.ref, 'refs/tags/')
73+
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
74+
with:
75+
verbose: true

0 commit comments

Comments
 (0)