Compare commits
5 Commits
7a5b371539
...
2646d42523
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2646d42523 | ||
|
|
a413385c4e | ||
|
|
5cb0010531 | ||
|
|
fd7660721a | ||
|
|
8fefbf1997 |
102
.gitea/workflows/action-validation.yml
Normal file
102
.gitea/workflows/action-validation.yml
Normal file
@@ -0,0 +1,102 @@
|
||||
name: Action Validation
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- "**"
|
||||
tags-ignore:
|
||||
- "*"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
validate-released-binary:
|
||||
runs-on: ubuntu-latest
|
||||
container: docker.io/catthehacker/ubuntu:act-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- runner_arch: X64
|
||||
asset_arch: amd64
|
||||
run_command: ./vociferate
|
||||
- runner_arch: ARM64
|
||||
asset_arch: arm64
|
||||
run_command: qemu-aarch64-static ./vociferate
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install arm64 emulator
|
||||
if: ${{ matrix.runner_arch == 'ARM64' }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
apt-get update
|
||||
apt-get install -y qemu-user-static
|
||||
|
||||
- name: Resolve latest released binary
|
||||
id: resolve-binary
|
||||
env:
|
||||
API_URL: ${{ github.api_url }}
|
||||
SERVER_URL: ${{ github.server_url }}
|
||||
TOKEN: ${{ github.token }}
|
||||
ASSET_ARCH: ${{ matrix.asset_arch }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
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)"
|
||||
|
||||
if [[ -z "$release_tag" ]]; then
|
||||
echo "Unable to resolve latest vociferate release" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
normalized_version="${release_tag#v}"
|
||||
asset_name="vociferate_${normalized_version}_linux_${ASSET_ARCH}"
|
||||
asset_url="${SERVER_URL}/aether/vociferate/releases/download/${release_tag}/${asset_name}"
|
||||
|
||||
echo "release_tag=$release_tag" >> "$GITHUB_OUTPUT"
|
||||
echo "asset_name=$asset_name" >> "$GITHUB_OUTPUT"
|
||||
echo "asset_url=$asset_url" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Download released binary
|
||||
env:
|
||||
TOKEN: ${{ github.token }}
|
||||
ASSET_URL: ${{ steps.resolve-binary.outputs.asset_url }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
curl --fail --location \
|
||||
-H "Authorization: token ${TOKEN}" \
|
||||
-o vociferate \
|
||||
"$ASSET_URL"
|
||||
chmod +x vociferate
|
||||
|
||||
- name: Smoke test released binary
|
||||
env:
|
||||
RUN_COMMAND: ${{ matrix.run_command }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
recommended_tag="$($RUN_COMMAND --recommend --root .)"
|
||||
case "$recommended_tag" in
|
||||
v*.*.*)
|
||||
;;
|
||||
*)
|
||||
echo "Unexpected recommended tag: $recommended_tag" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
{
|
||||
echo "## Released Binary Validation"
|
||||
echo
|
||||
echo "- Release tag: ${{ steps.resolve-binary.outputs.release_tag }}"
|
||||
echo "- Asset: ${{ steps.resolve-binary.outputs.asset_name }}"
|
||||
echo "- Recommended tag: ${recommended_tag}"
|
||||
} >> "$GITHUB_STEP_SUMMARY"
|
||||
@@ -4,13 +4,14 @@ on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
description: Semantic version to release, with or without leading v.
|
||||
required: true
|
||||
description: Optional semantic version override, with or without leading v. When omitted, the recommended version is used.
|
||||
required: false
|
||||
workflow_call:
|
||||
inputs:
|
||||
version:
|
||||
description: Semantic version to release, with or without leading v.
|
||||
required: true
|
||||
description: Optional semantic version override, with or without leading v. When omitted, the recommended version is used.
|
||||
required: false
|
||||
default: ''
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
@@ -36,12 +37,36 @@ jobs:
|
||||
cache: true
|
||||
cache-dependency-path: go.sum
|
||||
|
||||
- name: Prepare release files
|
||||
- name: Resolve release version
|
||||
id: resolve-version
|
||||
env:
|
||||
RELEASE_VERSION: ${{ inputs.version }}
|
||||
INPUT_VERSION: ${{ inputs.version }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
./script/prepare-release.sh "$RELEASE_VERSION"
|
||||
|
||||
provided_version="$(printf '%s' "${INPUT_VERSION:-}" | sed 's/^[[:space:]]\+//; s/[[:space:]]\+$//')"
|
||||
|
||||
if [[ -n "$provided_version" ]]; then
|
||||
release_version="$provided_version"
|
||||
else
|
||||
if ! release_version="$(go run ./cmd/vociferate --recommend --root . 2>release-recommendation.err)"; then
|
||||
recommendation_error="$(tr '\n' ' ' < release-recommendation.err | sed 's/[[:space:]]\+/ /g' | sed 's/^ //; s/ $//')"
|
||||
echo "Resolve release version: ${recommendation_error}" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "RELEASE_VERSION=$release_version" >> "$GITHUB_ENV"
|
||||
echo "version=$release_version" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Prepare release files
|
||||
run: |
|
||||
set -euo pipefail
|
||||
go run ./cmd/vociferate \
|
||||
--root . \
|
||||
--version "$RELEASE_VERSION" \
|
||||
--date "$(date -u +%F)" \
|
||||
--changelog changelog.md
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
@@ -55,8 +80,6 @@ jobs:
|
||||
git config user.email "gitea-actions[bot]@users.noreply.local"
|
||||
|
||||
- name: Commit release changes and push tag
|
||||
env:
|
||||
RELEASE_VERSION: ${{ inputs.version }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
@@ -82,15 +105,13 @@ jobs:
|
||||
esac
|
||||
|
||||
git remote set-url origin "$authed_remote"
|
||||
git add changelog.md internal/releaseprep/version/version.go
|
||||
git add changelog.md release-version
|
||||
git commit -m "release: prepare ${tag}"
|
||||
git tag "$tag"
|
||||
git push origin HEAD
|
||||
git push origin "$tag"
|
||||
|
||||
- name: Create release with changelog notes
|
||||
env:
|
||||
RELEASE_VERSION: ${{ inputs.version }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
@@ -158,24 +179,18 @@ jobs:
|
||||
echo "RELEASE_ID=$release_id" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Build release binaries
|
||||
env:
|
||||
RELEASE_VERSION: ${{ inputs.version }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
normalized_version="${RELEASE_VERSION#v}"
|
||||
mkdir -p dist
|
||||
|
||||
for target in darwin/amd64 darwin/arm64 linux/amd64 linux/arm64 windows/amd64 windows/arm64; do
|
||||
for target in linux/amd64 linux/arm64; do
|
||||
os="${target%/*}"
|
||||
arch="${target#*/}"
|
||||
ext=""
|
||||
if [[ "$os" == "windows" ]]; then
|
||||
ext=".exe"
|
||||
fi
|
||||
|
||||
bin="vociferate_${normalized_version}_${os}_${arch}${ext}"
|
||||
GOOS="$os" GOARCH="$arch" go build -trimpath -ldflags="-s -w" -o "dist/${bin}" ./cmd/releaseprep
|
||||
bin="vociferate_${normalized_version}_${os}_${arch}"
|
||||
GOOS="$os" GOARCH="$arch" go build -trimpath -ldflags="-s -w" -o "dist/${bin}" ./cmd/vociferate
|
||||
done
|
||||
|
||||
(
|
||||
|
||||
@@ -37,7 +37,7 @@ jobs:
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
if recommended_tag="$(go run ./cmd/releaseprep --recommend --root . 2>release-recommendation.err)"; then
|
||||
if recommended_tag="$(go run ./cmd/vociferate --recommend --root . 2>release-recommendation.err)"; then
|
||||
{
|
||||
echo
|
||||
echo '## Release Recommendation'
|
||||
|
||||
31
README.md
31
README.md
@@ -13,7 +13,7 @@ just go-build
|
||||
Or directly with Go:
|
||||
|
||||
```bash
|
||||
go build -o dist/releaseprep ./cmd/releaseprep
|
||||
go build -o dist/vociferate ./cmd/vociferate
|
||||
```
|
||||
|
||||
## Usage
|
||||
@@ -21,13 +21,15 @@ go build -o dist/releaseprep ./cmd/releaseprep
|
||||
Prepare release files:
|
||||
|
||||
```bash
|
||||
go run ./cmd/releaseprep --version v1.2.3 --date 2026-03-20 --root .
|
||||
go run ./cmd/vociferate --version v1.2.3 --date 2026-03-20 --root .
|
||||
```
|
||||
|
||||
In the provided workflow and composite action, `version` is optional. When it is omitted, vociferate computes and uses the recommended next version automatically.
|
||||
|
||||
Recommend next release tag from changelog content:
|
||||
|
||||
```bash
|
||||
go run ./cmd/releaseprep --recommend --root .
|
||||
go run ./cmd/vociferate --recommend --root .
|
||||
```
|
||||
|
||||
### Flags
|
||||
@@ -42,10 +44,12 @@ go run ./cmd/releaseprep --recommend --root .
|
||||
|
||||
Defaults:
|
||||
|
||||
- `version-file`: `internal/releaseprep/version/version.go`
|
||||
- `version-pattern`: `const String = "([^"]+)"`
|
||||
- `version-file`: `release-version`
|
||||
- `version-pattern`: `^\s*([^\r\n]+)\s*$`
|
||||
- `changelog`: `changelog.md`
|
||||
|
||||
By default, `vociferate` reads and writes the release version as the sole content of a root-level `release-version` file. Repositories that keep the version inside source code should pass explicit `version-file` and `version-pattern` values.
|
||||
|
||||
## Testing
|
||||
|
||||
```bash
|
||||
@@ -54,14 +58,10 @@ just go-test
|
||||
|
||||
## Release Artifacts
|
||||
|
||||
The `Prepare Release` workflow creates a release and uploads prebuilt `vociferate` binaries for:
|
||||
Releases are prepared through the `Prepare Release` workflow. The workflow creates a release and uploads prebuilt `vociferate` binaries for:
|
||||
|
||||
- `darwin/amd64`
|
||||
- `darwin/arm64`
|
||||
- `linux/amd64`
|
||||
- `linux/arm64`
|
||||
- `windows/amd64`
|
||||
- `windows/arm64`
|
||||
|
||||
It also uploads `checksums.txt` for integrity verification.
|
||||
If a release already exists for the same tag, the workflow updates its release notes and replaces matching asset filenames so reruns stay in sync.
|
||||
@@ -74,14 +74,17 @@ Use the composite action directly:
|
||||
|
||||
```yaml
|
||||
- name: Prepare release files
|
||||
uses: git.hrafn.xyz/aether/vociferate@main
|
||||
uses: git.hrafn.xyz/aether/vociferate@v1.0.0
|
||||
with:
|
||||
version: v1.2.3
|
||||
version-file: internal/myapp/version/version.go
|
||||
version-pattern: 'const Version = "([^"]+)"'
|
||||
changelog: changelog.md
|
||||
```
|
||||
|
||||
Set `version` only when you want to override the recommended version.
|
||||
Pin the composite action to a released tag. It downloads a prebuilt Linux binary from vociferate releases and caches it on the runner, so it does not require installing Go.
|
||||
If your repository uses the default plain-text `release-version` file, you can omit `version-file` and `version-pattern` entirely.
|
||||
|
||||
Call the reusable release workflow:
|
||||
|
||||
```yaml
|
||||
@@ -91,8 +94,8 @@ on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
description: Semantic version to release.
|
||||
required: true
|
||||
description: Optional semantic version override.
|
||||
required: false
|
||||
|
||||
jobs:
|
||||
release:
|
||||
|
||||
125
action.yml
125
action.yml
@@ -1,9 +1,13 @@
|
||||
name: releaseprep
|
||||
name: vociferate
|
||||
description: Prepare release files or recommend a next semantic version tag.
|
||||
|
||||
inputs:
|
||||
token:
|
||||
description: Optional token used to download the cached vociferate release binary. When omitted, the workflow token is used.
|
||||
required: false
|
||||
default: ''
|
||||
version:
|
||||
description: Semantic version to release.
|
||||
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.
|
||||
@@ -22,42 +26,125 @@ inputs:
|
||||
required: false
|
||||
default: 'false'
|
||||
|
||||
outputs:
|
||||
version:
|
||||
description: Resolved version used for prepare mode, or the emitted recommended version for recommend mode.
|
||||
value: ${{ steps.run-vociferate.outputs.version }}
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '1.26.1'
|
||||
|
||||
- name: Run releaseprep
|
||||
- name: Resolve vociferate binary metadata
|
||||
id: resolve-binary
|
||||
shell: bash
|
||||
env:
|
||||
ACTION_REF: ${{ github.action_ref }}
|
||||
SERVER_URL: ${{ github.server_url }}
|
||||
API_URL: ${{ github.api_url }}
|
||||
TOKEN: ${{ inputs.token != '' && inputs.token || github.token }}
|
||||
RUNNER_ARCH: ${{ runner.arch }}
|
||||
RUNNER_TEMP: ${{ runner.temp }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
args=(--root .)
|
||||
case "$RUNNER_ARCH" in
|
||||
X64)
|
||||
arch="amd64"
|
||||
;;
|
||||
ARM64)
|
||||
arch="arm64"
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported runner architecture: $RUNNER_ARCH" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ "${{ inputs.recommend }}" == "true" ]]; then
|
||||
args+=(--recommend)
|
||||
else
|
||||
if [[ -z "${{ inputs.version }}" ]]; then
|
||||
echo "input 'version' is required when recommend is false" >&2
|
||||
exit 2
|
||||
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
|
||||
args+=(--version "${{ inputs.version }}" --date "$(date -u +%F)")
|
||||
|
||||
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}"
|
||||
binary_path="${cache_dir}/vociferate"
|
||||
asset_url="${SERVER_URL}/aether/vociferate/releases/download/${release_tag}/${asset_name}"
|
||||
|
||||
mkdir -p "$cache_dir"
|
||||
|
||||
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"
|
||||
|
||||
- name: Restore cached vociferate binary
|
||||
id: cache-vociferate
|
||||
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'
|
||||
shell: bash
|
||||
env:
|
||||
TOKEN: ${{ inputs.token != '' && inputs.token || github.token }}
|
||||
ASSET_URL: ${{ steps.resolve-binary.outputs.asset_url }}
|
||||
BINARY_PATH: ${{ steps.resolve-binary.outputs.binary_path }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
curl --fail --location \
|
||||
-H "Authorization: token ${TOKEN}" \
|
||||
-o "$BINARY_PATH" \
|
||||
"$ASSET_URL"
|
||||
chmod +x "$BINARY_PATH"
|
||||
|
||||
- name: Run vociferate
|
||||
id: run-vociferate
|
||||
shell: bash
|
||||
env:
|
||||
VOCIFERATE_BIN: ${{ steps.resolve-binary.outputs.binary_path }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
common_args=(--root .)
|
||||
|
||||
if [[ -n "${{ inputs.version-file }}" ]]; then
|
||||
args+=(--version-file "${{ inputs.version-file }}")
|
||||
common_args+=(--version-file "${{ inputs.version-file }}")
|
||||
fi
|
||||
|
||||
if [[ -n "${{ inputs.version-pattern }}" ]]; then
|
||||
args+=(--version-pattern "${{ inputs.version-pattern }}")
|
||||
common_args+=(--version-pattern "${{ inputs.version-pattern }}")
|
||||
fi
|
||||
|
||||
if [[ -n "${{ inputs.changelog }}" ]]; then
|
||||
args+=(--changelog "${{ inputs.changelog }}")
|
||||
common_args+=(--changelog "${{ inputs.changelog }}")
|
||||
fi
|
||||
|
||||
go run git.hrafn.xyz/aether/vociferate/cmd/releaseprep@latest "${args[@]}"
|
||||
if [[ "${{ inputs.recommend }}" == "true" ]]; then
|
||||
resolved_version="$("$VOCIFERATE_BIN" "${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)"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "version=$resolved_version" >> "$GITHUB_OUTPUT"
|
||||
"$VOCIFERATE_BIN" "${common_args[@]}" --version "$resolved_version" --date "$(date -u +%F)"
|
||||
|
||||
27
changelog.md
27
changelog.md
@@ -9,27 +9,26 @@ A `### Breaking` section is used in addition to Keep a Changelog's standard sect
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [1.0.0] - 2026-03-20
|
||||
|
||||
### Breaking
|
||||
|
||||
### Added
|
||||
- The default version source is now a root-level `release-version` file containing only the current release version. Repositories that store versions in code must now pass explicit `version-file` and `version-pattern` values.
|
||||
|
||||
### Changed
|
||||
|
||||
- The composite action now downloads and caches a released Linux `vociferate` binary instead of installing Go and running the module source directly.
|
||||
- Added workflow coverage for the released Linux binaries consumed by the composite action on both `amd64` and `arm64`.
|
||||
- Release preparation now runs directly in the release workflow; the repository-local helper script and just recipe were removed.
|
||||
- Release artifacts are now limited to `linux/amd64` and `linux/arm64` binaries plus `checksums.txt`.
|
||||
- The CLI entrypoint, internal package paths, build outputs, and automation references now use the `vociferate` name instead of the earlier `releaseprep` naming.
|
||||
- The release workflow and composite action now treat a provided `version` as an override and otherwise fall back to the recommended next version automatically.
|
||||
- Release creation is now idempotent: existing releases for the same tag are updated in place instead of recreated.
|
||||
- Release asset uploads now replace existing assets with matching filenames so reruns stay synchronized.
|
||||
- Release recommendation now forces a major version bump whenever a `### Breaking` heading is present in `## [Unreleased]`, even if the section has no bullet entries yet.
|
||||
- Reusable `workflow_call` support for the `Prepare Release` workflow, enabling other repositories to invoke it directly.
|
||||
- Automated release artifact publishing in the release workflow for `darwin`, `linux`, and `windows` binaries plus `checksums.txt`.
|
||||
- README guidance for release artifacts and examples for reusing vociferate as a composite action or reusable workflow.
|
||||
- Initial standalone releaseprep migration into vociferate.
|
||||
- Initial standalone vociferate migration from its earlier internal naming.
|
||||
- Configurable version source and parser via `--version-file` and `--version-pattern`.
|
||||
- Configurable changelog path via `--changelog`.
|
||||
- Composite action (`action.yml`) for release preparation and recommendation flows.
|
||||
- Gitea workflows for push validation and manual release preparation.
|
||||
|
||||
### Changed
|
||||
|
||||
- Release creation is now idempotent: existing releases for the same tag are updated in place instead of recreated.
|
||||
- Release asset uploads now replace existing assets with matching filenames so reruns stay synchronized.
|
||||
- Release recommendation now forces a major version bump whenever a `### Breaking` heading is present in `## [Unreleased]`, even if the section has no bullet entries yet.
|
||||
|
||||
### Fixed
|
||||
|
||||
### Removed
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"git.hrafn.xyz/aether/vociferate/internal/releaseprep"
|
||||
"git.hrafn.xyz/aether/vociferate/internal/vociferate"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -25,14 +25,14 @@ func main() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
opts := releaseprep.Options{
|
||||
opts := vociferate.Options{
|
||||
VersionFile: *versionFile,
|
||||
VersionPattern: *versionPattern,
|
||||
Changelog: *changelog,
|
||||
}
|
||||
|
||||
if *recommend {
|
||||
tag, err := releaseprep.RecommendedTag(absRoot, opts)
|
||||
tag, err := vociferate.RecommendedTag(absRoot, opts)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "recommend release: %v\n", err)
|
||||
os.Exit(1)
|
||||
@@ -42,11 +42,11 @@ func main() {
|
||||
}
|
||||
|
||||
if *version == "" || *date == "" {
|
||||
fmt.Fprintln(os.Stderr, "usage: releaseprep --version <version> --date <YYYY-MM-DD> [--root <dir>] [--version-file <path>] [--version-pattern <regexp>] [--changelog <path>] | --recommend [--root <dir>] [--version-file <path>] [--version-pattern <regexp>] [--changelog <path>]")
|
||||
fmt.Fprintln(os.Stderr, "usage: vociferate --version <version> --date <YYYY-MM-DD> [--root <dir>] [--version-file <path>] [--version-pattern <regexp>] [--changelog <path>] | --recommend [--root <dir>] [--version-file <path>] [--version-pattern <regexp>] [--changelog <path>]")
|
||||
os.Exit(2)
|
||||
}
|
||||
|
||||
if err := releaseprep.Prepare(absRoot, *version, *date, opts); err != nil {
|
||||
if err := vociferate.Prepare(absRoot, *version, *date, opts); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "prepare release: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
package version
|
||||
|
||||
const String = "1.0.0"
|
||||
@@ -1,4 +1,4 @@
|
||||
package releaseprep
|
||||
package vociferate
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -10,8 +10,8 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
defaultVersionFile = "internal/releaseprep/version/version.go"
|
||||
defaultVersionExpr = `const String = "([^"]+)"`
|
||||
defaultVersionFile = "release-version"
|
||||
defaultVersionExpr = `^\s*([^\r\n]+)\s*$`
|
||||
defaultChangelog = "changelog.md"
|
||||
)
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package releaseprep_test
|
||||
package vociferate_test
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"git.hrafn.xyz/aether/vociferate/internal/releaseprep"
|
||||
"git.hrafn.xyz/aether/vociferate/internal/vociferate"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/stretchr/testify/suite"
|
||||
)
|
||||
@@ -21,12 +21,9 @@ func TestPrepareSuite(t *testing.T) {
|
||||
|
||||
func (s *PrepareSuite) SetupTest() {
|
||||
s.rootDir = s.T().TempDir()
|
||||
versionDir := filepath.Join(s.rootDir, "internal", "releaseprep", "version")
|
||||
require.NoError(s.T(), os.MkdirAll(versionDir, 0o755))
|
||||
|
||||
require.NoError(s.T(), os.WriteFile(
|
||||
filepath.Join(versionDir, "version.go"),
|
||||
[]byte("package version\n\nconst String = \"1.1.6\"\n"),
|
||||
filepath.Join(s.rootDir, "release-version"),
|
||||
[]byte("1.1.6\n"),
|
||||
0o644,
|
||||
))
|
||||
|
||||
@@ -38,13 +35,13 @@ func (s *PrepareSuite) SetupTest() {
|
||||
}
|
||||
|
||||
func (s *PrepareSuite) TestPrepare_UpdatesVersionAndPromotesUnreleasedNotes() {
|
||||
err := releaseprep.Prepare(s.rootDir, "v1.1.7", "2026-03-20", releaseprep.Options{})
|
||||
err := vociferate.Prepare(s.rootDir, "v1.1.7", "2026-03-20", vociferate.Options{})
|
||||
|
||||
require.NoError(s.T(), err)
|
||||
|
||||
versionBytes, err := os.ReadFile(filepath.Join(s.rootDir, "internal", "releaseprep", "version", "version.go"))
|
||||
versionBytes, err := os.ReadFile(filepath.Join(s.rootDir, "release-version"))
|
||||
require.NoError(s.T(), err)
|
||||
require.Equal(s.T(), "package version\n\nconst String = \"1.1.7\"\n", string(versionBytes))
|
||||
require.Equal(s.T(), "1.1.7\n", string(versionBytes))
|
||||
|
||||
changelogBytes, err := os.ReadFile(filepath.Join(s.rootDir, "changelog.md"))
|
||||
require.NoError(s.T(), err)
|
||||
@@ -58,7 +55,7 @@ func (s *PrepareSuite) TestPrepare_ReturnsErrorWhenUnreleasedSectionMissing() {
|
||||
0o644,
|
||||
))
|
||||
|
||||
err := releaseprep.Prepare(s.rootDir, "1.1.7", "2026-03-20", releaseprep.Options{})
|
||||
err := vociferate.Prepare(s.rootDir, "1.1.7", "2026-03-20", vociferate.Options{})
|
||||
|
||||
require.ErrorContains(s.T(), err, "unreleased section")
|
||||
}
|
||||
@@ -70,13 +67,13 @@ func (s *PrepareSuite) TestPrepare_ReturnsErrorWhenUnreleasedSectionIsEmpty() {
|
||||
0o644,
|
||||
))
|
||||
|
||||
err := releaseprep.Prepare(s.rootDir, "1.1.7", "2026-03-20", releaseprep.Options{})
|
||||
err := vociferate.Prepare(s.rootDir, "1.1.7", "2026-03-20", vociferate.Options{})
|
||||
|
||||
require.ErrorContains(s.T(), err, "unreleased section is empty")
|
||||
}
|
||||
|
||||
func (s *PrepareSuite) TestRecommendedTag_UsesMajorBumpWhenBreakingHeadingExists() {
|
||||
tag, err := releaseprep.RecommendedTag(s.rootDir, releaseprep.Options{})
|
||||
tag, err := vociferate.RecommendedTag(s.rootDir, vociferate.Options{})
|
||||
|
||||
require.NoError(s.T(), err)
|
||||
require.Equal(s.T(), "v2.0.0", tag)
|
||||
@@ -89,7 +86,7 @@ func (s *PrepareSuite) TestRecommendedTag_UsesPatchBumpForFixOnlyChanges() {
|
||||
0o644,
|
||||
))
|
||||
|
||||
tag, err := releaseprep.RecommendedTag(s.rootDir, releaseprep.Options{})
|
||||
tag, err := vociferate.RecommendedTag(s.rootDir, vociferate.Options{})
|
||||
|
||||
require.NoError(s.T(), err)
|
||||
require.Equal(s.T(), "v1.1.7", tag)
|
||||
@@ -102,7 +99,7 @@ func (s *PrepareSuite) TestRecommendedTag_UsesMajorBumpWhenRemovedEntriesExist()
|
||||
0o644,
|
||||
))
|
||||
|
||||
tag, err := releaseprep.RecommendedTag(s.rootDir, releaseprep.Options{})
|
||||
tag, err := vociferate.RecommendedTag(s.rootDir, vociferate.Options{})
|
||||
|
||||
require.NoError(s.T(), err)
|
||||
require.Equal(s.T(), "v2.0.0", tag)
|
||||
@@ -115,7 +112,7 @@ func (s *PrepareSuite) TestRecommendedTag_UsesMajorBumpWhenBreakingEntriesExist(
|
||||
0o644,
|
||||
))
|
||||
|
||||
tag, err := releaseprep.RecommendedTag(s.rootDir, releaseprep.Options{})
|
||||
tag, err := vociferate.RecommendedTag(s.rootDir, vociferate.Options{})
|
||||
|
||||
require.NoError(s.T(), err)
|
||||
require.Equal(s.T(), "v2.0.0", tag)
|
||||
@@ -130,7 +127,7 @@ func (s *PrepareSuite) TestPrepare_UsesCustomVersionFileAndPattern() {
|
||||
0o644,
|
||||
))
|
||||
|
||||
err := releaseprep.Prepare(s.rootDir, "1.1.8", "2026-03-20", releaseprep.Options{
|
||||
err := vociferate.Prepare(s.rootDir, "1.1.8", "2026-03-20", vociferate.Options{
|
||||
VersionFile: customVersionFile,
|
||||
VersionPattern: `VERSION=([^\n]+)`,
|
||||
})
|
||||
@@ -144,18 +141,18 @@ func (s *PrepareSuite) TestPrepare_UsesCustomVersionFileAndPattern() {
|
||||
|
||||
func (s *PrepareSuite) TestPrepare_AllowsUnchangedVersionValue() {
|
||||
require.NoError(s.T(), os.WriteFile(
|
||||
filepath.Join(s.rootDir, "internal", "releaseprep", "version", "version.go"),
|
||||
[]byte("package version\n\nconst String = \"1.1.6\"\n"),
|
||||
filepath.Join(s.rootDir, "release-version"),
|
||||
[]byte("1.1.6\n"),
|
||||
0o644,
|
||||
))
|
||||
|
||||
err := releaseprep.Prepare(s.rootDir, "1.1.6", "2026-03-20", releaseprep.Options{})
|
||||
err := vociferate.Prepare(s.rootDir, "1.1.6", "2026-03-20", vociferate.Options{})
|
||||
|
||||
require.NoError(s.T(), err)
|
||||
|
||||
versionBytes, readErr := os.ReadFile(filepath.Join(s.rootDir, "internal", "releaseprep", "version", "version.go"))
|
||||
versionBytes, readErr := os.ReadFile(filepath.Join(s.rootDir, "release-version"))
|
||||
require.NoError(s.T(), readErr)
|
||||
require.Equal(s.T(), "package version\n\nconst String = \"1.1.6\"\n", string(versionBytes))
|
||||
require.Equal(s.T(), "1.1.6\n", string(versionBytes))
|
||||
}
|
||||
|
||||
func (s *PrepareSuite) TestRecommendedTag_UsesCustomVersionFileAndPattern() {
|
||||
@@ -172,7 +169,7 @@ func (s *PrepareSuite) TestRecommendedTag_UsesCustomVersionFileAndPattern() {
|
||||
0o644,
|
||||
))
|
||||
|
||||
tag, err := releaseprep.RecommendedTag(s.rootDir, releaseprep.Options{
|
||||
tag, err := vociferate.RecommendedTag(s.rootDir, vociferate.Options{
|
||||
VersionFile: customVersionFile,
|
||||
VersionPattern: `VERSION=([^\n]+)`,
|
||||
})
|
||||
5
justfile
5
justfile
@@ -5,10 +5,7 @@ default:
|
||||
|
||||
go-build:
|
||||
@mkdir -p dist
|
||||
go build -o dist/releaseprep ./cmd/releaseprep
|
||||
go build -o dist/vociferate ./cmd/vociferate
|
||||
|
||||
go-test:
|
||||
go test ./...
|
||||
|
||||
prepare-release version:
|
||||
./script/prepare-release.sh "{{version}}"
|
||||
|
||||
1
release-version
Normal file
1
release-version
Normal file
@@ -0,0 +1 @@
|
||||
1.0.0
|
||||
@@ -1,18 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
if [[ $# -ne 1 ]]; then
|
||||
echo "usage: $0 <version>" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
repo_root="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
release_date="$(date -u +%F)"
|
||||
|
||||
go run ./cmd/releaseprep \
|
||||
--root "$repo_root" \
|
||||
--version "$1" \
|
||||
--date "$release_date" \
|
||||
--version-file internal/releaseprep/version/version.go \
|
||||
--version-pattern 'const String = "([^"]+)"' \
|
||||
--changelog changelog.md
|
||||
Reference in New Issue
Block a user