Skip to content

Commit

Permalink
fix: alter gh version action logic, version logging
Browse files Browse the repository at this point in the history
  • Loading branch information
dtbuchholz committed Dec 18, 2023
1 parent f02b0ab commit c270b94
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 23 deletions.
38 changes: 16 additions & 22 deletions .github/workflows/update-version.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,32 @@
name: Update Version
name: Update version file

on:
push:
branches:
- main
- dtb/cli-positionals # tmp
workflow_dispatch:

jobs:
update-version:
update_version:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Git
run: |
git config --global user.name 'GitHub Actions'
git config --global user.email 'actions@github.com'
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Get latest tag
id: get-latest-tag
run: echo ::set-output name=TAG::$(git describe --tags --abbrev=0)
id: get-tag
run: |
echo "LATEST_TAG=$(git describe --tags $(git rev-list --tags --max-count=1))" >> $GITHUB_OUTPUT
- name: Update version.json
run: |
echo "{\"version\": \"${{ steps.get-latest-tag.outputs.TAG }}\"}" > version.json
echo "{
\"version\": \"${{steps.get-tag.outputs.LATEST_TAG}}\"
}" > version.json
- name: Commit and push if changed
run: |
git diff
if [ -n "$(git diff --name-only)" ]; then
git add version.json
git commit -m "Update version to ${{ steps.get-latest-tag.outputs.TAG }}"
git push
else
echo "No changes in version.json"
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "chore: update version to ${{steps.get-tag.outputs.LATEST_TAG}}"
2 changes: 1 addition & 1 deletion cmd/vaults/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
func init() {
cli.VersionFlag = &cli.BoolFlag{Name: "version", Aliases: []string{"V"}, Usage: "show version"} // Enforce uppercase
cli.VersionPrinter = func(c *cli.Context) {
fmt.Printf("v%s\n", c.App.Version)
fmt.Printf("%s\n", c.App.Version)
}
}

Expand Down

0 comments on commit c270b94

Please sign in to comment.