Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 35 additions & 14 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
workflow_dispatch:

concurrency:
group: release-main
group: release-default-branch
cancel-in-progress: false

permissions:
Expand All @@ -22,27 +22,21 @@ 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:
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
Expand Down Expand Up @@ -102,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:
Expand Down
2 changes: 1 addition & 1 deletion .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 .
Expand Down
1 change: 1 addition & 0 deletions cmd/gitversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ package cmd

var (
gitcommit = "N/A"
gitdate = "unknown"
gitversion = "2026.2"
)
4 changes: 3 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmd

import (
"fmt"
"os"

"github.com/spf13/cobra"
Expand All @@ -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,
}
Expand All @@ -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))
}
Loading