From 0d4310184e80dd99993795009d11555ceb053f8a Mon Sep 17 00:00:00 2001 From: Micheal Wilkinson Date: Sat, 21 Mar 2026 15:31:49 +0000 Subject: [PATCH] refactor(actions): inline run-vociferate binary and source flows --- run-vociferate/action.yml | 207 +++++++++++++++++++++++++++---- run-vociferate/binary/action.yml | 176 -------------------------- run-vociferate/code/action.yml | 125 ------------------- 3 files changed, 185 insertions(+), 323 deletions(-) delete mode 100644 run-vociferate/binary/action.yml delete mode 100644 run-vociferate/code/action.yml diff --git a/run-vociferate/action.yml b/run-vociferate/action.yml index 9c3c08d..d840f63 100644 --- a/run-vociferate/action.yml +++ b/run-vociferate/action.yml @@ -63,35 +63,198 @@ runs: printf 'use_binary=false\n' >> "$GITHUB_OUTPUT" fi + - name: Resolve binary metadata + id: resolve-binary + if: steps.resolve-runtime.outputs.use_binary == 'true' + shell: bash + env: + ACTION_REF: ${{ github.action_ref }} + ACTION_REPOSITORY: ${{ github.action_repository }} + CACHE_TOKEN: ${{ env.VOCIFERATE_CACHE_TOKEN }} + SERVER_URL: ${{ github.server_url }} + RUNNER_ARCH: ${{ runner.arch }} + RUNNER_TEMP: ${{ runner.temp }} + run: | + set -euo pipefail + + if [[ "$ACTION_REF" != v* ]]; then + echo "run-vociferate binary path requires github.action_ref to be a release tag" >&2 + exit 1 + fi + + case "$RUNNER_ARCH" in + X64) + arch="amd64" + ;; + ARM64) + arch="arm64" + ;; + *) + echo "Unsupported runner architecture: $RUNNER_ARCH" >&2 + exit 1 + ;; + esac + + 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:-}" | 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" + + printf 'cache_token=%s\n' "$cache_token" >> "$GITHUB_OUTPUT" + printf 'cache_dir=%s\n' "$cache_dir" >> "$GITHUB_OUTPUT" + printf 'binary_path=%s\n' "$binary_path" >> "$GITHUB_OUTPUT" + printf 'asset_url=%s\n' "$asset_url" >> "$GITHUB_OUTPUT" + + - name: Restore cached binary + id: cache-vociferate + if: steps.resolve-runtime.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 binary + if: steps.resolve-runtime.outputs.use_binary == 'true' && steps.cache-vociferate.outputs.cache-hit != 'true' + shell: bash + env: + 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 binary id: run-binary if: steps.resolve-runtime.outputs.use_binary == 'true' - uses: ./run-vociferate/binary - with: - root: ${{ inputs.root }} - version-file: ${{ inputs.version-file }} - version-pattern: ${{ inputs.version-pattern }} - changelog: ${{ inputs.changelog }} - version: ${{ inputs.version }} - date: ${{ inputs.date }} - recommend: ${{ inputs.recommend }} - print-unreleased: ${{ inputs.print-unreleased }} - print-release-notes: ${{ inputs.print-release-notes }} + shell: bash + env: + VOCIFERATE_BIN: ${{ steps.resolve-binary.outputs.binary_path }} + ROOT: ${{ inputs.root }} + VERSION_FILE: ${{ inputs.version-file }} + VERSION_PATTERN: ${{ inputs.version-pattern }} + CHANGELOG: ${{ inputs.changelog }} + VERSION: ${{ inputs.version }} + DATE: ${{ inputs.date }} + RECOMMEND: ${{ inputs.recommend }} + PRINT_UNRELEASED: ${{ inputs.print-unreleased }} + PRINT_RELEASE_NOTES: ${{ inputs.print-release-notes }} + VOCIFERATE_REPOSITORY_URL: ${{ vars.VOCIFERATE_REPOSITORY_URL }} + run: | + set -euo pipefail + + command=("$VOCIFERATE_BIN" --root "$ROOT") + if [[ -n "$VERSION_FILE" ]]; then + command+=(--version-file "$VERSION_FILE") + fi + if [[ -n "$VERSION_PATTERN" ]]; then + command+=(--version-pattern "$VERSION_PATTERN") + fi + if [[ -n "$CHANGELOG" ]]; then + command+=(--changelog "$CHANGELOG") + fi + if [[ -n "$VERSION" ]]; then + command+=(--version "$VERSION") + fi + if [[ -n "$DATE" ]]; then + command+=(--date "$DATE") + fi + if [[ "$RECOMMEND" == 'true' ]]; then + command+=(--recommend) + fi + if [[ "$PRINT_UNRELEASED" == 'true' ]]; then + command+=(--print-unreleased) + fi + if [[ "$PRINT_RELEASE_NOTES" == 'true' ]]; then + command+=(--print-release-notes) + fi + + stdout_file="$(mktemp)" + trap 'rm -f "$stdout_file"' EXIT + "${command[@]}" > "$stdout_file" + + delimiter="EOF_STDOUT" + printf 'stdout<<%s\n' "$delimiter" >> "$GITHUB_OUTPUT" + cat "$stdout_file" >> "$GITHUB_OUTPUT" + printf '%s\n' "$delimiter" >> "$GITHUB_OUTPUT" - name: Run source id: run-code if: steps.resolve-runtime.outputs.use_binary != 'true' - uses: ./run-vociferate/code - with: - root: ${{ inputs.root }} - version-file: ${{ inputs.version-file }} - version-pattern: ${{ inputs.version-pattern }} - changelog: ${{ inputs.changelog }} - version: ${{ inputs.version }} - date: ${{ inputs.date }} - recommend: ${{ inputs.recommend }} - print-unreleased: ${{ inputs.print-unreleased }} - print-release-notes: ${{ inputs.print-release-notes }} + shell: bash + env: + ROOT: ${{ inputs.root }} + VERSION_FILE: ${{ inputs.version-file }} + VERSION_PATTERN: ${{ inputs.version-pattern }} + CHANGELOG: ${{ inputs.changelog }} + VERSION: ${{ inputs.version }} + DATE: ${{ inputs.date }} + RECOMMEND: ${{ inputs.recommend }} + PRINT_UNRELEASED: ${{ inputs.print-unreleased }} + PRINT_RELEASE_NOTES: ${{ inputs.print-release-notes }} + VOCIFERATE_REPOSITORY_URL: ${{ vars.VOCIFERATE_REPOSITORY_URL }} + run: | + set -euo pipefail + + source_root="$GITHUB_ACTION_PATH" + while [[ ! -f "$source_root/go.mod" ]] && [[ "$source_root" != "/" ]]; do + source_root="$(realpath "$source_root/..")" + done + if [[ ! -f "$source_root/go.mod" ]]; then + echo "Could not locate Go module root from $GITHUB_ACTION_PATH" >&2 + exit 1 + fi + + command=(go run ./cmd/vociferate --root "$ROOT") + if [[ -n "$VERSION_FILE" ]]; then + command+=(--version-file "$VERSION_FILE") + fi + if [[ -n "$VERSION_PATTERN" ]]; then + command+=(--version-pattern "$VERSION_PATTERN") + fi + if [[ -n "$CHANGELOG" ]]; then + command+=(--changelog "$CHANGELOG") + fi + if [[ -n "$VERSION" ]]; then + command+=(--version "$VERSION") + fi + if [[ -n "$DATE" ]]; then + command+=(--date "$DATE") + fi + if [[ "$RECOMMEND" == 'true' ]]; then + command+=(--recommend) + fi + if [[ "$PRINT_UNRELEASED" == 'true' ]]; then + command+=(--print-unreleased) + fi + if [[ "$PRINT_RELEASE_NOTES" == 'true' ]]; then + command+=(--print-release-notes) + fi + + stdout_file="$(mktemp)" + trap 'rm -f "$stdout_file"' EXIT + (cd "$source_root" && "${command[@]}") > "$stdout_file" + + delimiter="EOF_STDOUT" + printf 'stdout<<%s\n' "$delimiter" >> "$GITHUB_OUTPUT" + cat "$stdout_file" >> "$GITHUB_OUTPUT" + printf '%s\n' "$delimiter" >> "$GITHUB_OUTPUT" - name: Finalize stdout id: finalize diff --git a/run-vociferate/binary/action.yml b/run-vociferate/binary/action.yml deleted file mode 100644 index 9b310d2..0000000 --- a/run-vociferate/binary/action.yml +++ /dev/null @@ -1,176 +0,0 @@ -name: vociferate/run-vociferate-binary -description: Execute vociferate through a released binary. - -inputs: - root: - description: Repository root to pass to vociferate. - required: true - version-file: - description: Optional version file path. - required: false - default: '' - version-pattern: - description: Optional version pattern. - required: false - default: '' - changelog: - description: Optional changelog path. - required: false - default: '' - version: - description: Optional version argument. - required: false - default: '' - date: - description: Optional date argument. - required: false - default: '' - recommend: - description: Whether to run vociferate with --recommend. - required: false - default: 'false' - print-unreleased: - description: Whether to print the Unreleased body. - required: false - default: 'false' - print-release-notes: - description: Whether to print the release notes section for version. - required: false - default: 'false' - -outputs: - stdout: - description: Captured stdout from the vociferate invocation. - value: ${{ steps.run.outputs.stdout }} - -runs: - using: composite - steps: - - name: Resolve binary metadata - id: resolve-binary - shell: bash - env: - ACTION_REF: ${{ github.action_ref }} - ACTION_REPOSITORY: ${{ github.action_repository }} - CACHE_TOKEN: ${{ env.VOCIFERATE_CACHE_TOKEN }} - SERVER_URL: ${{ github.server_url }} - RUNNER_ARCH: ${{ runner.arch }} - RUNNER_TEMP: ${{ runner.temp }} - run: | - set -euo pipefail - - if [[ "$ACTION_REF" != v* ]]; then - echo "run-vociferate.binary requires github.action_ref to be a release tag" >&2 - exit 1 - fi - - case "$RUNNER_ARCH" in - X64) - arch="amd64" - ;; - ARM64) - arch="arm64" - ;; - *) - echo "Unsupported runner architecture: $RUNNER_ARCH" >&2 - exit 1 - ;; - esac - - 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:-}" | 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" - - printf 'cache_token=%s\n' "$cache_token" >> "$GITHUB_OUTPUT" - printf 'cache_dir=%s\n' "$cache_dir" >> "$GITHUB_OUTPUT" - printf 'binary_path=%s\n' "$binary_path" >> "$GITHUB_OUTPUT" - printf 'asset_url=%s\n' "$asset_url" >> "$GITHUB_OUTPUT" - - - name: Restore cached binary - id: cache-vociferate - 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 binary - if: steps.cache-vociferate.outputs.cache-hit != 'true' - shell: bash - env: - 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 binary - id: run - shell: bash - env: - VOCIFERATE_BIN: ${{ steps.resolve-binary.outputs.binary_path }} - ROOT: ${{ inputs.root }} - VERSION_FILE: ${{ inputs.version-file }} - VERSION_PATTERN: ${{ inputs.version-pattern }} - CHANGELOG: ${{ inputs.changelog }} - VERSION: ${{ inputs.version }} - DATE: ${{ inputs.date }} - RECOMMEND: ${{ inputs.recommend }} - PRINT_UNRELEASED: ${{ inputs.print-unreleased }} - PRINT_RELEASE_NOTES: ${{ inputs.print-release-notes }} - VOCIFERATE_REPOSITORY_URL: ${{ vars.VOCIFERATE_REPOSITORY_URL }} - run: | - set -euo pipefail - - command=("$VOCIFERATE_BIN" --root "$ROOT") - - if [[ -n "$VERSION_FILE" ]]; then - command+=(--version-file "$VERSION_FILE") - fi - if [[ -n "$VERSION_PATTERN" ]]; then - command+=(--version-pattern "$VERSION_PATTERN") - fi - if [[ -n "$CHANGELOG" ]]; then - command+=(--changelog "$CHANGELOG") - fi - if [[ -n "$VERSION" ]]; then - command+=(--version "$VERSION") - fi - if [[ -n "$DATE" ]]; then - command+=(--date "$DATE") - fi - if [[ "$RECOMMEND" == 'true' ]]; then - command+=(--recommend) - fi - if [[ "$PRINT_UNRELEASED" == 'true' ]]; then - command+=(--print-unreleased) - fi - if [[ "$PRINT_RELEASE_NOTES" == 'true' ]]; then - command+=(--print-release-notes) - fi - - stdout_file="$(mktemp)" - trap 'rm -f "$stdout_file"' EXIT - "${command[@]}" > "$stdout_file" - - delimiter="EOF_STDOUT" - printf 'stdout<<%s\n' "$delimiter" >> "$GITHUB_OUTPUT" - cat "$stdout_file" >> "$GITHUB_OUTPUT" - printf '%s\n' "$delimiter" >> "$GITHUB_OUTPUT" \ No newline at end of file diff --git a/run-vociferate/code/action.yml b/run-vociferate/code/action.yml deleted file mode 100644 index a7e8b82..0000000 --- a/run-vociferate/code/action.yml +++ /dev/null @@ -1,125 +0,0 @@ -name: vociferate/run-vociferate-code -description: Execute vociferate from the checked-out Go source. - -inputs: - root: - description: Repository root to pass to vociferate. - required: true - version-file: - description: Optional version file path. - required: false - default: '' - version-pattern: - description: Optional version pattern. - required: false - default: '' - changelog: - description: Optional changelog path. - required: false - default: '' - version: - description: Optional version argument. - required: false - default: '' - date: - description: Optional date argument. - required: false - default: '' - recommend: - description: Whether to run vociferate with --recommend. - required: false - default: 'false' - print-unreleased: - description: Whether to print the Unreleased body. - required: false - default: 'false' - print-release-notes: - description: Whether to print the release notes section for version. - required: false - default: 'false' - -outputs: - stdout: - description: Captured stdout from the vociferate invocation. - value: ${{ steps.run.outputs.stdout }} - -runs: - using: composite - steps: - - name: Resolve source root - id: resolve-source - shell: bash - run: | - set -euo pipefail - - source_root="$GITHUB_ACTION_PATH" - while [[ ! -f "$source_root/go.mod" ]] && [[ "$source_root" != "/" ]]; do - source_root="$(realpath "$source_root/..")" - done - if [[ ! -f "$source_root/go.mod" ]]; then - echo "Could not locate Go module root from $GITHUB_ACTION_PATH" >&2 - exit 1 - fi - - printf 'source_root=%s\n' "$source_root" >> "$GITHUB_OUTPUT" - - - name: Setup Go - uses: actions/setup-go@v5 - with: - go-version: '1.26.1' - cache: true - cache-dependency-path: ${{ steps.resolve-source.outputs.source_root }}/go.sum - - - name: Run source - id: run - shell: bash - working-directory: ${{ steps.resolve-source.outputs.source_root }} - env: - ROOT: ${{ inputs.root }} - VERSION_FILE: ${{ inputs.version-file }} - VERSION_PATTERN: ${{ inputs.version-pattern }} - CHANGELOG: ${{ inputs.changelog }} - VERSION: ${{ inputs.version }} - DATE: ${{ inputs.date }} - RECOMMEND: ${{ inputs.recommend }} - PRINT_UNRELEASED: ${{ inputs.print-unreleased }} - PRINT_RELEASE_NOTES: ${{ inputs.print-release-notes }} - VOCIFERATE_REPOSITORY_URL: ${{ vars.VOCIFERATE_REPOSITORY_URL }} - run: | - set -euo pipefail - - command=(go run ./cmd/vociferate --root "$ROOT") - - if [[ -n "$VERSION_FILE" ]]; then - command+=(--version-file "$VERSION_FILE") - fi - if [[ -n "$VERSION_PATTERN" ]]; then - command+=(--version-pattern "$VERSION_PATTERN") - fi - if [[ -n "$CHANGELOG" ]]; then - command+=(--changelog "$CHANGELOG") - fi - if [[ -n "$VERSION" ]]; then - command+=(--version "$VERSION") - fi - if [[ -n "$DATE" ]]; then - command+=(--date "$DATE") - fi - if [[ "$RECOMMEND" == 'true' ]]; then - command+=(--recommend) - fi - if [[ "$PRINT_UNRELEASED" == 'true' ]]; then - command+=(--print-unreleased) - fi - if [[ "$PRINT_RELEASE_NOTES" == 'true' ]]; then - command+=(--print-release-notes) - fi - - stdout_file="$(mktemp)" - trap 'rm -f "$stdout_file"' EXIT - "${command[@]}" > "$stdout_file" - - delimiter="EOF_STDOUT" - printf 'stdout<<%s\n' "$delimiter" >> "$GITHUB_OUTPUT" - cat "$stdout_file" >> "$GITHUB_OUTPUT" - printf '%s\n' "$delimiter" >> "$GITHUB_OUTPUT" \ No newline at end of file