Add a new optional cache-token input to both published actions. - Default cache key token is now action_repository + release_tag. - Cache key uses this token plus runner architecture. - prepare-release workflow passes github.sha as a fixed token. This prevents cross-repository cache collisions when consumers pull vociferate binaries produced by this repository.
176 lines
6.3 KiB
YAML
176 lines
6.3 KiB
YAML
name: vociferate
|
|
description: Prepare release files or recommend a next semantic version tag.
|
|
|
|
inputs:
|
|
token:
|
|
description: Optional token used to download the cached vociferate release binary. When omitted, the workflow token is used.
|
|
required: false
|
|
default: ''
|
|
version:
|
|
description: Optional semantic version override. When omitted, the recommended version is used.
|
|
required: false
|
|
version-file:
|
|
description: Path to version file relative to repository root. When omitted, the current version is derived from the most recent released section in the changelog.
|
|
required: false
|
|
default: ''
|
|
version-pattern:
|
|
description: Regular expression with one capture group for current version. Only required when version-file is set.
|
|
required: false
|
|
default: ''
|
|
changelog:
|
|
description: Path to changelog file relative to repository root.
|
|
required: false
|
|
default: changelog.md
|
|
recommend:
|
|
description: If true, print recommended next release tag.
|
|
required: false
|
|
default: 'false'
|
|
cache-token:
|
|
description: >
|
|
Optional fixed cache token used for the downloaded binary cache key.
|
|
Defaults to action repository plus release tag.
|
|
required: false
|
|
default: ''
|
|
|
|
outputs:
|
|
version:
|
|
description: Resolved version used for prepare mode, or the emitted recommended version for recommend mode.
|
|
value: ${{ steps.run-vociferate.outputs.version }}
|
|
|
|
runs:
|
|
using: composite
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Resolve vociferate binary metadata
|
|
id: resolve-binary
|
|
shell: bash
|
|
env:
|
|
ACTION_REF: ${{ github.action_ref }}
|
|
ACTION_REPOSITORY: ${{ github.action_repository }}
|
|
CACHE_TOKEN_INPUT: ${{ inputs.cache-token }}
|
|
SERVER_URL: ${{ github.server_url }}
|
|
API_URL: ${{ github.api_url }}
|
|
TOKEN: ${{ inputs.token != '' && inputs.token || github.token }}
|
|
RUNNER_ARCH: ${{ runner.arch }}
|
|
RUNNER_TEMP: ${{ runner.temp }}
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
case "$RUNNER_ARCH" in
|
|
X64)
|
|
arch="amd64"
|
|
;;
|
|
ARM64)
|
|
arch="arm64"
|
|
;;
|
|
*)
|
|
echo "Unsupported runner architecture: $RUNNER_ARCH" >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
if [[ "$ACTION_REF" == v* ]]; then
|
|
release_tag="$ACTION_REF"
|
|
normalized_version="${release_tag#v}"
|
|
asset_name="vociferate_${normalized_version}_linux_${arch}"
|
|
cache_dir="${RUNNER_TEMP}/vociferate/${release_tag}/linux-${arch}"
|
|
binary_path="${cache_dir}/vociferate"
|
|
asset_url="${SERVER_URL}/aether/vociferate/releases/download/${release_tag}/${asset_name}"
|
|
|
|
provided_cache_token="$(printf '%s' "${CACHE_TOKEN_INPUT:-}" | sed 's/^[[:space:]]\+//; s/[[:space:]]\+$//')"
|
|
if [[ -n "$provided_cache_token" ]]; then
|
|
cache_token="$provided_cache_token"
|
|
else
|
|
cache_token="${ACTION_REPOSITORY:-aether/vociferate}-${release_tag}"
|
|
fi
|
|
|
|
mkdir -p "$cache_dir"
|
|
|
|
echo "use_binary=true" >> "$GITHUB_OUTPUT"
|
|
echo "release_tag=$release_tag" >> "$GITHUB_OUTPUT"
|
|
echo "cache_token=$cache_token" >> "$GITHUB_OUTPUT"
|
|
echo "asset_name=$asset_name" >> "$GITHUB_OUTPUT"
|
|
echo "asset_url=$asset_url" >> "$GITHUB_OUTPUT"
|
|
echo "cache_dir=$cache_dir" >> "$GITHUB_OUTPUT"
|
|
echo "binary_path=$binary_path" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "use_binary=false" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
- name: Setup Go
|
|
if: steps.resolve-binary.outputs.use_binary != 'true'
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: '1.26.1'
|
|
cache: true
|
|
cache-dependency-path: ${{ github.action_path }}/go.sum
|
|
|
|
- name: Restore cached vociferate binary
|
|
id: cache-vociferate
|
|
if: steps.resolve-binary.outputs.use_binary == 'true'
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ${{ steps.resolve-binary.outputs.cache_dir }}
|
|
key: vociferate-${{ steps.resolve-binary.outputs.cache_token }}-linux-${{ runner.arch }}
|
|
|
|
- name: Download vociferate binary
|
|
if: steps.resolve-binary.outputs.use_binary == 'true' && steps.cache-vociferate.outputs.cache-hit != 'true'
|
|
shell: bash
|
|
env:
|
|
TOKEN: ${{ inputs.token != '' && inputs.token || github.token }}
|
|
ASSET_URL: ${{ steps.resolve-binary.outputs.asset_url }}
|
|
BINARY_PATH: ${{ steps.resolve-binary.outputs.binary_path }}
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
curl --fail --location \
|
|
-H "Authorization: token ${TOKEN}" \
|
|
-o "$BINARY_PATH" \
|
|
"$ASSET_URL"
|
|
chmod +x "$BINARY_PATH"
|
|
|
|
- name: Run vociferate
|
|
id: run-vociferate
|
|
shell: bash
|
|
env:
|
|
VOCIFERATE_BIN: ${{ steps.resolve-binary.outputs.binary_path }}
|
|
USE_BINARY: ${{ steps.resolve-binary.outputs.use_binary }}
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
if [[ "$USE_BINARY" == "true" ]]; then
|
|
run_vociferate() { "$VOCIFERATE_BIN" "$@"; }
|
|
else
|
|
run_vociferate() { (cd "$GITHUB_ACTION_PATH" && go run ./cmd/vociferate "$@"); }
|
|
fi
|
|
|
|
common_args=(--root "$GITHUB_WORKSPACE")
|
|
|
|
if [[ -n "${{ inputs.version-file }}" ]]; then
|
|
common_args+=(--version-file "${{ inputs.version-file }}")
|
|
fi
|
|
|
|
if [[ -n "${{ inputs.version-pattern }}" ]]; then
|
|
common_args+=(--version-pattern "${{ inputs.version-pattern }}")
|
|
fi
|
|
|
|
if [[ -n "${{ inputs.changelog }}" ]]; then
|
|
common_args+=(--changelog "${{ inputs.changelog }}")
|
|
fi
|
|
|
|
if [[ "${{ inputs.recommend }}" == "true" ]]; then
|
|
resolved_version="$(run_vociferate "${common_args[@]}" --recommend)"
|
|
echo "$resolved_version"
|
|
echo "version=$resolved_version" >> "$GITHUB_OUTPUT"
|
|
exit 0
|
|
else
|
|
resolved_version="$(printf '%s' "${{ inputs.version }}" | sed 's/^[[:space:]]\+//; s/[[:space:]]\+$//')"
|
|
if [[ -z "$resolved_version" ]]; then
|
|
resolved_version="$(run_vociferate "${common_args[@]}" --recommend)"
|
|
fi
|
|
fi
|
|
|
|
echo "version=$resolved_version" >> "$GITHUB_OUTPUT"
|
|
run_vociferate "${common_args[@]}" --version "$resolved_version" --date "$(date -u +%F)"
|