Skip to content

Commit 59214df

Browse files
feat: workflows to update api version automatically
1 parent f7a9562 commit 59214df

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Update Version and Release
2+
on:
3+
push:
4+
branches:
5+
- main
6+
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
update-version:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
16+
- name: Extract latest version from CHANGELOG.md
17+
id: get_version
18+
run: |
19+
VERSION=$(grep -oP '\[\K[0-9]+\.[0-9]+\.[0-9]+' CHANGELOG.md | head -1)
20+
echo "::set-output name=VERSION::$VERSION"
21+
22+
- name: Update version in cmd/api/main.go
23+
run: |
24+
sed -i "s/var version = \".*\"/var version = \"${{ steps.get_version.outputs.VERSION }}\"/" cmd/api/main.go
25+
26+
- name: Commit and push if changed
27+
run: |
28+
git config --global user.email "[email protected]"
29+
git config --global user.name "GitHub Action"
30+
git add cmd/api/main.go
31+
git commit -m "Update version to ${{ steps.get_version.outputs.VERSION }}" || echo "No changes to commit"
32+
git push

0 commit comments

Comments
 (0)