chore(go): compose vociferate runtime flow
This commit is contained in:
91
resolve-vociferate-runtime/action.yml
Normal file
91
resolve-vociferate-runtime/action.yml
Normal file
@@ -0,0 +1,91 @@
|
||||
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
|
||||
Reference in New Issue
Block a user