From ae944a16c1976f2a0f3eebb83428587749f0b0b8 Mon Sep 17 00:00:00 2001 From: matthewpeterkort Date: Thu, 11 Jun 2026 13:07:18 -0700 Subject: [PATCH 1/2] fix branch name --- .github/workflows/release.yaml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 9c18781..c3016a7 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -9,7 +9,7 @@ on: workflow_dispatch: concurrency: - group: release-main + group: release-default-branch cancel-in-progress: false permissions: @@ -22,7 +22,10 @@ jobs: ( github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push' && - github.event.workflow_run.head_branch == 'main' + ( + github.event.workflow_run.head_branch == 'master' || + github.event.workflow_run.head_branch == 'main' + ) ) runs-on: ubuntu-latest outputs: From 82a6bec84e4556e15c313e214733cce8aac513f7 Mon Sep 17 00:00:00 2001 From: matthewpeterkort Date: Thu, 11 Jun 2026 13:22:23 -0700 Subject: [PATCH 2/2] fix gh action version naming --- .github/workflows/release.yaml | 42 ++++++++++++++++++++++++---------- .goreleaser.yaml | 2 +- Dockerfile | 1 + cmd/gitversion.go | 1 + cmd/root.go | 4 +++- 5 files changed, 36 insertions(+), 14 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index c3016a7..f4f02b7 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -30,22 +30,13 @@ jobs: runs-on: ubuntu-latest outputs: release_tag: ${{ steps.next-tag.outputs.release_tag }} - release_sha: ${{ steps.resolve-sha.outputs.release_sha }} + release_sha: ${{ steps.bump-version.outputs.release_sha }} steps: - name: Check out code uses: actions/checkout@v4 with: fetch-depth: 0 - ref: ${{ github.event_name == 'workflow_dispatch' && github.ref || github.event.workflow_run.head_sha }} - - - name: Resolve release SHA - id: resolve-sha - run: | - if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then - echo "release_sha=${GITHUB_SHA}" >> "$GITHUB_OUTPUT" - else - echo "release_sha=${{ github.event.workflow_run.head_sha }}" >> "$GITHUB_OUTPUT" - fi + ref: ${{ github.event_name == 'workflow_dispatch' && github.ref_name || github.event.workflow_run.head_branch }} - name: Determine next release tag id: next-tag @@ -105,12 +96,39 @@ jobs: core.info(`Next release tag: ${nextTag}`); core.setOutput("release_tag", nextTag); + - name: Bump source version file + id: bump-version + env: + RELEASE_TAG: ${{ steps.next-tag.outputs.release_tag }} + RELEASE_BRANCH: ${{ github.event_name == 'workflow_dispatch' && github.ref_name || github.event.workflow_run.head_branch }} + run: | + set -euo pipefail + + version="${RELEASE_TAG#v}" + sed -E -i.bak "s/(gitversion *= *\")[^\"]+(\")/\1${version}\2/" cmd/gitversion.go + rm -f cmd/gitversion.go.bak + + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git add cmd/gitversion.go + + if git diff --cached --quiet; then + echo "cmd/gitversion.go already matches ${version}" + else + git commit -m "chore(release): bump version to ${version} [skip ci]" + git push origin "HEAD:${RELEASE_BRANCH}" + fi + + echo "release_sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" + - name: Create annotated tag + env: + RELEASE_SHA: ${{ steps.bump-version.outputs.release_sha }} run: | set -euo pipefail git config user.name "github-actions[bot]" git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - git tag -a "${{ steps.next-tag.outputs.release_tag }}" "${{ steps.resolve-sha.outputs.release_sha }}" -m "Release ${{ steps.next-tag.outputs.release_tag }}" + git tag -a "${{ steps.next-tag.outputs.release_tag }}" "${RELEASE_SHA}" -m "Release ${{ steps.next-tag.outputs.release_tag }}" git push origin "${{ steps.next-tag.outputs.release_tag }}" goreleaser: diff --git a/.goreleaser.yaml b/.goreleaser.yaml index d778196..e7b653f 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -20,7 +20,7 @@ builds: - amd64 - arm64 ldflags: - - -s -w -X github.com/calypr/calypr-cli/cmd.gitversion={{ .Version }} -X github.com/calypr/calypr-cli/cmd.gitcommit={{ .Commit }} + - -s -w -X github.com/calypr/calypr-cli/cmd.gitversion={{ .Version }} -X github.com/calypr/calypr-cli/cmd.gitcommit={{ .Commit }} -X github.com/calypr/calypr-cli/cmd.gitdate={{ .Date }} archives: - id: default diff --git a/Dockerfile b/Dockerfile index 753d86e..677a135 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,6 +19,7 @@ RUN COMMIT=$(git rev-parse HEAD); \ ''\ 'const ('\ ' gitcommit="'"${COMMIT}"'"'\ + ' gitdate="'"$(date -u +%Y-%m-%dT%H:%M:%SZ)"'"'\ ' gitversion="'"${VERSION}"'"'\ ')' > cmd/gitversion.go \ && go build -o /calypr-cli . diff --git a/cmd/gitversion.go b/cmd/gitversion.go index ce96e41..070945a 100644 --- a/cmd/gitversion.go +++ b/cmd/gitversion.go @@ -2,5 +2,6 @@ package cmd var ( gitcommit = "N/A" + gitdate = "unknown" gitversion = "2026.2" ) diff --git a/cmd/root.go b/cmd/root.go index 355d88d..2a352c5 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -1,6 +1,7 @@ package cmd import ( + "fmt" "os" "github.com/spf13/cobra" @@ -13,7 +14,7 @@ var backendType string var RootCmd = &cobra.Command{ Use: "calypr-cli", Short: "Calypr CLI for data transfer, permissions, collaboration, and portal operations", - Long: "Calypr CLI for data transfer, permissions, collaboration, and portal operations.\ncalypr-cli version: " + gitversion + ", commit: " + gitcommit, + Long: "Calypr CLI for data transfer, permissions, collaboration, and portal operations.\ncalypr-cli version: " + gitversion + ", commit: " + gitcommit + ", build date: " + gitdate, Version: gitversion, SilenceErrors: true, } @@ -31,4 +32,5 @@ func init() { RootCmd.PersistentFlags().StringVar(&profile, "profile", "", "Specify profile to use") RootCmd.PersistentFlags().StringVar(&backendType, "backend", "gen3", "Specify backend to use (gen3 or drs)") _ = RootCmd.MarkFlagRequired("profile") + RootCmd.SetVersionTemplate(fmt.Sprintf("calypr-cli %s\ncommit: %s\nbuild date: %s\n", "{{.Version}}", gitcommit, gitdate)) }