diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml new file mode 100644 index 0000000..0fec9cd --- /dev/null +++ b/.github/workflows/actions.yml @@ -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 diff --git a/redli.go b/redli.go index e4920c1..a151df7 100644 --- a/redli.go +++ b/redli.go @@ -64,7 +64,7 @@ var ( ) func main() { - kingpin.Version("0.5.2") + kingpin.Version(version) kingpin.Parse() if *forceraw { diff --git a/version.go b/version.go new file mode 100644 index 0000000..73f823f --- /dev/null +++ b/version.go @@ -0,0 +1,5 @@ +package main + +const ( + version = "v0.0.4" +)