chore(go): compose vociferate runtime flow
This commit is contained in:
@@ -52,47 +52,6 @@ outputs:
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Resolve vociferate 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 }}
|
||||
API_URL: ${{ github.api_url }}
|
||||
TOKEN: ${{ github.token }}
|
||||
RUNNER_ARCH: ${{ runner.arch }}
|
||||
RUNNER_TEMP: ${{ runner.temp }}
|
||||
run: |
|
||||
bash "$GITHUB_ACTION_PATH/../script/resolve-vociferate-runtime.sh"
|
||||
|
||||
- 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: ${{ steps.resolve-binary.outputs.source_root }}/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: ${{ github.token }}
|
||||
ASSET_URL: ${{ steps.resolve-binary.outputs.asset_url }}
|
||||
BINARY_PATH: ${{ steps.resolve-binary.outputs.binary_path }}
|
||||
run: |
|
||||
bash "${{ steps.resolve-binary.outputs.source_root }}/script/download-vociferate-binary.sh"
|
||||
|
||||
- name: Normalize version input
|
||||
id: normalize-version
|
||||
shell: bash
|
||||
@@ -104,73 +63,29 @@ runs:
|
||||
provided_version="$(printf '%s' "${INPUT_VERSION:-}" | sed 's/^[[:space:]]\+//; s/[[:space:]]\+$//')"
|
||||
printf 'value=%s\n' "$provided_version" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Recommend version from binary
|
||||
id: recommend-binary
|
||||
if: steps.normalize-version.outputs.value == '' && steps.resolve-binary.outputs.use_binary == 'true'
|
||||
shell: bash
|
||||
env:
|
||||
VOCIFERATE_BIN: ${{ steps.resolve-binary.outputs.binary_path }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
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
|
||||
|
||||
provided_version="$($VOCIFERATE_BIN "${common_args[@]}" --recommend)"
|
||||
printf 'version=%s\n' "$provided_version" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Recommend version from source
|
||||
id: recommend-source
|
||||
if: steps.normalize-version.outputs.value == '' && steps.resolve-binary.outputs.use_binary != 'true'
|
||||
shell: bash
|
||||
working-directory: ${{ steps.resolve-binary.outputs.source_root }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
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
|
||||
|
||||
provided_version="$(go run ./cmd/vociferate "${common_args[@]}" --recommend)"
|
||||
printf 'version=%s\n' "$provided_version" >> "$GITHUB_OUTPUT"
|
||||
- name: Recommend version
|
||||
id: recommend-version
|
||||
if: steps.normalize-version.outputs.value == ''
|
||||
uses: ../run-vociferate
|
||||
with:
|
||||
root: ${{ github.workspace }}
|
||||
version-file: ${{ inputs.version-file }}
|
||||
version-pattern: ${{ inputs.version-pattern }}
|
||||
changelog: ${{ inputs.changelog }}
|
||||
recommend: 'true'
|
||||
|
||||
- name: Finalize version
|
||||
id: finalize-version
|
||||
shell: bash
|
||||
env:
|
||||
PROVIDED_VERSION: ${{ steps.normalize-version.outputs.value }}
|
||||
RECOMMENDED_BINARY: ${{ steps.recommend-binary.outputs.version }}
|
||||
RECOMMENDED_SOURCE: ${{ steps.recommend-source.outputs.version }}
|
||||
RECOMMENDED_VERSION: ${{ steps.recommend-version.outputs.stdout }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
provided_version="$PROVIDED_VERSION"
|
||||
if [[ -z "$provided_version" ]]; then
|
||||
provided_version="$RECOMMENDED_BINARY"
|
||||
fi
|
||||
if [[ -z "$provided_version" ]]; then
|
||||
provided_version="$RECOMMENDED_SOURCE"
|
||||
provided_version="$RECOMMENDED_VERSION"
|
||||
fi
|
||||
|
||||
normalized_version="${provided_version#v}"
|
||||
@@ -178,55 +93,23 @@ runs:
|
||||
|
||||
printf 'version=%s\n' "$tag" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Prepare release files with binary
|
||||
if: steps.resolve-binary.outputs.use_binary == 'true'
|
||||
- name: Resolve release date
|
||||
id: resolve-date
|
||||
shell: bash
|
||||
env:
|
||||
VOCIFERATE_BIN: ${{ steps.resolve-binary.outputs.binary_path }}
|
||||
VOCIFERATE_REPOSITORY_URL: ${{ vars.VOCIFERATE_REPOSITORY_URL }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
common_args=(--root "$GITHUB_WORKSPACE")
|
||||
printf 'value=%s\n' "$(date -u +%F)" >> "$GITHUB_OUTPUT"
|
||||
|
||||
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
|
||||
|
||||
"$VOCIFERATE_BIN" "${common_args[@]}" --version "${{ steps.finalize-version.outputs.version }}" --date "$(date -u +%F)"
|
||||
|
||||
- name: Prepare release files with source
|
||||
if: steps.resolve-binary.outputs.use_binary != 'true'
|
||||
shell: bash
|
||||
working-directory: ${{ steps.resolve-binary.outputs.source_root }}
|
||||
env:
|
||||
VOCIFERATE_REPOSITORY_URL: ${{ vars.VOCIFERATE_REPOSITORY_URL }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
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
|
||||
|
||||
go run ./cmd/vociferate "${common_args[@]}" --version "${{ steps.finalize-version.outputs.version }}" --date "$(date -u +%F)"
|
||||
- name: Prepare release files
|
||||
uses: ../run-vociferate
|
||||
with:
|
||||
root: ${{ github.workspace }}
|
||||
version-file: ${{ inputs.version-file }}
|
||||
version-pattern: ${{ inputs.version-pattern }}
|
||||
changelog: ${{ inputs.changelog }}
|
||||
version: ${{ steps.finalize-version.outputs.version }}
|
||||
date: ${{ steps.resolve-date.outputs.value }}
|
||||
|
||||
- name: Commit and push release
|
||||
shell: bash
|
||||
|
||||
Reference in New Issue
Block a user