Compare commits
2 Commits
55a067973e
...
dda898868f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dda898868f | ||
|
|
b793e1b289 |
43
action.yml
43
action.yml
@@ -62,19 +62,8 @@ runs:
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ "$ACTION_REF" == v* ]]; then
|
||||
release_tag="$ACTION_REF"
|
||||
if [[ -z "$release_tag" || "$release_tag" == refs/* || "$release_tag" != v* ]]; then
|
||||
release_tag="$(curl -fsSL \
|
||||
-H "Authorization: token ${TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
"${API_URL}/repos/aether/vociferate/releases/latest" | sed -n 's/.*"tag_name"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' | head -n 1)"
|
||||
fi
|
||||
|
||||
if [[ -z "$release_tag" ]]; then
|
||||
echo "Unable to resolve a vociferate release tag for binary download" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
normalized_version="${release_tag#v}"
|
||||
asset_name="vociferate_${normalized_version}_linux_${arch}"
|
||||
cache_dir="${RUNNER_TEMP}/vociferate/${release_tag}/linux-${arch}"
|
||||
@@ -83,21 +72,34 @@ runs:
|
||||
|
||||
mkdir -p "$cache_dir"
|
||||
|
||||
echo "use_binary=true" >> "$GITHUB_OUTPUT"
|
||||
echo "release_tag=$release_tag" >> "$GITHUB_OUTPUT"
|
||||
echo "asset_name=$asset_name" >> "$GITHUB_OUTPUT"
|
||||
echo "asset_url=$asset_url" >> "$GITHUB_OUTPUT"
|
||||
echo "cache_dir=$cache_dir" >> "$GITHUB_OUTPUT"
|
||||
echo "binary_path=$binary_path" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "use_binary=false" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
- 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: ${{ github.action_path }}/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.release_tag }}-linux-${{ runner.arch }}
|
||||
|
||||
- name: Download vociferate binary
|
||||
if: steps.cache-vociferate.outputs.cache-hit != 'true'
|
||||
if: steps.resolve-binary.outputs.use_binary == 'true' && steps.cache-vociferate.outputs.cache-hit != 'true'
|
||||
shell: bash
|
||||
env:
|
||||
TOKEN: ${{ inputs.token != '' && inputs.token || github.token }}
|
||||
@@ -117,10 +119,17 @@ runs:
|
||||
shell: bash
|
||||
env:
|
||||
VOCIFERATE_BIN: ${{ steps.resolve-binary.outputs.binary_path }}
|
||||
USE_BINARY: ${{ steps.resolve-binary.outputs.use_binary }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
common_args=(--root .)
|
||||
if [[ "$USE_BINARY" == "true" ]]; then
|
||||
run_vociferate() { "$VOCIFERATE_BIN" "$@"; }
|
||||
else
|
||||
run_vociferate() { (cd "$GITHUB_ACTION_PATH" && go run ./cmd/vociferate "$@"); }
|
||||
fi
|
||||
|
||||
common_args=(--root "$GITHUB_WORKSPACE")
|
||||
|
||||
if [[ -n "${{ inputs.version-file }}" ]]; then
|
||||
common_args+=(--version-file "${{ inputs.version-file }}")
|
||||
@@ -135,16 +144,16 @@ runs:
|
||||
fi
|
||||
|
||||
if [[ "${{ inputs.recommend }}" == "true" ]]; then
|
||||
resolved_version="$("$VOCIFERATE_BIN" "${common_args[@]}" --recommend)"
|
||||
resolved_version="$(run_vociferate "${common_args[@]}" --recommend)"
|
||||
echo "$resolved_version"
|
||||
echo "version=$resolved_version" >> "$GITHUB_OUTPUT"
|
||||
exit 0
|
||||
else
|
||||
resolved_version="$(printf '%s' "${{ inputs.version }}" | sed 's/^[[:space:]]\+//; s/[[:space:]]\+$//')"
|
||||
if [[ -z "$resolved_version" ]]; then
|
||||
resolved_version="$("$VOCIFERATE_BIN" "${common_args[@]}" --recommend)"
|
||||
resolved_version="$(run_vociferate "${common_args[@]}" --recommend)"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "version=$resolved_version" >> "$GITHUB_OUTPUT"
|
||||
"$VOCIFERATE_BIN" "${common_args[@]}" --version "$resolved_version" --date "$(date -u +%F)"
|
||||
run_vociferate "${common_args[@]}" --version "$resolved_version" --date "$(date -u +%F)"
|
||||
|
||||
@@ -17,6 +17,7 @@ A `### Breaking` section is used in addition to Keep a Changelog's standard sect
|
||||
- `publish/action.yml` outputs `release-id`, `tag`, and `version` so consumers can upload their own release assets after the release is created.
|
||||
- `prepare/action.yml` accepts a `git-add-files` input so repositories using a custom `version-file` can stage the correct set of files for the release commit.
|
||||
- The `prepare-release.yml` and `do-release.yml` vociferate workflows now use the local `./prepare` and `./publish` actions, validating the actions in the self-release pipeline.
|
||||
- `prepare/action.yml` and `action.yml` use `go run ./cmd/vociferate` directly from the action source (via `GITHUB_ACTION_PATH`) when invoked at `@main`, and download a prebuilt binary when invoked at a semver tag. This makes development and CI on `main` self-contained without requiring a published release.
|
||||
|
||||
- Release version recommendation now reads the current version from the most recent released section in the changelog instead of requiring a separate version file. When no prior releases exist the version defaults to `0.0.0`, yielding `v1.0.0` as the first recommended tag.
|
||||
- `vociferate prepare` creates the `release-version` file if it does not already exist, removing the need to pre-seed it in new repositories.
|
||||
|
||||
@@ -80,19 +80,8 @@ runs:
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ "$ACTION_REF" == v* ]]; then
|
||||
release_tag="$ACTION_REF"
|
||||
if [[ -z "$release_tag" || "$release_tag" == refs/* || "$release_tag" != v* ]]; then
|
||||
release_tag="$(curl -fsSL \
|
||||
-H "Authorization: token ${TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
"${API_URL}/repos/aether/vociferate/releases/latest" | sed -n 's/.*"tag_name"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' | head -n 1)"
|
||||
fi
|
||||
|
||||
if [[ -z "$release_tag" ]]; then
|
||||
echo "Unable to resolve a vociferate release tag for binary download" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
normalized_version="${release_tag#v}"
|
||||
asset_name="vociferate_${normalized_version}_linux_${arch}"
|
||||
cache_dir="${RUNNER_TEMP}/vociferate/${release_tag}/linux-${arch}"
|
||||
@@ -101,21 +90,34 @@ runs:
|
||||
|
||||
mkdir -p "$cache_dir"
|
||||
|
||||
echo "use_binary=true" >> "$GITHUB_OUTPUT"
|
||||
echo "release_tag=$release_tag" >> "$GITHUB_OUTPUT"
|
||||
echo "asset_name=$asset_name" >> "$GITHUB_OUTPUT"
|
||||
echo "asset_url=$asset_url" >> "$GITHUB_OUTPUT"
|
||||
echo "cache_dir=$cache_dir" >> "$GITHUB_OUTPUT"
|
||||
echo "binary_path=$binary_path" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "use_binary=false" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
- 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: ${{ github.action_path }}/../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.release_tag }}-linux-${{ runner.arch }}
|
||||
|
||||
- name: Download vociferate binary
|
||||
if: steps.cache-vociferate.outputs.cache-hit != 'true'
|
||||
if: steps.resolve-binary.outputs.use_binary == 'true' && steps.cache-vociferate.outputs.cache-hit != 'true'
|
||||
shell: bash
|
||||
env:
|
||||
TOKEN: ${{ inputs.token != '' && inputs.token || github.token }}
|
||||
@@ -135,11 +137,19 @@ runs:
|
||||
shell: bash
|
||||
env:
|
||||
VOCIFERATE_BIN: ${{ steps.resolve-binary.outputs.binary_path }}
|
||||
USE_BINARY: ${{ steps.resolve-binary.outputs.use_binary }}
|
||||
INPUT_VERSION: ${{ inputs.version }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
common_args=(--root .)
|
||||
if [[ "$USE_BINARY" == "true" ]]; then
|
||||
run_vociferate() { "$VOCIFERATE_BIN" "$@"; }
|
||||
else
|
||||
action_root="$(realpath "$GITHUB_ACTION_PATH/..")"
|
||||
run_vociferate() { (cd "$action_root" && go run ./cmd/vociferate "$@"); }
|
||||
fi
|
||||
|
||||
common_args=(--root "$GITHUB_WORKSPACE")
|
||||
|
||||
if [[ -n "${{ inputs.version-file }}" ]]; then
|
||||
common_args+=(--version-file "${{ inputs.version-file }}")
|
||||
@@ -155,13 +165,13 @@ runs:
|
||||
|
||||
provided_version="$(printf '%s' "${INPUT_VERSION:-}" | sed 's/^[[:space:]]\+//; s/[[:space:]]\+$//')"
|
||||
if [[ -z "$provided_version" ]]; then
|
||||
provided_version="$("$VOCIFERATE_BIN" "${common_args[@]}" --recommend)"
|
||||
provided_version="$(run_vociferate "${common_args[@]}" --recommend)"
|
||||
fi
|
||||
|
||||
normalized_version="${provided_version#v}"
|
||||
tag="v${normalized_version}"
|
||||
|
||||
"$VOCIFERATE_BIN" "${common_args[@]}" --version "$provided_version" --date "$(date -u +%F)"
|
||||
run_vociferate "${common_args[@]}" --version "$provided_version" --date "$(date -u +%F)"
|
||||
|
||||
echo "version=$tag" >> "$GITHUB_OUTPUT"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user