-
Notifications
You must be signed in to change notification settings - Fork 0
32 lines (27 loc) · 957 Bytes
/
update-api-version.yaml
File metadata and controls
32 lines (27 loc) · 957 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
name: Update Version and Release
on:
push:
branches:
- master
permissions:
contents: write
jobs:
update-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Extract latest version from CHANGELOG.md
id: get_version
run: |
VERSION=$(grep -oP '\[\K[0-9]+\.[0-9]+\.[0-9]+' CHANGELOG.md | head -1)
echo "::set-output name=VERSION::$VERSION"
- name: Update version in cmd/api/main.go
run: |
sed -i "s/var version = \".*\"/var version = \"${{ steps.get_version.outputs.VERSION }}\"/" cmd/api/main.go
- name: Commit and push if changed
run: |
git config --global user.email "action@github.com"
git config --global user.name "GitHub Action"
git add cmd/api/main.go
git commit -m "Update version to ${{ steps.get_version.outputs.VERSION }}" || echo "No changes to commit"
git push