Skip to content

Commit 5aaa7ad

Browse files
authored
Refactor Release workflow for submodule handling
Updated release workflow to improve handling of submodules and streamline branch management.
1 parent 47b42ea commit 5aaa7ad

File tree

1 file changed

+64
-33
lines changed

1 file changed

+64
-33
lines changed

.github/workflows/Release.yml

Lines changed: 64 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -9,50 +9,81 @@ concurrency:
99
group: ${{ github.workflow }}
1010
cancel-in-progress: true
1111

12+
env:
13+
RELEASE_BRANCH: release
14+
1215
jobs:
1316

1417
create-git-branch-release:
1518
runs-on: ubuntu-latest
1619
permissions:
1720
contents: write
18-
env:
19-
RELEASE_BRANCH: release
20-
outputs:
21-
branch: ${{ env.RELEASE_BRANCH }}
2221
steps:
23-
- uses: actions/checkout@v5
24-
25-
- name: Create release branch
26-
run: git checkout -B $RELEASE_BRANCH
27-
28-
- name: Remove submodule (if exists)
29-
env:
30-
SUBMODULE_PATH: Submodule/github/rest-api-description
31-
run: |
32-
if [ -d "$SUBMODULE_PATH" ]; then
33-
git config user.name "${GITHUB_ACTOR}"
34-
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
35-
git submodule deinit -f $SUBMODULE_PATH || true
36-
git rm -f $SUBMODULE_PATH || true
37-
rm -rf .git/modules/$SUBMODULE_PATH || true
38-
git commit -m "Remove submodule"
39-
else
40-
echo "Submodule not found, skipping removal."
41-
fi
42-
43-
- name: Push release branch
44-
run: git push --force --set-upstream origin $RELEASE_BRANCH
22+
- uses: actions/checkout@v5
23+
24+
- name: Remove submodule to improve Swift Package experience
25+
env:
26+
SUBMODULE_PATH: Submodule/github/rest-api-description
27+
run: |
28+
if [ -d "$SUBMODULE_PATH" ]; then
29+
#
30+
git config user.name "${GITHUB_ACTOR}"
31+
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
32+
#
33+
git checkout -B $RELEASE_BRANCH
34+
#
35+
git rm $SUBMODULE_PATH
36+
git commit -m "Remove submodule to improve Swift Package experience"
37+
git push --set-upstream origin $RELEASE_BRANCH
38+
else
39+
echo "::error ::Submodule not found, skipping removal."
40+
exit 1
41+
fi
4542
4643
create-github-release:
4744
needs: create-git-branch-release
4845
runs-on: ubuntu-latest
4946
permissions:
5047
contents: write
5148
steps:
52-
- uses: Wei18/GitHubSwiftActions/Actions/Release@1.0.9
53-
with:
54-
owner: ${{ github.repository_owner }}
55-
repo: ${{ github.event.repository.name }}
56-
token: ${{ secrets.GITHUB_TOKEN }}
57-
ref: ${{ needs.create-git-branch-release.outputs.branch }}
58-
type: "patch"
49+
- uses: Wei18/GitHubSwiftActions/Actions/Release@1.0.9
50+
with:
51+
owner: ${{ github.repository_owner }}
52+
repo: ${{ github.event.repository.name }}
53+
token: ${{ github.token }}
54+
ref: ${{ env.RELEASE_BRANCH }}
55+
type: "patch"
56+
57+
create-pull-request:
58+
needs: create-github-release
59+
runs-on: ubuntu-latest
60+
permissions:
61+
contents: write
62+
pull-requests: write
63+
64+
steps:
65+
- uses: actions/checkout@v5
66+
with:
67+
ref: ${{ env.RELEASE_BRANCH }}
68+
69+
- name: Revert previous commit
70+
run: |
71+
if [ ! -d "$SUBMODULE_PATH" ]; then
72+
#
73+
git config user.name "${GITHUB_ACTOR}"
74+
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
75+
#
76+
git revert --no-edit HEAD
77+
git push
78+
else
79+
echo "::error ::Submodule already exists, skipping restore."
80+
exit 1
81+
fi
82+
83+
- name: Create pull request
84+
env:
85+
GITHUB_TOKEN: ${{ github.token }}
86+
run: |
87+
PR_URL="$(gh pr create --head $RELEASE_BRANCH --title 'Bump patch version' --body 'Automated monthly release merge')"
88+
gh pr merge --auto --merge "$PR_URL"
89+
gh pr merge --merge --admin "$PR_URL"

0 commit comments

Comments
 (0)