|
1 | | -name: Upload Python Package |
| 1 | +name: Python Package Release |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | 5 | branches: |
6 | 6 | - master |
| 7 | + - main |
7 | 8 |
|
8 | 9 | permissions: |
9 | 10 | contents: write |
10 | | - id-token: write |
11 | | - actions: write |
12 | 11 | packages: write |
| 12 | + id-token: write |
| 13 | + pull-requests: write |
13 | 14 |
|
14 | 15 | jobs: |
15 | | - release: |
| 16 | + prepare-release: |
| 17 | + if: github.ref == 'refs/heads/master' |
16 | 18 | runs-on: ubuntu-latest |
| 19 | + |
17 | 20 | steps: |
18 | | - - name: Checkout master branch |
| 21 | + - name: Checkout master |
19 | 22 | uses: actions/checkout@v4 |
20 | | - with: |
21 | | - ref: master |
22 | | - fetch-depth: 0 |
23 | 23 |
|
24 | | - - name: Create and push to main |
| 24 | + - name: Create release branch |
25 | 25 | run: | |
26 | | - git checkout -b main |
27 | | - git push origin main |
| 26 | + git checkout -b release-main |
| 27 | + git push origin release-main |
| 28 | +
|
| 29 | + - name: Raise PR to main |
| 30 | + uses: peter-evans/create-pull-request@v5 |
| 31 | + with: |
| 32 | + base: main |
| 33 | + head: release-main |
| 34 | + title: "Release PR: release-main → main" |
| 35 | + body: "Auto-generated release PR for version bump" |
| 36 | + branch: pr-release-main |
28 | 37 |
|
29 | | - - name: Checkout release branch |
30 | | - run: git checkout main |
| 38 | + publish-release: |
| 39 | + if: github.ref == 'refs/heads/main' |
| 40 | + runs-on: ubuntu-latest |
| 41 | + |
| 42 | + steps: |
| 43 | + - name: Checkout main |
| 44 | + uses: actions/checkout@v4 |
31 | 45 |
|
32 | 46 | - name: Set up Python |
33 | | - uses: actions/setup-python@v3 |
| 47 | + uses: actions/setup-python@v4 |
34 | 48 | with: |
35 | 49 | python-version: "3.x" |
36 | 50 |
|
37 | 51 | - name: Install dependencies |
38 | 52 | run: | |
39 | | - python -m pip install --upgrade pip |
| 53 | + pip install --upgrade pip |
40 | 54 | pip install build twine python-semantic-release setuptools-scm |
41 | 55 |
|
42 | | - - name: Run semantic-release |
43 | | - env: |
44 | | - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 56 | + - name: Configure Git |
45 | 57 | run: | |
46 | 58 | git config user.name github-actions |
47 | 59 | git config user.email github-actions@github.com |
48 | | - semantic-release version |
49 | | - semantic-release publish |
| 60 | +
|
| 61 | + - name: Run semantic-release publish |
| 62 | + env: |
| 63 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 64 | + run: semantic-release publish |
50 | 65 |
|
51 | 66 | - name: Build package |
52 | 67 | run: python -m build |
53 | 68 |
|
54 | | - - name: Publish package to PyPI |
| 69 | + - name: Upload to PyPI |
55 | 70 | env: |
56 | 71 | TWINE_USERNAME: __token__ |
57 | 72 | TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} |
58 | 73 | run: twine upload dist/* |
59 | | - |
60 | | - - name: Raise PR from main to master |
61 | | - uses: peter-evans/create-pull-request@v5 |
62 | | - with: |
63 | | - base: master |
64 | | - head: main |
65 | | - title: "Release PR: main -> master" |
66 | | - body: "This PR merges the changes from the main branch back into master after the release." |
67 | | - branch: pr-main-to-master |
|
0 commit comments