|
6 | 6 | pull_request: |
7 | 7 | branches: [main] |
8 | 8 |
|
| 9 | +env: |
| 10 | + PYTHON_VERSION: "3.14" |
| 11 | + |
9 | 12 | jobs: |
10 | | - main: |
| 13 | + release: |
11 | 14 | name: Test and release |
12 | 15 | runs-on: ubuntu-latest |
13 | 16 |
|
14 | 17 | steps: |
15 | 18 | - uses: actions/checkout@v6 |
16 | | - with: |
17 | | - fetch-depth: 0 |
18 | 19 |
|
19 | | - - name: Set up Python 3.10 |
| 20 | + - name: Set up Python 3.14 |
20 | 21 | uses: actions/setup-python@v6 |
21 | 22 | with: |
22 | | - python-version: "3.12" |
| 23 | + python-version: ${{ env.PYTHON_VERSION }} |
23 | 24 |
|
24 | 25 | - name: Install uv |
25 | 26 | uses: astral-sh/setup-uv@v7 |
26 | 27 | with: |
27 | 28 | enable-cache: true |
28 | 29 |
|
29 | 30 | - name: Install dependencies |
30 | | - run: uv sync |
| 31 | + run: uv sync --all-groups |
31 | 32 |
|
32 | 33 | - name: Run tests |
33 | 34 | run: uv run pytest -v |
34 | 35 |
|
35 | 36 | - name: Check formatting |
36 | | - run: uv run ruff format --check src/bolt_expressions examples tests |
| 37 | + run: uv run ruff check |
37 | 38 |
|
38 | | - - name: Check imports |
39 | | - run: uv run ruff check --select I src/bolt_expressions examples tests |
| 39 | + - name: Action | Semantic Version Release |
| 40 | + id: release |
| 41 | + if: github.ref == 'refs/heads/main' |
| 42 | + run: | |
| 43 | + # 1. Run the versioning logic |
| 44 | + uv run semantic-release version |
40 | 45 |
|
41 | | - - name: Release |
42 | | - if: | |
43 | | - github.repository == 'rx-modules/bolt-expressions' |
44 | | - && github.event_name == 'push' |
45 | | - && github.ref == 'refs/heads/main' |
| 46 | + # 2. Extract version info for subsequent steps |
| 47 | + echo "tag=$(uv run semantic-release version --print-tag)" >> $GITHUB_OUTPUT |
| 48 | +
|
| 49 | + # 3. Check if a release actually happened |
| 50 | + if [ -d "dist" ] && [ "$(ls -A dist)" ]; then |
| 51 | + echo "released=true" >> $GITHUB_OUTPUT |
| 52 | + fi |
46 | 53 | env: |
47 | 54 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
48 | | - PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} |
49 | | - run: | |
50 | | - git config --global user.name "github-actions" |
51 | | - git config --global user.email "action@github.com" |
52 | | - uv run semantic-release publish -v DEBUG -D commit_author="github-actions <action@github.com>" |
| 55 | + |
| 56 | + - name: Publish | Upload to GitHub Release Assets |
| 57 | + uses: python-semantic-release/publish-action@v10.5.3 |
| 58 | + if: steps.release.outputs.released == 'true' |
| 59 | + with: |
| 60 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 61 | + tag: ${{ steps.release.outputs.tag }} |
| 62 | + |
| 63 | + - name: Upload | Distribution Artifacts |
| 64 | + uses: actions/upload-artifact@v4 |
| 65 | + if: steps.release.outputs.released == 'true' |
| 66 | + with: |
| 67 | + name: distribution-artifacts |
| 68 | + path: dist |
| 69 | + if-no-files-found: error |
| 70 | + |
| 71 | + deploy: |
| 72 | + # 1. Separate out the deploy step from the publish step to run each step at |
| 73 | + # the least amount of token privilege |
| 74 | + # 2. Also, deployments can fail, and its better to have a separate job if you need to retry |
| 75 | + # and it won't require reversing the release. |
| 76 | + runs-on: ubuntu-latest |
| 77 | + needs: release |
| 78 | + if: ${{ needs.release.outputs.released == 'true' }} |
| 79 | + |
| 80 | + permissions: |
| 81 | + contents: read |
| 82 | + id-token: write |
| 83 | + |
| 84 | + steps: |
| 85 | + - name: Setup | Download Build Artifacts |
| 86 | + uses: actions/download-artifact@v4 |
| 87 | + id: artifact-download |
| 88 | + with: |
| 89 | + name: distribution-artifacts |
| 90 | + path: dist |
| 91 | + |
| 92 | + - name: Publish package distributions to PyPI |
| 93 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 94 | + with: |
| 95 | + packages-dir: dist |
| 96 | + print-hash: true |
| 97 | + verbose: true |
0 commit comments