Skip to content

Commit 2624bf4

Browse files
authored
Merge branch 'main' into free_disk_space
2 parents 8e17572 + 64a89ee commit 2624bf4

File tree

1 file changed

+111
-0
lines changed

1 file changed

+111
-0
lines changed
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
name: Post-Merge Release Actions
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
base_branch:
7+
type: string
8+
description: "The base branch to check for merged PRs"
9+
required: false
10+
default: "main"
11+
develop_branch:
12+
type: string
13+
description: "The branch to merge into"
14+
required: false
15+
default: "develop"
16+
pr_title:
17+
type: string
18+
description: "The title of the merged pull request"
19+
required: true
20+
pr_number:
21+
type: string
22+
description: "The number of the merged pull request"
23+
required: true
24+
repository_owner:
25+
type: string
26+
description: "The owner of the repository"
27+
required: true
28+
repository_name:
29+
type: string
30+
description: "The name of the repository"
31+
required: true
32+
33+
34+
permissions:
35+
contents: write
36+
pull-requests: write
37+
38+
env:
39+
GITHUB_USER: "datavisyn-bot"
40+
GITHUB_TOKEN: ${{ secrets.DATAVISYN_BOT_REPO_TOKEN }}
41+
42+
jobs:
43+
post_release:
44+
runs-on: ubuntu-22.04
45+
steps:
46+
- name: Checkout Repository
47+
uses: actions/checkout@v4
48+
with:
49+
token: ${{ secrets.CHECKOUT_TOKEN || github.event.repository.private == true && secrets.DATAVISYN_BOT_REPO_TOKEN || github.token }}
50+
fetch-depth: 0
51+
52+
- name: Create and Push Tag
53+
run: |
54+
TAG_NAME="v$(echo "${{ inputs.pr_title }}" | awk '{print $2}')"
55+
git tag "$TAG_NAME"
56+
git push origin "$TAG_NAME"
57+
58+
- name: Get PR body from release PR for release notes
59+
id: get-pr-body
60+
run: |
61+
echo "Fetching PR body for release notes..."
62+
PR_RESPONSE=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
63+
-H "Accept: application/vnd.github.v3+json" \
64+
https://api.github.com/repos/${{ inputs.repository_owner }}/${{ inputs.repository_name }}/pulls/${{ inputs.pr_number }})
65+
66+
PR_BODY=$(echo "$PR_RESPONSE" | jq -r '.body')
67+
echo "$PR_BODY" > pr_release_notes.txt
68+
69+
- name: Create GitHub Release
70+
run: |
71+
TAG_NAME="v$(echo "${{ inputs.pr_title }}" | awk '{print $2}')"
72+
RELEASE_NOTES=$(cat pr_release_notes.txt)
73+
74+
RESPONSE=$(curl -s -o response.json -w "%{http_code}" -X POST \
75+
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
76+
-H "Accept: application/vnd.github.v3+json" \
77+
https://api.github.com/repos/${{ inputs.repository_owner }}/${{ inputs.repository_name }}/releases \
78+
-d "$(jq -n \
79+
--arg tag_name "$TAG_NAME" \
80+
--arg target_commitish "${{ inputs.base_branch }}" \
81+
--arg name "$TAG_NAME" \
82+
--arg body "$RELEASE_NOTES" \
83+
'{tag_name: $tag_name, target_commitish: $target_commitish, name: $name, body: $body, draft: false, prerelease: false}')")
84+
85+
if [ "$RESPONSE" -ne 201 ]; then
86+
echo "Failed to create GitHub release. Status code: $RESPONSE"
87+
echo "Response body:"
88+
cat response.json
89+
exit 1
90+
else
91+
echo "GitHub release '$TAG_NAME' created successfully."
92+
fi
93+
94+
- name: Merge Main into Develop
95+
run: |
96+
git config user.name "$GITHUB_ACTOR"
97+
git config user.email "<>"
98+
git checkout ${{ inputs.develop_branch }}
99+
git fetch origin ${{ inputs.base_branch }}
100+
git merge origin/${{ inputs.base_branch }}
101+
git push origin ${{ inputs.develop_branch }}
102+
103+
- name: Update Package Version for Next Development Cycle
104+
run: |
105+
CURRENT_VERSION=$(jq -r '.version' package.json)
106+
NEW_VERSION=$(echo "$CURRENT_VERSION" | awk -F. -v OFS=. '{$NF += 1 ; print $0"-SNAPSHOT"}')
107+
jq --arg new_version "$NEW_VERSION" '.version = $new_version' package.json > tmp.json && mv tmp.json package.json
108+
109+
git add package.json
110+
git commit -m "chore: prepare next dev release"
111+
git push origin ${{ inputs.develop_branch }}

0 commit comments

Comments
 (0)