Skip to content

Commit 8272cbe

Browse files
fix: update-workflow
1 parent 76931b5 commit 8272cbe

File tree

1 file changed

+57
-6
lines changed

1 file changed

+57
-6
lines changed

.github/workflows/release-and-publish.yml

Lines changed: 57 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,83 @@ on:
99
jobs:
1010
release:
1111
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
id-token: write
1215
steps:
13-
- uses: actions/checkout@v4
16+
- name: Checkout code
17+
uses: actions/checkout@v3
1418
with:
1519
fetch-depth: 0
20+
token: ${{ secrets.GITHUB_TOKEN }}
21+
1622
- name: Set up Python
1723
uses: actions/setup-python@v3
1824
with:
1925
python-version: "3.x"
26+
2027
- name: Install dependencies
2128
run: |
2229
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+
2432
- name: Run semantic-release
2533
env:
2634
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2735
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"
3038
semantic-release version
3139
semantic-release publish
40+
3241
- name: Build package
3342
run: python -m build
43+
3444
- name: Publish package to PyPI
3545
env:
3646
TWINE_USERNAME: __token__
3747
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
3848
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

Comments
 (0)