Skip to content

Commit b135ea5

Browse files
committed
[#723] Automate GitHub Release creation process and tagging
1 parent 341c038 commit b135ea5

3 files changed

Lines changed: 81 additions & 7 deletions

File tree

.cicdtemplate/.github/workflows/configs/changelog-config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@
3131
]
3232
}
3333
],
34-
"max_pull_requests": 200
34+
"pr_template": "- #{{TITLE}} (by @#{{ASSIGNEES}} in [##{{NUMBER}}](#{{URL}}))"
3535
}

.cicdtemplate/.github/workflows/create_release_pull_request.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,27 @@ jobs:
1111
name: Create Release Pull Request
1212
runs-on: ubuntu-latest
1313
timeout-minutes: 30
14+
permissions:
15+
contents: write
16+
pull-requests: write
17+
issues: read
1418
steps:
1519
- name: Checkout code
1620
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # actions/checkout@v6.0.2
1721
with:
18-
fetch-depth: 1
22+
fetch-depth: 0
1923

2024
- name: Get release version
25+
id: extract_version
2126
run: |
2227
filename=$(find . -maxdepth 1 -name "*.xcodeproj" -exec basename {} .xcodeproj \; | head -n 1)
23-
release_version=$(sed -n 's/.*MARKETING_VERSION *= *\([^;]*\);.*/\1/p' "$filename.xcodeproj/project.pbxproj" | head -n 1 | sed 's/^[^=]*=\s*//' | tr -d ' ')
24-
echo $release_version
25-
echo "RELEASE_VERSION=$release_version" >> "$GITHUB_ENV"
28+
version=$(sed -n 's/.*MARKETING_VERSION *= *\([^;]*\);.*/\1/p' "$filename.xcodeproj/project.pbxproj" | head -n 1 | sed 's/^[^=]*=\s*//' | tr -d ' ')
29+
echo "version=$version" >> "$GITHUB_OUTPUT"
30+
echo "Build version: $version"
2631
2732
- uses: nimblehq/github-actions-workflows/create_release_pull_request@d2f913f1faba9dd814eb0cab86147d2bab6e0e34 # nimblehq/github-actions-workflows/create_release_pull_request@v0.1.10
2833
with:
29-
release_version: ${{ env.RELEASE_VERSION }}
34+
release_version: "${{ steps.extract_version.outputs.version }}"
3035
changelog_configuration: ".github/workflows/configs/changelog-config.json"
31-
assignee: bot-nimble
36+
base_branch: main
37+
assignee: ${{ github.actor }}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Tag the new Release
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
branches:
7+
- main
8+
9+
permissions:
10+
actions: write
11+
contents: write
12+
13+
jobs:
14+
tag_and_release:
15+
name: Tag and release
16+
if: |
17+
github.event.pull_request.merged == true
18+
&& contains(github.event.pull_request.labels.*.name, 'type : release')
19+
runs-on: ubuntu-latest
20+
timeout-minutes: 10
21+
steps:
22+
- name: Extract release version from head branch
23+
id: extract_version
24+
shell: bash
25+
run: |
26+
head_ref="${{ github.event.pull_request.head.ref }}"
27+
if [[ ! "$head_ref" =~ ^release/([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
28+
echo "Head ref '$head_ref' does not match release/X.Y.Z pattern"
29+
exit 1
30+
fi
31+
version="${BASH_REMATCH[1]}"
32+
echo "version=$version" >> "$GITHUB_OUTPUT"
33+
echo "Extracted version: $version"
34+
35+
- name: Checkout main at merge commit
36+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # actions/checkout@v6.0.2
37+
with:
38+
ref: ${{ github.event.pull_request.merge_commit_sha }}
39+
fetch-depth: 0
40+
41+
- name: Ensure tag does not already exist
42+
shell: bash
43+
run: |
44+
tag="${{ steps.extract_version.outputs.version }}"
45+
if git rev-parse "refs/tags/$tag" >/dev/null 2>&1; then
46+
echo "Tag $tag already exists — refusing to overwrite"
47+
exit 1
48+
fi
49+
50+
- name: Create and push tag
51+
shell: bash
52+
run: |
53+
tag="${{ steps.extract_version.outputs.version }}"
54+
git config --local user.email "action@github.com"
55+
git config --local user.name "GitHub Action"
56+
git tag -a "$tag" -m "Release $tag"
57+
git push origin "$tag"
58+
59+
- name: Create GitHub Release
60+
env:
61+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62+
shell: bash
63+
run: |
64+
tag="${{ steps.extract_version.outputs.version }}"
65+
gh release create "$tag" \
66+
--target "${{ github.event.pull_request.merge_commit_sha }}" \
67+
--title "$tag" \
68+
--generate-notes

0 commit comments

Comments
 (0)