55 pull_request :
66 workflow_dispatch :
77
8+ env :
9+ PYTHON_VERSION : " 3.14"
10+
811jobs :
912 main :
1013 name : Test and release
1114 runs-on : ubuntu-latest
15+ outputs :
16+ released : ${{ steps.release.outputs.released }}
17+ tag : ${{ steps.release.outputs.tag }}
1218
1319 steps :
1420 - uses : actions/checkout@v6
@@ -18,24 +24,37 @@ jobs:
1824 - name : Set up Python 3.14
1925 uses : actions/setup-python@v6
2026 with :
21- python-version : " 3.14 "
27+ python-version : ${{ env.PYTHON_VERSION }}
2228
2329 - name : Install uv
2430 uses : astral-sh/setup-uv@v7
2531 with :
2632 enable-cache : true
2733
2834 - name : Install dependencies
29- run : uv sync
35+ run : uv sync --all-groups
3036
3137 - name : Run tests
3238 run : uv run pytest -v
3339
34- - name : Check formatting
35- run : uv run ruff format --check bolt_control_flow examples tests
40+ - name : Check linting, formatting, imports
41+ run : uv run ruff check
42+
43+ - name : Action | Semantic Version Release
44+ id : release
45+ run : |
46+ # 1. Run the versioning logic
47+ uv run semantic-release version
3648
37- - name : Check imports
38- run : uv run ruff check --select I bolt_control_flow examples tests
49+ # 2. Extract version info for subsequent steps
50+ echo "tag=$(uv run semantic-release version --print-tag)" >> $GITHUB_OUTPUT
51+
52+ # 3. Check if a release actually happened
53+ if [ -d "dist" ] && [ "$(ls -A dist)" ]; then
54+ echo "released=true" >> $GITHUB_OUTPUT
55+ fi
56+ env :
57+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
3958
4059 - name : Build docs
4160 run : |
@@ -45,22 +64,44 @@ jobs:
4564 poetry run make html
4665 cp -r build/* ../gh-pages/
4766
48- - name : Release
49- if : |
50- github.repository == 'vdvman1/bolt-control-flow'
51- && github.event_name == 'push'
52- && github.ref == 'refs/heads/main'
53- env :
54- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
55- PYPI_TOKEN : ${{ secrets.PYPI_TOKEN }}
56- run : |
57- git config --global user.name "github-actions"
58- git config --global user.email "action@github.com"
59- uv run semantic-release publish -v DEBUG -D commit_author="github-actions <action@github.com>"
67+ - name : Publish | Upload to GitHub Release Assets
68+ uses : python-semantic-release/publish-action@v10.5.3
69+ if : steps.release.outputs.released == 'true'
70+ with :
71+ github_token : ${{ secrets.GITHUB_TOKEN }}
72+ tag : ${{ steps.release.outputs.tag }}
73+
74+ - name : Upload | Distribution Artifacts
75+ uses : actions/upload-artifact@v4
76+ with :
77+ name : distribution-artifacts
78+ path : dist
79+ if-no-files-found : error
80+
81+ deploy :
82+ # 1. Separate out the deploy step from the publish step to run each step at
83+ # the least amount of token privilege
84+ # 2. Also, deployments can fail, and its better to have a separate job if you need to retry
85+ # and it won't require reversing the release.
86+ runs-on : ubuntu-latest
87+ needs : release
88+ if : ${{ needs.release.outputs.released == 'true' }}
89+
90+ permissions :
91+ contents : read
92+ id-token : write
93+
94+ steps :
95+ - name : Setup | Download Build Artifacts
96+ uses : actions/download-artifact@v4
97+ id : artifact-download
98+ with :
99+ name : distribution-artifacts
100+ path : dist
60101
61- - name : Publish docs
62- if : github.event_name == 'push' && github.ref == 'refs/heads/main'
63- uses : JamesIves/github-pages-deploy-action@4.1.4
102+ - name : Publish package distributions to PyPI
103+ uses : pypa/gh-action-pypi-publish@release/v1
64104 with :
65- branch : gh-pages
66- folder : gh-pages
105+ packages-dir : dist
106+ print-hash : true
107+ verbose : true
0 commit comments