Skip to content

Commit

Permalink
Merge pull request #1 from AmanChh/dynamic-version
Browse files Browse the repository at this point in the history
Dynamic version
  • Loading branch information
AmanChh authored Apr 1, 2024
2 parents e447e58 + d43d265 commit b516a1a
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
42 changes: 42 additions & 0 deletions .github/workflows/actions.yml
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
2 changes: 1 addition & 1 deletion redli.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ var (
)

func main() {
kingpin.Version("0.5.2")
kingpin.Version(version)
kingpin.Parse()

if *forceraw {
Expand Down
5 changes: 5 additions & 0 deletions version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package main

const (
version = "v0.0.4"
)

0 comments on commit b516a1a

Please sign in to comment.