Skip to content
Open
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
62 changes: 62 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Release

on:
workflow_dispatch:
inputs:
version:
description: "Version to release, without the leading v (e.g. 2.3.0). Must match Version in secretcache/versionInfo.go."
required: true
type: string

permissions:
contents: write

jobs:
release:
runs-on: ubuntu-latest

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gate this workflow on an environment so we can restrict this to running under a 2PR.

steps:
- uses: actions/checkout@v5

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For our release workflows we tie GitHub actions we use to a SHA hash. This is to prevent supply chain attacks.


- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: "1.24"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might want to go with "stable". Or follow the other comment and reuse the build workflow.


- name: Check version matches versionInfo.go
run: |
input="${{ github.event.inputs.version }}"
if ! echo "$input" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then
echo "::error::Version '$input' is not strict semver (expected x.y.z)."
exit 1
fi
repo=$(grep -oE 'Version = "[^"]+"' secretcache/versionInfo.go \
| grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
echo "Requested version: $input"
echo "versionInfo.go version: $repo"
if [ "$input" != "$repo" ]; then
echo "::error::Requested version ($input) does not match Version in secretcache/versionInfo.go ($repo)."
exit 1
fi

@bob2681312 bob2681312 Aug 7, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Consider adding a check to make sure the requested new version is correct with respect to the previously released version. e.g. v3.1.0 -> v3.1.1 is fine, but v3.1.0 -> v3.2.1 is not.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would the latter example you provided not be ok?

- name: Check tag does not already exist

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just attempt the push? It will fail if the tag already exists.

run: |
tag="v${{ github.event.inputs.version }}"
if git ls-remote --exit-code --tags origin "refs/tags/$tag" >/dev/null 2>&1; then
echo "::error::Tag $tag already exists. Releases are immutable; bump the version to release again."
exit 1
fi

- name: Build

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can reuse existing workflows using workflow_call.

run: go build -v ./...

- name: Test
run: go test -v ./secretcache

- name: Tag and create GitHub Release
env:
GH_TOKEN: ${{ github.token }}
run: |
tag="v${{ github.event.inputs.version }}"
gh release create "$tag" \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a matching git tag does not yet exist, one will automatically get created from the latest state of the default branch. Use --target to point to a different branch or commit for the automatic tag creation. Use --verify-tag to abort the release if the tag doesn't already exist.

From https://cli.github.com/manual/gh_release_create

--title "$tag" \
--generate-notes
Loading