feat: default to release-version file
Some checks failed
Action Validation / validate-released-binary (amd64, ./vociferate, X64) (push) Failing after 6s
Action Validation / validate-released-binary (arm64, qemu-aarch64-static ./vociferate, ARM64) (push) Failing after 23s
Push Validation / validate (push) Successful in 52s

This commit is contained in:
Micheal Wilkinson
2026-03-20 19:32:49 +00:00
parent a413385c4e
commit 2646d42523
7 changed files with 21 additions and 21 deletions

View File

@@ -66,8 +66,6 @@ jobs:
--root . \ --root . \
--version "$RELEASE_VERSION" \ --version "$RELEASE_VERSION" \
--date "$(date -u +%F)" \ --date "$(date -u +%F)" \
--version-file internal/vociferate/version/version.go \
--version-pattern 'const String = "([^"]+)"' \
--changelog changelog.md --changelog changelog.md
- name: Run tests - name: Run tests
@@ -107,7 +105,7 @@ jobs:
esac esac
git remote set-url origin "$authed_remote" git remote set-url origin "$authed_remote"
git add changelog.md internal/vociferate/version/version.go git add changelog.md release-version
git commit -m "release: prepare ${tag}" git commit -m "release: prepare ${tag}"
git tag "$tag" git tag "$tag"
git push origin HEAD git push origin HEAD

View File

@@ -44,10 +44,12 @@ go run ./cmd/vociferate --recommend --root .
Defaults: Defaults:
- `version-file`: `internal/vociferate/version/version.go` - `version-file`: `release-version`
- `version-pattern`: `const String = "([^"]+)"` - `version-pattern`: `^\s*([^\r\n]+)\s*$`
- `changelog`: `changelog.md` - `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 ## Testing
```bash ```bash
@@ -81,6 +83,7 @@ Use the composite action directly:
Set `version` only when you want to override the recommended version. 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. 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: Call the reusable release workflow:

View File

@@ -9,6 +9,10 @@ A `### Breaking` section is used in addition to Keep a Changelog's standard sect
## [Unreleased] ## [Unreleased]
### Breaking
- 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 ### Changed
- The composite action now downloads and caches a released Linux `vociferate` binary instead of installing Go and running the module source directly. - The composite action now downloads and caches a released Linux `vociferate` binary instead of installing Go and running the module source directly.

View File

@@ -1,3 +0,0 @@
package version
const String = "1.0.0"

View File

@@ -10,8 +10,8 @@ import (
) )
const ( const (
defaultVersionFile = "internal/vociferate/version/version.go" defaultVersionFile = "release-version"
defaultVersionExpr = `const String = "([^"]+)"` defaultVersionExpr = `^\s*([^\r\n]+)\s*$`
defaultChangelog = "changelog.md" defaultChangelog = "changelog.md"
) )

View File

@@ -21,12 +21,9 @@ func TestPrepareSuite(t *testing.T) {
func (s *PrepareSuite) SetupTest() { func (s *PrepareSuite) SetupTest() {
s.rootDir = s.T().TempDir() s.rootDir = s.T().TempDir()
versionDir := filepath.Join(s.rootDir, "internal", "vociferate", "version")
require.NoError(s.T(), os.MkdirAll(versionDir, 0o755))
require.NoError(s.T(), os.WriteFile( require.NoError(s.T(), os.WriteFile(
filepath.Join(versionDir, "version.go"), filepath.Join(s.rootDir, "release-version"),
[]byte("package version\n\nconst String = \"1.1.6\"\n"), []byte("1.1.6\n"),
0o644, 0o644,
)) ))
@@ -42,9 +39,9 @@ func (s *PrepareSuite) TestPrepare_UpdatesVersionAndPromotesUnreleasedNotes() {
require.NoError(s.T(), err) require.NoError(s.T(), err)
versionBytes, err := os.ReadFile(filepath.Join(s.rootDir, "internal", "vociferate", "version", "version.go")) versionBytes, err := os.ReadFile(filepath.Join(s.rootDir, "release-version"))
require.NoError(s.T(), err) 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")) changelogBytes, err := os.ReadFile(filepath.Join(s.rootDir, "changelog.md"))
require.NoError(s.T(), err) require.NoError(s.T(), err)
@@ -144,8 +141,8 @@ func (s *PrepareSuite) TestPrepare_UsesCustomVersionFileAndPattern() {
func (s *PrepareSuite) TestPrepare_AllowsUnchangedVersionValue() { func (s *PrepareSuite) TestPrepare_AllowsUnchangedVersionValue() {
require.NoError(s.T(), os.WriteFile( require.NoError(s.T(), os.WriteFile(
filepath.Join(s.rootDir, "internal", "vociferate", "version", "version.go"), filepath.Join(s.rootDir, "release-version"),
[]byte("package version\n\nconst String = \"1.1.6\"\n"), []byte("1.1.6\n"),
0o644, 0o644,
)) ))
@@ -153,9 +150,9 @@ func (s *PrepareSuite) TestPrepare_AllowsUnchangedVersionValue() {
require.NoError(s.T(), err) require.NoError(s.T(), err)
versionBytes, readErr := os.ReadFile(filepath.Join(s.rootDir, "internal", "vociferate", "version", "version.go")) versionBytes, readErr := os.ReadFile(filepath.Join(s.rootDir, "release-version"))
require.NoError(s.T(), readErr) 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() { func (s *PrepareSuite) TestRecommendedTag_UsesCustomVersionFileAndPattern() {

1
release-version Normal file
View File

@@ -0,0 +1 @@
1.0.0