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