Release #4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: read | |
| id-token: write | |
| jobs: | |
| check: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 | |
| - 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 | |
| - name: Check tag does not already exist | |
| 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." | |
| exit 1 | |
| fi | |
| build: | |
| needs: check | |
| uses: ./.github/workflows/go.yml | |
| release: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| environment: release | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 | |
| - name: Tag and create GitHub Release | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| tag="v${{ github.event.inputs.version }}" | |
| gh release create "$tag" \ | |
| --title "$tag" \ | |
| --target "$GITHUB_SHA" \ | |
| --generate-notes |