refactor(actions): simplify run-vociferate runtime flow
This commit is contained in:
@@ -1,31 +0,0 @@
|
|||||||
name: vociferate/download-vociferate-binary
|
|
||||||
description: Download a released vociferate binary to a target path.
|
|
||||||
|
|
||||||
inputs:
|
|
||||||
token:
|
|
||||||
description: Token used to authenticate the download request.
|
|
||||||
required: true
|
|
||||||
asset-url:
|
|
||||||
description: URL of the release asset to download.
|
|
||||||
required: true
|
|
||||||
binary-path:
|
|
||||||
description: Destination path for the downloaded binary.
|
|
||||||
required: true
|
|
||||||
|
|
||||||
runs:
|
|
||||||
using: composite
|
|
||||||
steps:
|
|
||||||
- name: Download binary
|
|
||||||
shell: bash
|
|
||||||
env:
|
|
||||||
TOKEN: ${{ inputs.token }}
|
|
||||||
ASSET_URL: ${{ inputs.asset-url }}
|
|
||||||
BINARY_PATH: ${{ inputs.binary-path }}
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
curl --fail --location \
|
|
||||||
-H "Authorization: token ${TOKEN}" \
|
|
||||||
-o "$BINARY_PATH" \
|
|
||||||
"$ASSET_URL"
|
|
||||||
chmod +x "$BINARY_PATH"
|
|
||||||
@@ -1,91 +0,0 @@
|
|||||||
name: vociferate/resolve-vociferate-runtime
|
|
||||||
description: Resolve whether vociferate should run from a released binary or source checkout.
|
|
||||||
|
|
||||||
outputs:
|
|
||||||
use_binary:
|
|
||||||
description: Whether a released binary should be used.
|
|
||||||
value: ${{ steps.resolve.outputs.use_binary }}
|
|
||||||
source_root:
|
|
||||||
description: Action repository root that contains go.mod.
|
|
||||||
value: ${{ steps.resolve.outputs.source_root }}
|
|
||||||
release_tag:
|
|
||||||
description: Action release tag when using a binary.
|
|
||||||
value: ${{ steps.resolve.outputs.release_tag }}
|
|
||||||
cache_token:
|
|
||||||
description: Cache token used for the binary cache key.
|
|
||||||
value: ${{ steps.resolve.outputs.cache_token }}
|
|
||||||
asset_name:
|
|
||||||
description: Binary asset name for the resolved platform.
|
|
||||||
value: ${{ steps.resolve.outputs.asset_name }}
|
|
||||||
asset_url:
|
|
||||||
description: Download URL for the resolved binary asset.
|
|
||||||
value: ${{ steps.resolve.outputs.asset_url }}
|
|
||||||
cache_dir:
|
|
||||||
description: Cache directory for the binary.
|
|
||||||
value: ${{ steps.resolve.outputs.cache_dir }}
|
|
||||||
binary_path:
|
|
||||||
description: Expected path to the downloaded binary.
|
|
||||||
value: ${{ steps.resolve.outputs.binary_path }}
|
|
||||||
|
|
||||||
runs:
|
|
||||||
using: composite
|
|
||||||
steps:
|
|
||||||
- name: Resolve runtime
|
|
||||||
id: resolve
|
|
||||||
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
|
|
||||||
|
|
||||||
case "$RUNNER_ARCH" in
|
|
||||||
X64)
|
|
||||||
arch="amd64"
|
|
||||||
;;
|
|
||||||
ARM64)
|
|
||||||
arch="arm64"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Unsupported runner architecture: $RUNNER_ARCH" >&2
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
source_root="$GITHUB_ACTION_PATH"
|
|
||||||
if [[ ! -f "$source_root/go.mod" ]]; then
|
|
||||||
source_root="$(realpath "$GITHUB_ACTION_PATH/..")"
|
|
||||||
fi
|
|
||||||
printf 'source_root=%s\n' "$source_root" >> "$GITHUB_OUTPUT"
|
|
||||||
|
|
||||||
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:-}" | 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 'use_binary=true\n' >> "$GITHUB_OUTPUT"
|
|
||||||
printf 'release_tag=%s\n' "$release_tag" >> "$GITHUB_OUTPUT"
|
|
||||||
printf 'cache_token=%s\n' "$cache_token" >> "$GITHUB_OUTPUT"
|
|
||||||
printf 'asset_name=%s\n' "$asset_name" >> "$GITHUB_OUTPUT"
|
|
||||||
printf 'asset_url=%s\n' "$asset_url" >> "$GITHUB_OUTPUT"
|
|
||||||
printf 'cache_dir=%s\n' "$cache_dir" >> "$GITHUB_OUTPUT"
|
|
||||||
printf 'binary_path=%s\n' "$binary_path" >> "$GITHUB_OUTPUT"
|
|
||||||
else
|
|
||||||
printf 'use_binary=false\n' >> "$GITHUB_OUTPUT"
|
|
||||||
fi
|
|
||||||
@@ -2,9 +2,6 @@ name: vociferate/run-vociferate-binary
|
|||||||
description: Execute vociferate through a released binary.
|
description: Execute vociferate through a released binary.
|
||||||
|
|
||||||
inputs:
|
inputs:
|
||||||
binary-path:
|
|
||||||
description: Path to the vociferate binary.
|
|
||||||
required: true
|
|
||||||
root:
|
root:
|
||||||
description: Repository root to pass to vociferate.
|
description: Repository root to pass to vociferate.
|
||||||
required: true
|
required: true
|
||||||
@@ -49,11 +46,86 @@ outputs:
|
|||||||
runs:
|
runs:
|
||||||
using: composite
|
using: composite
|
||||||
steps:
|
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
|
- name: Run binary
|
||||||
id: run
|
id: run
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
VOCIFERATE_BIN: ${{ inputs.binary-path }}
|
VOCIFERATE_BIN: ${{ steps.resolve-binary.outputs.binary_path }}
|
||||||
ROOT: ${{ inputs.root }}
|
ROOT: ${{ inputs.root }}
|
||||||
VERSION_FILE: ${{ inputs.version-file }}
|
VERSION_FILE: ${{ inputs.version-file }}
|
||||||
VERSION_PATTERN: ${{ inputs.version-pattern }}
|
VERSION_PATTERN: ${{ inputs.version-pattern }}
|
||||||
|
|||||||
@@ -2,9 +2,6 @@ name: vociferate/run-vociferate-code
|
|||||||
description: Execute vociferate from the checked-out Go source.
|
description: Execute vociferate from the checked-out Go source.
|
||||||
|
|
||||||
inputs:
|
inputs:
|
||||||
source-root:
|
|
||||||
description: Action repository root containing the Go module.
|
|
||||||
required: true
|
|
||||||
root:
|
root:
|
||||||
description: Repository root to pass to vociferate.
|
description: Repository root to pass to vociferate.
|
||||||
required: true
|
required: true
|
||||||
@@ -49,10 +46,30 @@ outputs:
|
|||||||
runs:
|
runs:
|
||||||
using: composite
|
using: composite
|
||||||
steps:
|
steps:
|
||||||
|
- name: Resolve source root
|
||||||
|
id: resolve-source
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
source_root="$GITHUB_ACTION_PATH"
|
||||||
|
if [[ ! -f "$source_root/go.mod" ]]; then
|
||||||
|
source_root="$(realpath "$GITHUB_ACTION_PATH/..")"
|
||||||
|
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
|
- name: Run source
|
||||||
id: run
|
id: run
|
||||||
shell: bash
|
shell: bash
|
||||||
working-directory: ${{ inputs.source-root }}
|
working-directory: ${{ steps.resolve-source.outputs.source_root }}
|
||||||
env:
|
env:
|
||||||
ROOT: ${{ inputs.root }}
|
ROOT: ${{ inputs.root }}
|
||||||
VERSION_FILE: ${{ inputs.version-file }}
|
VERSION_FILE: ${{ inputs.version-file }}
|
||||||
|
|||||||
@@ -51,38 +51,23 @@ runs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Resolve runtime
|
- name: Resolve runtime
|
||||||
id: resolve-runtime
|
id: resolve-runtime
|
||||||
uses: ../resolve-vociferate-runtime
|
shell: bash
|
||||||
|
env:
|
||||||
|
ACTION_REF: ${{ github.action_ref }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
- name: Setup Go
|
if [[ "$ACTION_REF" == v* ]]; then
|
||||||
if: steps.resolve-runtime.outputs.use_binary != 'true'
|
printf 'use_binary=true\n' >> "$GITHUB_OUTPUT"
|
||||||
uses: actions/setup-go@v5
|
else
|
||||||
with:
|
printf 'use_binary=false\n' >> "$GITHUB_OUTPUT"
|
||||||
go-version: '1.26.1'
|
fi
|
||||||
cache: true
|
|
||||||
cache-dependency-path: ${{ steps.resolve-runtime.outputs.source_root }}/go.sum
|
|
||||||
|
|
||||||
- name: Restore cached binary
|
|
||||||
id: cache-vociferate
|
|
||||||
if: steps.resolve-runtime.outputs.use_binary == 'true'
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
path: ${{ steps.resolve-runtime.outputs.cache_dir }}
|
|
||||||
key: vociferate-${{ steps.resolve-runtime.outputs.cache_token }}-linux-${{ runner.arch }}
|
|
||||||
|
|
||||||
- name: Download binary
|
|
||||||
if: steps.resolve-runtime.outputs.use_binary == 'true' && steps.cache-vociferate.outputs.cache-hit != 'true'
|
|
||||||
uses: ../download-vociferate-binary
|
|
||||||
with:
|
|
||||||
token: ${{ github.token }}
|
|
||||||
asset-url: ${{ steps.resolve-runtime.outputs.asset_url }}
|
|
||||||
binary-path: ${{ steps.resolve-runtime.outputs.binary_path }}
|
|
||||||
|
|
||||||
- name: Run binary
|
- name: Run binary
|
||||||
id: run-binary
|
id: run-binary
|
||||||
if: steps.resolve-runtime.outputs.use_binary == 'true'
|
if: steps.resolve-runtime.outputs.use_binary == 'true'
|
||||||
uses: ../run-vociferate.binary
|
uses: ../run-vociferate.binary
|
||||||
with:
|
with:
|
||||||
binary-path: ${{ steps.resolve-runtime.outputs.binary_path }}
|
|
||||||
root: ${{ inputs.root }}
|
root: ${{ inputs.root }}
|
||||||
version-file: ${{ inputs.version-file }}
|
version-file: ${{ inputs.version-file }}
|
||||||
version-pattern: ${{ inputs.version-pattern }}
|
version-pattern: ${{ inputs.version-pattern }}
|
||||||
@@ -98,7 +83,6 @@ runs:
|
|||||||
if: steps.resolve-runtime.outputs.use_binary != 'true'
|
if: steps.resolve-runtime.outputs.use_binary != 'true'
|
||||||
uses: ../run-vociferate.code
|
uses: ../run-vociferate.code
|
||||||
with:
|
with:
|
||||||
source-root: ${{ steps.resolve-runtime.outputs.source_root }}
|
|
||||||
root: ${{ inputs.root }}
|
root: ${{ inputs.root }}
|
||||||
version-file: ${{ inputs.version-file }}
|
version-file: ${{ inputs.version-file }}
|
||||||
version-pattern: ${{ inputs.version-pattern }}
|
version-pattern: ${{ inputs.version-pattern }}
|
||||||
|
|||||||
Reference in New Issue
Block a user