Skip to content

Commit b8a422f

Browse files
feat: update api version automatically
1 parent 80d8625 commit b8a422f

File tree

3 files changed

+32
-83
lines changed

3 files changed

+32
-83
lines changed

.chglog/CHANGELOG.tpl.md

Lines changed: 0 additions & 56 deletions
This file was deleted.

.chglog/config.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.
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 "action@github.com"
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)