chore(go): compose vociferate runtime flow
This commit is contained in:
168
action.yml
168
action.yml
@@ -32,46 +32,13 @@ runs:
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Resolve vociferate binary metadata
|
||||
id: resolve-binary
|
||||
- name: Resolve release date
|
||||
id: resolve-date
|
||||
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"
|
||||
set -euo pipefail
|
||||
|
||||
- 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"
|
||||
printf 'value=%s\n' "$(date -u +%F)" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Normalize version input
|
||||
id: normalize-version
|
||||
@@ -84,74 +51,30 @@ runs:
|
||||
resolved_version="$(printf '%s' "${INPUT_VERSION:-}" | sed 's/^[[:space:]]\+//; s/[[:space:]]\+$//')"
|
||||
printf 'value=%s\n' "$resolved_version" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Recommend version from binary
|
||||
id: recommend-binary
|
||||
if: (inputs.recommend == 'true' || 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
|
||||
|
||||
resolved_version="$($VOCIFERATE_BIN "${common_args[@]}" --recommend)"
|
||||
printf 'version=%s\n' "$resolved_version" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Recommend version from source
|
||||
id: recommend-source
|
||||
if: (inputs.recommend == 'true' || 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
|
||||
|
||||
resolved_version="$(go run ./cmd/vociferate "${common_args[@]}" --recommend)"
|
||||
printf 'version=%s\n' "$resolved_version" >> "$GITHUB_OUTPUT"
|
||||
- name: Recommend version
|
||||
id: recommend-version
|
||||
if: inputs.recommend == 'true' || 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
|
||||
|
||||
if [[ -n "$PROVIDED_VERSION" ]] && [[ "${{ inputs.recommend }}" != 'true' ]]; then
|
||||
resolved_version="$PROVIDED_VERSION"
|
||||
else
|
||||
resolved_version="$RECOMMENDED_BINARY"
|
||||
if [[ -z "$resolved_version" ]]; then
|
||||
resolved_version="$RECOMMENDED_SOURCE"
|
||||
fi
|
||||
resolved_version="$RECOMMENDED_VERSION"
|
||||
fi
|
||||
|
||||
if [[ "${{ inputs.recommend }}" == 'true' ]]; then
|
||||
@@ -160,52 +83,13 @@ runs:
|
||||
|
||||
printf 'version=%s\n' "$resolved_version" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Prepare release files with binary
|
||||
if: inputs.recommend != 'true' && steps.resolve-binary.outputs.use_binary == 'true'
|
||||
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")
|
||||
|
||||
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: inputs.recommend != 'true' && 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
|
||||
if: inputs.recommend != 'true'
|
||||
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 }}
|
||||
|
||||
Reference in New Issue
Block a user