Skip to content

Commit 847869c

Browse files
committed
add post-merge release workflow
1 parent b3d9af2 commit 847869c

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Post-Merge Release Actions
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
branches:
7+
- 'main'
8+
env:
9+
GITHUB_USER: "datavisyn-bot"
10+
GITHUB_TOKEN: ${{ secrets.DATAVISYN_BOT_REPO_TOKEN }}
11+
12+
jobs:
13+
post_release:
14+
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.title, 'Release')
15+
runs-on: ubuntu-22.04
16+
steps:
17+
- name: checkout repository
18+
uses: actions/checkout@v4
19+
with:
20+
token: ${{ secrets.CHECKOUT_TOKEN || github.event.repository.private == true && secrets.DATAVISYN_BOT_REPO_TOKEN || github.token }}
21+
22+
- name: Generate Release Notes
23+
id: generate-release-notes
24+
run: |
25+
response=$(curl -s -X POST \
26+
-H "Accept: application/vnd.github+json" \
27+
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
28+
https://api.github.com/repos/${{ github.repository }}/releases/generate-notes \
29+
-d "$(jq -n --arg tag_name "v${{ github.event.pull_request.title.split(' ')[1] }}" \
30+
--arg target_commitish "main" \
31+
'{tag_name: $tag_name, target_commitish: $target_commitish}')")
32+
echo "$(echo "$response" | jq -r '.body')" > release_notes.txt
33+
34+
- name: Create GitHub Release
35+
run: |
36+
TAG="v${{ github.event.pull_request.title.split(' ')[1] }}"
37+
RELEASE_NOTES=$(cat release_notes.txt)
38+
curl -X POST \
39+
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
40+
-H "Accept: application/vnd.github.v3+json" \
41+
https://api.github.com/repos/${{ github.repository.full_name }}/releases \
42+
-d '{
43+
"tag_name": "'"$TAG"'",
44+
"target_commitish": "main",
45+
"name": "'"$TAG"'",
46+
"body": "'"$RELEASE_NOTES"'",
47+
"draft": false,
48+
"prerelease": false
49+
}'
50+
51+
- name: Merge Main into Develop
52+
run: |
53+
git config user.name "$GITHUB_ACTOR"
54+
git config user.email "<>"
55+
git checkout develop
56+
git pull origin main
57+
git push origin develop
58+
59+
- name: Update Package Version for Next Development Cycle
60+
run: |
61+
CURRENT_VERSION=$(jq -r '.version' package.json)
62+
NEW_VERSION=$(echo "$CURRENT_VERSION" | awk -F. -v OFS=. '{$NF += 1 ; print $0"-SNAPSHOT"}')
63+
jq --arg new_version "$NEW_VERSION" '.version = $new_version' package.json > tmp.json && mv tmp.json package.json
64+
65+
git add package.json
66+
git commit -m "Bump to $NEW_VERSION"
67+
git push origin develop

0 commit comments

Comments
 (0)