|
9 | 9 | jobs: |
10 | 10 | release: |
11 | 11 | runs-on: ubuntu-latest |
| 12 | + permissions: |
| 13 | + contents: write |
| 14 | + id-token: write |
12 | 15 | steps: |
13 | | - - uses: actions/checkout@v4 |
| 16 | + - name: Checkout code |
| 17 | + uses: actions/checkout@v3 |
14 | 18 | with: |
15 | 19 | fetch-depth: 0 |
| 20 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 21 | + |
16 | 22 | - name: Set up Python |
17 | 23 | uses: actions/setup-python@v3 |
18 | 24 | with: |
19 | 25 | python-version: "3.x" |
| 26 | + |
20 | 27 | - name: Install dependencies |
21 | 28 | run: | |
22 | 29 | python -m pip install --upgrade pip |
23 | | - pip install build twine semantic-release setuptools-scm |
| 30 | + pip install build twine python-semantic-release setuptools-scm |
| 31 | +
|
24 | 32 | - name: Run semantic-release |
25 | 33 | env: |
26 | 34 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
27 | 35 | run: | |
28 | | - git config user.name github-actions |
29 | | - git config user.email github-actions@github-actions.github.com |
| 36 | + git config --global user.name "github-actions" |
| 37 | + git config --global user.email "github-actions@github.com" |
30 | 38 | semantic-release version |
31 | 39 | semantic-release publish |
| 40 | +
|
32 | 41 | - name: Build package |
33 | 42 | run: python -m build |
| 43 | + |
34 | 44 | - name: Publish package to PyPI |
35 | 45 | env: |
36 | 46 | TWINE_USERNAME: __token__ |
37 | 47 | TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} |
38 | 48 | run: twine upload dist/* |
39 | | - - name: Delete release-main branch from remote |
40 | | - run: git push origin --delete release-main |
| 49 | + |
| 50 | + create-pr-back-to-master: |
| 51 | + needs: release |
| 52 | + runs-on: ubuntu-latest |
| 53 | + permissions: |
| 54 | + contents: write |
| 55 | + pull-requests: write |
| 56 | + steps: |
| 57 | + - name: Checkout code |
| 58 | + uses: actions/checkout@v3 |
| 59 | + with: |
| 60 | + fetch-depth: 0 |
| 61 | + ref: main |
| 62 | + |
| 63 | + - name: Set Git Identity |
| 64 | + run: | |
| 65 | + git config --global user.name 'GitHub Actions' |
| 66 | + git config --global user.email 'github-actions@github.com' |
| 67 | +
|
| 68 | + - name: Create Pull Request from main to master |
| 69 | + env: |
| 70 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 71 | + run: | |
| 72 | + # Fetch the latest from master |
| 73 | + git fetch origin master:refs/remotes/origin/master |
| 74 | +
|
| 75 | + # Check if there are differences between main and master |
| 76 | + DIFF_COUNT=$(git rev-list --count origin/master..HEAD) |
| 77 | +
|
| 78 | + if [ "$DIFF_COUNT" -gt 0 ]; then |
| 79 | + echo "Differences found between main and master. Creating PR..." |
| 80 | + |
| 81 | + # Use GitHub CLI to create the PR |
| 82 | + gh pr create \ |
| 83 | + --base master \ |
| 84 | + --head main \ |
| 85 | + --title "Sync master with main after release" \ |
| 86 | + --body "This is an automated PR to sync changes from main back to master after a release." || true |
| 87 | + |
| 88 | + echo "Pull request created or already exists." |
| 89 | + else |
| 90 | + echo "No differences found between main and master. Skipping PR creation." |
| 91 | + fi |
0 commit comments