Skip to content

Commit fb92a18

Browse files
Updated build and release GH actions (#198)
* updated build and release GH actions * fix(pre_commit): 🎨 auto format pre-commit hooks --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 341b44e commit fb92a18

File tree

3 files changed

+77
-36
lines changed

3 files changed

+77
-36
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Build Package
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
workflow_call:
8+
inputs:
9+
python-version:
10+
required: false
11+
type: string
12+
default: "3.10"
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: 📥 Checkout the repository
19+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
20+
21+
- name: 🐍 Install uv and set Python version ${{ inputs.python-version }}
22+
uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0
23+
with:
24+
python-version: ${{ inputs.python-version }}
25+
activate-environment: true
26+
27+
- name: 🏗️ Build source and wheel distributions
28+
run: |
29+
uv pip install -r pyproject.toml --group build
30+
uv build
31+
uv run twine check --strict dist/*
32+
33+
- name: 📤 Upload distribution artifacts
34+
uses: actions/upload-artifact@v6
35+
with:
36+
name: dist
37+
path: dist/

.github/workflows/publish-pre-release.yml

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,27 @@ name: Publish Trackers Pre-Releases to PyPI
33
on:
44
push:
55
tags:
6-
- "[0-9]+.[0-9]+.[0-9]+.a[0-9]"
7-
- "[0-9]+.[0-9]+.[0-9]+.b[0-9]"
8-
- "[0-9]+.[0-9]+.[0-9]+.rc[0-9]"
6+
- "[0-9]+.[0-9]+[0-9]+.[0-9]+a[0-9]"
7+
- "[0-9]+.[0-9]+[0-9]+.[0-9]+b[0-9]"
8+
- "[0-9]+.[0-9]+[0-9]+.[0-9]+rc[0-9]"
99
workflow_dispatch:
10+
pull_request:
11+
branches: [main, develop]
12+
paths:
13+
- '.github/workflows/build-package.yml'
14+
- '.github/workflows/publish-pre-release.yml'
1015

1116
permissions: {} # Explicitly remove all permissions by default
1217

1318
jobs:
19+
build:
20+
permissions:
21+
contents: read
22+
uses: ./.github/workflows/build-package.yml
23+
1424
publish-pre-release:
1525
name: Publish Pre-release Package
26+
needs: build
1627
runs-on: ubuntu-latest
1728
environment:
1829
name: test
@@ -21,26 +32,17 @@ jobs:
2132
permissions:
2233
id-token: write # Required for PyPI publishing
2334
contents: read # Required for checkout
24-
strategy:
25-
matrix:
26-
python-version: ["3.10"]
2735
steps:
28-
- name: 📥 Checkout the repository
29-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
30-
31-
- name: 🐍 Install uv and set Python version ${{ matrix.python-version }}
32-
uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0
36+
- name: 📥 Download distribution artifacts
37+
uses: actions/download-artifact@v7
3338
with:
34-
python-version: ${{ matrix.python-version }}
35-
activate-environment: true
36-
37-
- name: 🏗️ Build source and wheel distributions
38-
run: |
39-
uv pip install -r pyproject.toml --group build
40-
uv build
41-
uv run twine check --strict dist/*
39+
name: dist
40+
path: dist/
41+
- name: List distribution artifacts
42+
run: ls -lh dist/
4243

4344
- name: 🚀 Publish to PyPi
45+
if: github.event_name != 'pull_request'
4446
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
4547
with:
4648
attestations: true

.github/workflows/publish-release.yml

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,25 @@ name: Publish Trackers Releases to PyPI
33
on:
44
push:
55
tags:
6-
- "[0-9]+.[0-9]+.[0-9]"
6+
- "[0-9]+.[0-9]+[0-9]+.[0-9]"
77
workflow_dispatch:
8+
pull_request:
9+
branches: [main, develop]
10+
paths:
11+
- '.github/workflows/build-package.yml'
12+
- '.github/workflows/publish-release.yml'
813

914
permissions: {} # Explicitly remove all permissions by default
1015

1116
jobs:
17+
build:
18+
permissions:
19+
contents: read
20+
uses: ./.github/workflows/build-package.yml
21+
1222
publish-release:
1323
name: Publish Release Package
24+
needs: build
1425
runs-on: ubuntu-latest
1526
environment:
1627
name: release
@@ -19,26 +30,17 @@ jobs:
1930
permissions:
2031
id-token: write # Required for PyPI publishing
2132
contents: read # Required for checkout
22-
strategy:
23-
matrix:
24-
python-version: ["3.10"]
2533
steps:
26-
- name: 📥 Checkout the repository
27-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
28-
29-
- name: 🐍 Install uv and set Python version ${{ matrix.python-version }}
30-
uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0
34+
- name: 📥 Download distribution artifacts
35+
uses: actions/download-artifact@v7
3136
with:
32-
python-version: ${{ matrix.python-version }}
33-
activate-environment: true
34-
35-
- name: 🏗️ Build source and wheel distributions
36-
run: |
37-
uv pip install -r pyproject.toml --group build
38-
uv build
39-
uv run twine check --strict dist/*
37+
name: dist
38+
path: dist/
39+
- name: List distribution artifacts
40+
run: ls -lh dist/
4041

4142
- name: 🚀 Publish to PyPi
43+
if: github.event_name != 'pull_request'
4244
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
4345
with:
4446
attestations: true

0 commit comments

Comments
 (0)