Skip to content

Commit

Permalink
feat(version): add version information to cli (#336)
Browse files Browse the repository at this point in the history
* feat(version): add version information to cli

* feat(version): add version check for release

* fix(typo): wrong variable name

* refactor(workflow): separated check version into its own workflow

---------

Co-authored-by: Gabriel Guerra <[email protected]>
  • Loading branch information
guergabo and Gabriel Guerra committed May 23, 2024
1 parent b88be18 commit ed80099
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,17 @@ permissions:
packages: write

jobs:
check-version:
uses: ./.github/workflows/release_check_version.yaml

publish-github-image:
needs: [check-version]
uses: ./.github/workflows/release_publish_github_image.yaml
with:
tag: ${{ github.ref_name }}

publish-github-artifacts:
needs: [check-version]
uses: ./.github/workflows/release_publish_github_artifacts.yaml
with:
tag: ${{ github.ref_name }}
Expand Down
45 changes: 45 additions & 0 deletions .github/workflows/release_check_version.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Check Release Version

on:
workflow_call:
workflow_dispatch:

permissions:
contents: write

jobs:
check-version:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v11

- name: Use Magic Nix Cache
uses: DeterminateSystems/magic-nix-cache-action@v6

- name: Build Resonate binary
run: |
# Build resonate binary
nix build ".#resonate"
# Copy into root
cp ./result/bin/resonate resonate
- name: Check version
env:
GITHUB_REF_VERSION: ${{ github.ref_name }}
run: |
# Extract resonate version
RESONATE_VERSION=$(./resonate -v | awk '{print $3}')
RESONATE_VERSION="v${RESONATE_VERSION}"
# Compare versions
if [ "$RESONATE_VERSION" != "$GITHUB_REF_VERSION" ]; then
echo "Version mismatch: resonate version ($RESONATE_VERSION) does not match GitHub ref ($GITHUB_REF_VERSION)"
exit 1
else
echo "Version match: resonate version ($RESONATE_VERSION) matches GitHub ref ($GITHUB_REF_VERSION)"
fi
5 changes: 3 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ var (
)

var rootCmd = &cobra.Command{
Use: "resonate",
Short: "Durable promises",
Use: "resonate",
Short: "Durable promises",
Version: "0.5.5", // This needs to be bumped when new versions are released.
}

func init() {
Expand Down

0 comments on commit ed80099

Please sign in to comment.