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
4 changes: 4 additions & 0 deletions .changes/cache-built-binary.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
kind: fixed
---
Cache the compiled binary keyed on a source content hash instead of recompiling via `go run .` every invocation; fixes the non-functional setup-go module cache (its cache-dependency-path sat outside GITHUB_WORKSPACE) and removes the per-run compile cost
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/release-tool
39 changes: 35 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,40 @@ outputs:
runs:
using: composite
steps:
# Cache the compiled binary instead of recompiling via `go run .` on every
# invocation. The key is a content hash of the Go sources, so it is correct
# both for external consumers (pinned by SHA, source under _actions/) and for
# this repo's own `uses: ./` self-invocation (source changes per commit).
# setup-go's own module cache can't help here: its cache-dependency-path is
# the action's go.sum under _actions/, outside GITHUB_WORKSPACE, which the
# cache key resolver rejects ("Some specified paths were not resolved").
- name: Hash release-tool sources
id: srchash
shell: bash
working-directory: ${{ github.action_path }}
run: |
h=$(find . -type f \( -name '*.go' -o -name 'go.mod' -o -name 'go.sum' \) \
-print0 | sort -z | xargs -0 sha256sum | sha256sum | awk '{print $1}')
echo "hash=$h" >> "$GITHUB_OUTPUT"

- name: Restore release-tool binary
id: cache-bin
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: ${{ github.action_path }}/release-tool
key: release-tool-${{ runner.os }}-${{ runner.arch }}-go${{ inputs.go-version }}-${{ steps.srchash.outputs.hash }}

- uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
if: steps.cache-bin.outputs.cache-hit != 'true'
with:
go-version: ${{ inputs.go-version }}
cache-dependency-path: ${{ github.action_path }}/go.sum
cache: false

- name: Build release-tool
if: steps.cache-bin.outputs.cache-hit != 'true'
shell: bash
working-directory: ${{ github.action_path }}
run: go build -o release-tool .

- name: Configure git identity
shell: bash
Expand All @@ -99,18 +129,19 @@ runs:
BASE_SHA: ${{ inputs.base-sha }}
PR_NUMBER: ${{ inputs.pr-number }}
run: |
BIN="$PWD/release-tool"
case "$RELEASE_MODE" in
release)
ARGS=(--root "$WORKSPACE" --output "$WORKSPACE/$RELEASE_OUTPUT")
[ -n "$RELEASE_NOTES" ] && ARGS+=(--notes "$WORKSPACE/$RELEASE_NOTES")
[ "$DRY_RUN" = "true" ] && ARGS+=(--dry-run)
go run . release "${ARGS[@]}"
"$BIN" release "${ARGS[@]}"
;;
status)
go run . status --root "$WORKSPACE"
"$BIN" status --root "$WORKSPACE"
;;
check)
go run . check --root "$WORKSPACE" \
"$BIN" check --root "$WORKSPACE" \
--base "$BASE_REF" \
--against "$BASE_SHA" \
--pr "$PR_NUMBER" \
Expand Down
Loading