feat: default to release-version file
Some checks failed
Some checks failed
This commit is contained in:
@@ -66,8 +66,6 @@ jobs:
|
||||
--root . \
|
||||
--version "$RELEASE_VERSION" \
|
||||
--date "$(date -u +%F)" \
|
||||
--version-file internal/vociferate/version/version.go \
|
||||
--version-pattern 'const String = "([^"]+)"' \
|
||||
--changelog changelog.md
|
||||
|
||||
- name: Run tests
|
||||
@@ -107,7 +105,7 @@ jobs:
|
||||
esac
|
||||
|
||||
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 tag "$tag"
|
||||
git push origin HEAD
|
||||
|
||||
@@ -44,10 +44,12 @@ go run ./cmd/vociferate --recommend --root .
|
||||
|
||||
Defaults:
|
||||
|
||||
- `version-file`: `internal/vociferate/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
|
||||
@@ -81,6 +83,7 @@ Use the composite action directly:
|
||||
|
||||
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:
|
||||
|
||||
|
||||
@@ -9,6 +9,10 @@ A `### Breaking` section is used in addition to Keep a Changelog's standard sect
|
||||
|
||||
## [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
|
||||
|
||||
- The composite action now downloads and caches a released Linux `vociferate` binary instead of installing Go and running the module source directly.
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
package version
|
||||
|
||||
const String = "1.0.0"
|
||||
@@ -10,8 +10,8 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
defaultVersionFile = "internal/vociferate/version/version.go"
|
||||
defaultVersionExpr = `const String = "([^"]+)"`
|
||||
defaultVersionFile = "release-version"
|
||||
defaultVersionExpr = `^\s*([^\r\n]+)\s*$`
|
||||
defaultChangelog = "changelog.md"
|
||||
)
|
||||
|
||||
|
||||
@@ -21,12 +21,9 @@ func TestPrepareSuite(t *testing.T) {
|
||||
|
||||
func (s *PrepareSuite) SetupTest() {
|
||||
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(
|
||||
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,
|
||||
))
|
||||
|
||||
@@ -42,9 +39,9 @@ func (s *PrepareSuite) TestPrepare_UpdatesVersionAndPromotesUnreleasedNotes() {
|
||||
|
||||
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.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)
|
||||
@@ -144,8 +141,8 @@ func (s *PrepareSuite) TestPrepare_UsesCustomVersionFileAndPattern() {
|
||||
|
||||
func (s *PrepareSuite) TestPrepare_AllowsUnchangedVersionValue() {
|
||||
require.NoError(s.T(), os.WriteFile(
|
||||
filepath.Join(s.rootDir, "internal", "vociferate", "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,
|
||||
))
|
||||
|
||||
@@ -153,9 +150,9 @@ func (s *PrepareSuite) TestPrepare_AllowsUnchangedVersionValue() {
|
||||
|
||||
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.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() {
|
||||
|
||||
1
release-version
Normal file
1
release-version
Normal file
@@ -0,0 +1 @@
|
||||
1.0.0
|
||||
Reference in New Issue
Block a user