forked from IBM-Cloud/redli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from AmanChh/dynamic-version
Dynamic version
- Loading branch information
Showing
3 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: Update Values on Tag | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' # Trigger only in case of new tag | ||
|
||
jobs: | ||
update_values: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: Set up Go v1.21.4 | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: '1.21.4' | ||
- name: Get tag and set version on release | ||
if: startsWith(github.ref, 'refs/tags/v') | ||
run: | | ||
sed -i "s|version = \"v.*\"|version = \"$GITHUB_REF_NAME\"|" version.go | ||
cat -n version.go | ||
- name: Set VERSION env vars | ||
run: | | ||
VERSION="$GITHUB_REF_NAME" | ||
if [[ $GITHUB_REF != "refs/tags/v"* ]]; then | ||
VERSION="${GITHUB_SHA::7}" | ||
fi | ||
echo "VERSION=$VERSION" | tee -a "$GITHUB_ENV" | ||
- name: Bump version on release [${{ env.VERSION }}] | ||
if: startsWith(github.ref, 'refs/tags/v') | ||
run: | | ||
git config user.name "${{ github.actor }}" | ||
git config user.email "${{ github.actor }}@users.noreply.github.com" | ||
if [[ $(git diff version.go) != "" ]]; then | ||
git checkout master | ||
git add version.go | ||
git commit -m "[CI] Bump version to $VERSION" | ||
git push | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package main | ||
|
||
const ( | ||
version = "v0.0.4" | ||
) |