name: vociferate description: Prepare release files or recommend a next semantic version tag. inputs: version: description: Optional semantic version override. When omitted, the recommended version is used. required: false version-file: description: Path to version file relative to repository root. When omitted, the current version is derived from the most recent released section in the changelog. required: false default: '' version-pattern: description: Regular expression with one capture group for current version. Only required when version-file is set. required: false default: '' changelog: description: Path to changelog file relative to repository root. required: false default: CHANGELOG.md recommend: description: If true, print recommended next release tag. required: false default: 'false' outputs: version: description: Resolved version used for prepare mode, or the emitted recommended version for recommend mode. value: ${{ steps.finalize-version.outputs.version }} runs: using: composite steps: - uses: actions/checkout@v4 - 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 env: INPUT_VERSION: ${{ inputs.version }} run: | set -euo pipefail 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: 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 }} 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 fi if [[ "${{ inputs.recommend }}" == 'true' ]]; then echo "$resolved_version" fi 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)"