Files
vociferate/action.yml
Micheal Wilkinson 4ae6f34931
All checks were successful
Push Validation / validate (push) Successful in 54s
docs: update action and README to reflect changelog-based versioning default
- action.yml: clarify that version-file triggers version-file-based
  resolution and that omitting it causes the version to be derived from
  the changelog; note version-pattern is only required when version-file
  is set.
- README: replace stale reference to the plain-text release-version file
  as the default with an accurate description of changelog-based
  versioning as the default, directing users to set version-file and
  version-pattern only for repos with source-embedded versioning.
2026-03-20 20:12:38 +00:00

151 lines
5.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'
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 }}
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
release_tag="$ACTION_REF"
if [[ -z "$release_tag" || "$release_tag" == refs/* || "$release_tag" != v* ]]; then
release_tag="$(curl -fsSL \
-H "Authorization: token ${TOKEN}" \
-H "Content-Type: application/json" \
"${API_URL}/repos/aether/vociferate/releases/latest" | sed -n 's/.*"tag_name"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' | head -n 1)"
fi
if [[ -z "$release_tag" ]]; then
echo "Unable to resolve a vociferate release tag for binary download" >&2
exit 1
fi
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}"
mkdir -p "$cache_dir"
echo "release_tag=$release_tag" >> "$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"
- name: Restore cached vociferate binary
id: cache-vociferate
uses: actions/cache@v4
with:
path: ${{ steps.resolve-binary.outputs.cache_dir }}
key: vociferate-${{ steps.resolve-binary.outputs.release_tag }}-linux-${{ runner.arch }}
- name: Download vociferate binary
if: 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 }}
run: |
set -euo pipefail
common_args=(--root .)
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="$("$VOCIFERATE_BIN" "${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="$("$VOCIFERATE_BIN" "${common_args[@]}" --recommend)"
fi
fi
echo "version=$resolved_version" >> "$GITHUB_OUTPUT"
"$VOCIFERATE_BIN" "${common_args[@]}" --version "$resolved_version" --date "$(date -u +%F)"