|
1 | 1 | name: Release |
2 | 2 |
|
3 | 3 | on: |
4 | | - # Support manually pushing a new release |
5 | | - workflow_dispatch: {} |
6 | | - # Trigger when a release or pre-release is published |
7 | | - release: |
8 | | - types: [published] |
| 4 | + pull_request: |
| 5 | + types: [closed] |
| 6 | + branches: [main] |
9 | 7 |
|
10 | 8 | defaults: |
11 | 9 | run: |
12 | 10 | shell: bash |
13 | 11 |
|
14 | 12 | jobs: |
15 | | - build: |
16 | | - name: Build distribution |
| 13 | + create-release: |
| 14 | + name: Create GitHub Release |
| 15 | + if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'version-bump') |
17 | 16 | runs-on: ubuntu-latest |
| 17 | + permissions: |
| 18 | + contents: write |
18 | 19 | steps: |
19 | | - - name: Checkout |
20 | | - uses: actions/checkout@v5 |
21 | | - - name: Install uv |
22 | | - uses: astral-sh/setup-uv@v6 |
23 | | - - name: Build |
24 | | - run: uv build |
25 | | - - name: Upload artifacts |
26 | | - uses: actions/upload-artifact@v4 |
| 20 | + - name: Generate token |
| 21 | + id: generate-token |
| 22 | + uses: actions/create-github-app-token@v1 |
27 | 23 | with: |
28 | | - name: dist |
29 | | - path: dist/ |
| 24 | + app-id: ${{ vars.WORKOS_BOT_APP_ID }} |
| 25 | + private-key: ${{ secrets.WORKOS_BOT_PRIVATE_KEY }} |
30 | 26 |
|
31 | | - smoke-test: |
32 | | - name: Smoke test (Python ${{ matrix.python }}) |
33 | | - needs: build |
34 | | - runs-on: ubuntu-latest |
35 | | - strategy: |
36 | | - fail-fast: false |
37 | | - matrix: |
38 | | - python: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] |
39 | | - steps: |
40 | 27 | - name: Checkout |
41 | | - uses: actions/checkout@v5 |
42 | | - - name: Install uv |
43 | | - uses: astral-sh/setup-uv@v6 |
| 28 | + uses: actions/checkout@v4 |
44 | 29 | with: |
45 | | - python-version: ${{ matrix.python }} |
46 | | - cache-python: true |
47 | | - - name: Download artifacts |
48 | | - uses: actions/download-artifact@v4 |
| 30 | + token: ${{ steps.generate-token.outputs.token }} |
| 31 | + |
| 32 | + - name: Get version from pyproject.toml |
| 33 | + id: get-version |
| 34 | + run: | |
| 35 | + VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/') |
| 36 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 37 | +
|
| 38 | + - name: Create Release |
| 39 | + uses: softprops/action-gh-release@v2 |
49 | 40 | with: |
50 | | - name: dist |
51 | | - path: dist/ |
52 | | - - name: Smoke test (wheel) |
53 | | - run: uv run --python ${{ matrix.python }} --isolated --no-project --with dist/*.whl tests/smoke_test.py |
54 | | - - name: Smoke test (source distribution) |
55 | | - run: uv run --python ${{ matrix.python }} --isolated --no-project --with dist/*.tar.gz tests/smoke_test.py |
| 41 | + tag_name: v${{ steps.get-version.outputs.version }} |
| 42 | + name: v${{ steps.get-version.outputs.version }} |
| 43 | + generate_release_notes: true |
| 44 | + token: ${{ steps.generate-token.outputs.token }} |
56 | 45 |
|
57 | 46 | publish: |
58 | 47 | name: Publish to PyPI |
59 | | - needs: smoke-test |
| 48 | + needs: create-release |
60 | 49 | runs-on: ubuntu-latest |
61 | | - environment: |
62 | | - name: pypi |
63 | 50 | permissions: |
64 | 51 | id-token: write |
65 | 52 | contents: read |
66 | 53 | steps: |
67 | | - - name: Download artifacts |
68 | | - uses: actions/download-artifact@v4 |
69 | | - with: |
70 | | - name: dist |
71 | | - path: dist/ |
| 54 | + - name: Checkout |
| 55 | + uses: actions/checkout@v4 |
72 | 56 | - name: Install uv |
73 | 57 | uses: astral-sh/setup-uv@v6 |
| 58 | + - name: Build |
| 59 | + run: uv build |
74 | 60 | - name: Publish |
75 | 61 | run: uv publish |
0 commit comments