mirror of
https://github.com/usememos/memos.git
synced 2026-11-19 10:29:11 +01:00
chore: switch release versions to YY.MM.N (#6469)
This commit is contained in:
@@ -44,10 +44,12 @@ to, and whether the working tree differs from the candidate (mention it; do not
|
||||
|
||||
## 2. Choose the Tag
|
||||
|
||||
Format is `YY.MM[.N][-rc.N]` (validated by `scripts/release_version.sh` and `internal/version`). `YY.MM` is the current UTC month.
|
||||
Format is `YY.MM.N[-rc.K]` (validated by `scripts/release_version.sh` and `internal/version`). `YY.MM` is the current UTC
|
||||
month, `N` counts stable releases in that month from 0, and `K` counts candidates for one stable release from 1. Bare `YY.MM`
|
||||
is never a git tag: it is the image tag that follows the newest stable release of its month.
|
||||
|
||||
- **New stable:** `YY.MM` if no stable tag exists for this month, else `YY.MM.<N+1>`.
|
||||
- **New release candidate:** the next stable version plus `-rc.<N+1>`, counting existing candidates for that version.
|
||||
- **New stable:** `YY.MM.0` if no stable tag exists for this month, else `YY.MM.<N+1>`.
|
||||
- **New release candidate:** the next stable version plus `-rc.<K+1>`, counting existing candidates for that version.
|
||||
- **Promote a candidate:** the candidate's base version, tagged on the candidate's commit. Promotion keeps the base version
|
||||
even if the month has changed. If main moved past the candidate, ask whether to promote the candidate commit or cut a new
|
||||
candidate from main.
|
||||
@@ -111,8 +113,8 @@ Do not report success until each check passes:
|
||||
2. Download `checksums.txt` and the archive for this machine into a temporary directory. Check it with `sha256sum -c` (or
|
||||
`shasum -a 256 -c`) against its line, then extract and run `./memos --version`, which must print the tag.
|
||||
3. `docker buildx imagetools inspect neosmemo/memos:<tag>` and `ghcr.io/usememos/memos:<tag>`: both list `linux/amd64`,
|
||||
`linux/arm64`, and `linux/arm/v7`. For stable tags, `stable` and the series tag (when it differs from the tag) resolve to the
|
||||
same digest as `<tag>`.
|
||||
`linux/arm64`, and `linux/arm/v7`. For stable tags, `stable` and the month tag `YY.MM` resolve to the same digest as
|
||||
`<tag>`.
|
||||
4. If Docker can run locally, `./scripts/release_smoke_test.sh --candidate-image neosmemo/memos:<tag>` tests the published
|
||||
image. If Docker is unavailable, say so; do not skip it silently.
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ contributors: describe what changed for them, not how the code changed.
|
||||
Stable releases use these sections in this order. Omit an empty section rather than padding it.
|
||||
|
||||
1. **Summary paragraph** (no heading): two sentences. Name the most important additions, then the areas that improved
|
||||
overall. Use the release's tag as the version, e.g. "Memos 26.10 adds…".
|
||||
overall. Use the release's tag as the version, e.g. "Memos 26.10.0 adds…".
|
||||
2. `## Highlights`: new capabilities, ordered writing first, then finding and browsing, then ownership and data.
|
||||
3. `## Fixes and polish`: grouped by area (Editor, Markdown, Interface and languages, …).
|
||||
4. `## Administration and integrations`: security, deployment, configuration, API, MCP, CLI.
|
||||
|
||||
@@ -3,7 +3,7 @@ name: Release
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
# Calendar tags only (26.09, 26.09.1, 26.09-rc.1); legacy v0.x tags
|
||||
# Calendar tags only (26.10.0, 26.10.1, 26.10.0-rc.1); legacy v0.x tags
|
||||
# are rejected by scripts/release_version.sh and must not start a run.
|
||||
- "[1-9][0-9].*"
|
||||
workflow_dispatch:
|
||||
|
||||
@@ -142,9 +142,9 @@ Black-box service tests live in `server/api/test/`, unit tests next to the code.
|
||||
|
||||
## CI Reference
|
||||
|
||||
- Releases are cut by pushing a `YY.MM[.N][-rc.N]` tag. To cut, promote, or check a release, follow
|
||||
- Releases are cut by pushing a `YY.MM.N[-rc.K]` tag. To cut, promote, or check a release, follow
|
||||
`.agents/skills/release/SKILL.md`.
|
||||
- Development builds use the HEAD committer date in UTC as `YY.MM`; release builds inject the CalVer tag.
|
||||
- Development builds use the HEAD committer date in UTC as `YY.MM.D-dev.<sha7>`; release builds inject the CalVer tag.
|
||||
- `go build` embeds Git metadata automatically; `go run` needs `-buildvcs=true`. Builds without Git metadata must inject
|
||||
`github.com/usememos/memos/internal/version.Version` through `-ldflags`.
|
||||
- Docker excludes `.git`; pass `--build-arg VERSION="$(bash scripts/release_version.sh development-version)"` and
|
||||
|
||||
@@ -40,9 +40,9 @@ docker run -d \
|
||||
|
||||
Other install options are in the [deployment guide](https://usememos.com/docs/deploy).
|
||||
|
||||
Releases use `YY.MM`, with optional point releases such as `26.09.1` and release
|
||||
candidates such as `26.09-rc.1`. Calendar release tags have no `v` prefix. The Docker `stable` tag follows stable releases;
|
||||
`canary` follows development builds. If upgrading from a release before v0.31.0,
|
||||
Releases use `YY.MM.N`: each month starts at `26.10.0`, point releases follow as `26.10.1`, and release candidates are
|
||||
`26.10.0-rc.1`. Calendar release tags have no `v` prefix. The Docker `26.10` tag follows the newest stable release of its
|
||||
month, `stable` follows stable releases, and `canary` follows development builds. If upgrading from a release before v0.31.0,
|
||||
run [v0.31.0](https://github.com/usememos/memos/releases/tag/v0.31.0) successfully.
|
||||
See the [upgrade requirements](store/migration/README.md) for earlier versions.
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ func TestVersionFormsPrintTheSameString(t *testing.T) {
|
||||
// Test binaries do not carry VCS metadata. Supply a version so Cobra takes
|
||||
// its version path rather than running the server.
|
||||
originalVersion := rootCmd.Version
|
||||
rootCmd.Version = "26.09"
|
||||
rootCmd.Version = "26.10.0"
|
||||
t.Cleanup(func() { rootCmd.Version = originalVersion })
|
||||
|
||||
// Cobra handles the version flag before RunE, and the version subcommand has
|
||||
|
||||
@@ -14,8 +14,9 @@ var Version string
|
||||
// Commit is injected by CI or read from build metadata, falling back to unknown.
|
||||
var Commit = "unknown"
|
||||
|
||||
// calendarVersion matches YY.MM[.N][-rc.N]; scripts/release_version.sh accepts the same tags.
|
||||
var calendarVersion = regexp.MustCompile(`^[1-9][0-9]\.(0[1-9]|1[0-2])(\.[1-9][0-9]*)?(-rc\.[1-9][0-9]*)?$`)
|
||||
// buildVersion matches release tags YY.MM.N[-rc.K] and development builds
|
||||
// YY.MM.D-dev.<sha7>; scripts/release_version.sh accepts the same release tags.
|
||||
var buildVersion = regexp.MustCompile(`^[1-9][0-9]\.(0[1-9]|1[0-2])\.(0|[1-9][0-9]*)(-rc\.[1-9][0-9]*|-dev\.[0-9a-f]{7})?$`)
|
||||
|
||||
func init() {
|
||||
if info, ok := debug.ReadBuildInfo(); ok {
|
||||
@@ -23,22 +24,28 @@ func init() {
|
||||
}
|
||||
}
|
||||
|
||||
// resolveBuild fills the version and commit from Go build settings. Without an
|
||||
// injected version it derives YY.MM.D-dev.<sha7> from the commit time in UTC and
|
||||
// the commit revision, matching scripts/release_version.sh development-version.
|
||||
func resolveBuild(version, commit string, settings []debug.BuildSetting) (string, string) {
|
||||
var date, revision string
|
||||
for _, setting := range settings {
|
||||
switch setting.Key {
|
||||
case "vcs.time":
|
||||
if version == "" {
|
||||
if timestamp, err := time.Parse(time.RFC3339, setting.Value); err == nil {
|
||||
version = timestamp.UTC().Format("06.01")
|
||||
}
|
||||
date = timestamp.UTC().Format("06.01.2")
|
||||
}
|
||||
case "vcs.revision":
|
||||
revision = setting.Value
|
||||
if commit == "" || commit == "unknown" {
|
||||
commit = setting.Value
|
||||
commit = revision
|
||||
}
|
||||
default:
|
||||
}
|
||||
}
|
||||
if version == "" && date != "" && len(revision) >= 7 {
|
||||
version = date + "-dev." + revision[:7]
|
||||
}
|
||||
return version, commit
|
||||
}
|
||||
|
||||
@@ -47,8 +54,8 @@ func Validate() error {
|
||||
if Version == "" {
|
||||
return errors.New("missing build version: use go run -buildvcs=true ./cmd/memos or inject internal/version.Version with -ldflags")
|
||||
}
|
||||
if !calendarVersion.MatchString(Version) {
|
||||
return errors.Errorf("invalid build version %q: expected YY.MM[.N][-rc.N]", Version)
|
||||
if !buildVersion.MatchString(Version) {
|
||||
return errors.Errorf("invalid build version %q: expected YY.MM.N[-rc.K] or YY.MM.D-dev.<sha7>", Version)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -11,17 +11,17 @@ func TestResolveBuild(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
name, version, commit, timestamp, wantVersion, wantCommit string
|
||||
}{
|
||||
{"development", "", "unknown", "2026-09-27T14:58:52Z", "26.09", "abc123"},
|
||||
{"UTC month boundary", "", "unknown", "2026-10-01T00:30:00+08:00", "26.09", "abc123"},
|
||||
{"UTC year boundary", "", "unknown", "2026-12-31T23:30:00-08:00", "27.01", "abc123"},
|
||||
{"development", "", "unknown", "2026-09-27T14:58:52Z", "26.09.27-dev.abc1234", "abc1234def"},
|
||||
{"UTC day boundary", "", "unknown", "2026-10-01T00:30:00+08:00", "26.09.30-dev.abc1234", "abc1234def"},
|
||||
{"UTC year boundary", "", "unknown", "2026-12-31T23:30:00-08:00", "27.01.1-dev.abc1234", "abc1234def"},
|
||||
{"release override", "26.10.1", "release-sha", "2026-09-27T14:58:52Z", "26.10.1", "release-sha"},
|
||||
{"RC override", "26.10-rc.1", "", "2026-09-27T14:58:52Z", "26.10-rc.1", "abc123"},
|
||||
{"invalid timestamp", "", "unknown", "invalid", "", "abc123"},
|
||||
{"RC override", "26.10.0-rc.1", "", "2026-09-27T14:58:52Z", "26.10.0-rc.1", "abc1234def"},
|
||||
{"invalid timestamp", "", "unknown", "invalid", "", "abc1234def"},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
settings := []debug.BuildSetting{
|
||||
{Key: "vcs.time", Value: tc.timestamp},
|
||||
{Key: "vcs.revision", Value: "abc123"},
|
||||
{Key: "vcs.revision", Value: "abc1234def"},
|
||||
{Key: "vcs.modified", Value: "true"},
|
||||
}
|
||||
version, commit := resolveBuild(tc.version, tc.commit, settings)
|
||||
@@ -30,7 +30,11 @@ func TestResolveBuild(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
version, commit := resolveBuild("", "unknown", nil)
|
||||
// A commit time without a revision cannot name a development build.
|
||||
version, commit := resolveBuild("", "unknown", []debug.BuildSetting{{Key: "vcs.time", Value: "2026-09-27T14:58:52Z"}})
|
||||
require.Empty(t, version)
|
||||
require.Equal(t, "unknown", commit)
|
||||
version, commit = resolveBuild("", "unknown", nil)
|
||||
require.Empty(t, version)
|
||||
require.Equal(t, "unknown", commit)
|
||||
version, commit = resolveBuild("26.09.1", "release-sha", nil)
|
||||
@@ -41,11 +45,16 @@ func TestResolveBuild(t *testing.T) {
|
||||
func TestValidate(t *testing.T) {
|
||||
original := Version
|
||||
t.Cleanup(func() { Version = original })
|
||||
for _, value := range []string{"26.09", "26.09.1", "27.01", "26.10-rc.1", "26.10.2-rc.3"} {
|
||||
for _, value := range []string{
|
||||
"26.09.0", "26.09.1", "26.09.10", "27.01.0", "26.10.0-rc.1", "26.10.2-rc.3", "26.10.1-dev.abc1234", "26.10.31-dev.abc1234",
|
||||
} {
|
||||
Version = value
|
||||
require.NoError(t, Validate(), value)
|
||||
}
|
||||
for _, value := range []string{"dev", "manual-abc123", "v26.09", "0.31.0", "26.9", "26.00", "26.13", "26.09.0", "26.09.01", "26.09-rc.0", "26.09-dev.1", "26.09-dirty"} {
|
||||
for _, value := range []string{
|
||||
"dev", "manual-abc123", "v26.09.0", "0.31.0", "26.09", "26.9.0", "26.00.0", "26.13.0", "26.09.01", "26.09-rc.1",
|
||||
"26.09.0-rc.0", "26.09.1-dev", "26.09.1-dev.abc", "26.09.1-dev.ABC1234", "26.09.01-dev.abc1234", "26.09.1-dirty",
|
||||
} {
|
||||
Version = value
|
||||
require.ErrorContains(t, Validate(), "invalid build version", value)
|
||||
}
|
||||
|
||||
+2
-2
@@ -17,7 +17,7 @@ Usage:
|
||||
install.sh [--version <version>] [--install-dir <dir>] [--repo <owner/name>] [--skip-checksum]
|
||||
|
||||
Environment:
|
||||
MEMOS_VERSION Version to install. Accepts "26.09" or "26.09.1". Defaults to latest release.
|
||||
MEMOS_VERSION Version to install. Accepts "26.10.0" or "26.10.1". Defaults to latest release.
|
||||
MEMOS_INSTALL_DIR Directory to install the binary into.
|
||||
MEMOS_SKIP_CHECKSUM Set to 1 to skip checksum verification.
|
||||
MEMOS_INSTALL_QUIET Set to 1 to reduce log output.
|
||||
@@ -25,7 +25,7 @@ Environment:
|
||||
|
||||
Examples:
|
||||
curl -fsSL https://raw.githubusercontent.com/usememos/memos/main/scripts/install.sh | sh
|
||||
curl -fsSL https://raw.githubusercontent.com/usememos/memos/main/scripts/install.sh | sh -s -- --version 26.09
|
||||
curl -fsSL https://raw.githubusercontent.com/usememos/memos/main/scripts/install.sh | sh -s -- --version 26.10.0
|
||||
EOF
|
||||
}
|
||||
|
||||
|
||||
@@ -14,13 +14,13 @@ import (
|
||||
|
||||
func TestInstallRelease(t *testing.T) {
|
||||
for _, tc := range []struct{ input, tag string }{
|
||||
{"26.09", "26.09"},
|
||||
{"26.09.1", "26.09.1"},
|
||||
{"v26.09.1", "26.09.1"},
|
||||
{"26.09-rc.1", "26.09-rc.1"},
|
||||
{"26.10.0", "26.10.0"},
|
||||
{"26.10.1", "26.10.1"},
|
||||
{"v26.10.1", "26.10.1"},
|
||||
{"26.10.0-rc.1", "26.10.0-rc.1"},
|
||||
{"0.31.0", "v0.31.0"},
|
||||
{"v0.31.0", "v0.31.0"},
|
||||
{"", "26.09.2"},
|
||||
{"", "26.10.2"},
|
||||
{"", "v0.31.0"},
|
||||
} {
|
||||
input, tag := tc.input, tc.tag
|
||||
|
||||
+21
-13
@@ -2,10 +2,12 @@
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# Application releases use YY.MM[.N][-rc.N]. Database migration sequences are separate.
|
||||
# Application releases use YY.MM.N[-rc.K]; .agents/skills/release/SKILL.md says
|
||||
# how N and K are chosen. Bare YY.MM is only an image tag that follows the newest
|
||||
# stable of its month. Database migration sequences are separate.
|
||||
parse_release_tag() {
|
||||
local tag="$1"
|
||||
if [[ ! "$tag" =~ ^([1-9][0-9]\.(0[1-9]|1[0-2]))(\.([1-9][0-9]*))?(-rc\.([1-9][0-9]*))?$ ]]; then
|
||||
if [[ ! "$tag" =~ ^([1-9][0-9]\.(0[1-9]|1[0-2]))\.(0|[1-9][0-9]*)(-rc\.([1-9][0-9]*))?$ ]]; then
|
||||
return 1
|
||||
fi
|
||||
RELEASE_VERSION="$tag"
|
||||
@@ -16,6 +18,21 @@ parse_release_tag() {
|
||||
fi
|
||||
}
|
||||
|
||||
# development_version prints YY.MM.D-dev.<sha7> for HEAD from its committer date
|
||||
# in UTC, matching internal/version. format-local honors TZ; plain format uses
|
||||
# the commit's original zone.
|
||||
development_version() {
|
||||
local repo="$1" head month day sha version
|
||||
head="$(TZ=UTC git -C "$repo" show -s --format='%cd %H' --date='format-local:%y.%m %d' HEAD)"
|
||||
read -r month day sha <<<"$head"
|
||||
version="$month.${day#0}"
|
||||
if ! parse_release_tag "$version"; then
|
||||
echo "Cannot derive a calendar version from HEAD" >&2
|
||||
return 1
|
||||
fi
|
||||
printf '%s-dev.%s\n' "$version" "${sha:0:7}"
|
||||
}
|
||||
|
||||
# previous_release_tag prints the newest stable release tag that is an ancestor
|
||||
# of HEAD, excluding tags on HEAD itself. Legacy v0.31.x tags count because
|
||||
# v0.31.0 is the fixed upgrade baseline.
|
||||
@@ -55,13 +72,7 @@ previous_release_image() {
|
||||
if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
|
||||
case "${1:-}" in
|
||||
development-version)
|
||||
# format-local honors TZ; plain format uses the commit's original zone.
|
||||
version="$(TZ=UTC git -C "${2:-.}" show -s --format=%cd --date=format-local:%y.%m HEAD)"
|
||||
if ! parse_release_tag "$version"; then
|
||||
echo "Cannot derive a calendar version from HEAD" >&2
|
||||
exit 1
|
||||
fi
|
||||
printf '%s\n' "$version"
|
||||
development_version "${2:-.}"
|
||||
exit
|
||||
;;
|
||||
previous-tag)
|
||||
@@ -86,10 +97,7 @@ if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
|
||||
image-tags)
|
||||
printf '%s\n' "$RELEASE_VERSION"
|
||||
if [[ "$RELEASE_IS_PRERELEASE" == false ]]; then
|
||||
if [[ "$RELEASE_SERIES" != "$RELEASE_VERSION" ]]; then
|
||||
printf '%s\n' "$RELEASE_SERIES"
|
||||
fi
|
||||
printf 'stable\n'
|
||||
printf '%s\nstable\n' "$RELEASE_SERIES"
|
||||
fi
|
||||
;;
|
||||
*) echo "Unknown release command: ${1:-}" >&2; exit 1 ;;
|
||||
|
||||
@@ -13,10 +13,12 @@ import (
|
||||
)
|
||||
|
||||
func TestDevelopmentVersion(t *testing.T) {
|
||||
original := version.Version
|
||||
t.Cleanup(func() { version.Version = original })
|
||||
for _, tc := range []struct{ date, version string }{
|
||||
{"2026-09-27T14:58:52Z", "26.09"},
|
||||
{"2026-10-01T00:30:00+08:00", "26.09"},
|
||||
{"2026-12-31T23:30:00-08:00", "27.01"},
|
||||
{"2026-09-27T14:58:52Z", "26.09.27"},
|
||||
{"2026-10-01T00:30:00+08:00", "26.09.30"},
|
||||
{"2026-12-31T23:30:00-08:00", "27.01.1"},
|
||||
} {
|
||||
t.Run(tc.date, func(t *testing.T) {
|
||||
repo := t.TempDir()
|
||||
@@ -29,11 +31,17 @@ func TestDevelopmentVersion(t *testing.T) {
|
||||
}
|
||||
check := func(repo string) {
|
||||
t.Helper()
|
||||
sha, err := exec.Command("git", "-C", repo, "rev-parse", "HEAD").Output()
|
||||
require.NoError(t, err)
|
||||
cmd := exec.Command("bash", "release_version.sh", "development-version", repo)
|
||||
cmd.Env = append(os.Environ(), "TZ=Pacific/Honolulu")
|
||||
out, err := cmd.CombinedOutput()
|
||||
require.NoError(t, err, string(out))
|
||||
require.Equal(t, tc.version+"\n", string(out))
|
||||
want := tc.version + "-dev." + strings.TrimSpace(string(sha))[:7] + "\n"
|
||||
require.Equal(t, want, string(out))
|
||||
// The script and the binary must name the same development build.
|
||||
version.Version = strings.TrimSpace(string(out))
|
||||
require.NoError(t, version.Validate())
|
||||
}
|
||||
runGit("init", "-b", "main")
|
||||
runGit("commit", "--allow-empty", "-m", "source")
|
||||
@@ -58,12 +66,12 @@ func TestReleaseVersions(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
tag, series, prerelease, images string
|
||||
}{
|
||||
{"26.09", "26.09", "false", "26.09\nstable\n"},
|
||||
{"26.09.0", "26.09", "false", "26.09.0\n26.09\nstable\n"},
|
||||
{"26.09.1", "26.09", "false", "26.09.1\n26.09\nstable\n"},
|
||||
{"26.09.10", "26.09", "false", "26.09.10\n26.09\nstable\n"},
|
||||
{"26.10.1", "26.10", "false", "26.10.1\n26.10\nstable\n"},
|
||||
{"27.01", "27.01", "false", "27.01\nstable\n"},
|
||||
{"26.09-rc.1", "26.09", "true", "26.09-rc.1\n"},
|
||||
{"27.01.0", "27.01", "false", "27.01.0\n27.01\nstable\n"},
|
||||
{"26.09.0-rc.1", "26.09", "true", "26.09.0-rc.1\n"},
|
||||
{"26.09.1-rc.2", "26.09", "true", "26.09.1-rc.2\n"},
|
||||
} {
|
||||
t.Run(tc.tag, func(t *testing.T) {
|
||||
@@ -75,27 +83,33 @@ func TestReleaseVersions(t *testing.T) {
|
||||
require.Equal(t, tc.images, string(out))
|
||||
})
|
||||
}
|
||||
for _, tag := range []string{"v0.31.0", "v26.09", "v26.09.1", "v26.09-rc.1", "26.9", "26.00", "26.13", "2026.09", "26.09.0", "26.09.01", "26.09-rc.0", "26.09-rc.01", "26.09beta", "26.09.1+build"} {
|
||||
for _, tag := range []string{
|
||||
"v0.31.0", "v26.09.0", "v26.09.1", "v26.09.0-rc.1", "26.09", "26.09-rc.1", "26.9.0", "26.00.0", "26.13.0", "2026.09.0",
|
||||
"26.09.01", "26.09.0-rc.0", "26.09.0-rc.01", "26.09.0beta", "26.09.1+build", "26.09.1-dev.abc1234",
|
||||
} {
|
||||
out, err := exec.Command("bash", "release_version.sh", "version", tag).CombinedOutput()
|
||||
require.Error(t, err, tag)
|
||||
require.Contains(t, string(out), "Unsupported release tag")
|
||||
}
|
||||
}
|
||||
|
||||
// The script and the binary must accept the same versions, or a tag could
|
||||
// build a binary that refuses to start.
|
||||
// The script and the binary must accept the same release tags, or a tag could
|
||||
// build a binary that refuses to start. Development versions are binary-only.
|
||||
func TestReleaseTagsMatchBinaryVersions(t *testing.T) {
|
||||
original := version.Version
|
||||
t.Cleanup(func() { version.Version = original })
|
||||
for _, tag := range []string{
|
||||
"26.09", "26.09.1", "26.09.10", "27.01", "26.09-rc.1", "26.09.1-rc.2",
|
||||
"v26.09", "0.31.0", "26.9", "26.00", "26.13", "2026.09", "26.09.0", "26.09.01", "26.09-rc.0", "26.09-rc.01",
|
||||
"26.09-dev.1", "26.09-dirty", "26.09beta", "26.09.1+build", "dev",
|
||||
"26.09.0", "26.09.1", "26.09.10", "27.01.0", "26.09.0-rc.1", "26.09.1-rc.2",
|
||||
"v26.09.0", "0.31.0", "26.09", "26.9.0", "26.00.0", "26.13.0", "2026.09.0", "26.09.01", "26.09-rc.1", "26.09.0-rc.0", "26.09.0-rc.01",
|
||||
"26.09.1-dev.1", "26.09.1-dirty", "26.09.0beta", "26.09.1+build", "dev",
|
||||
} {
|
||||
scriptErr := exec.Command("bash", "release_version.sh", "version", tag).Run()
|
||||
version.Version = tag
|
||||
require.Equal(t, scriptErr == nil, version.Validate() == nil, tag)
|
||||
}
|
||||
version.Version = "26.09.1-dev.abc1234"
|
||||
require.NoError(t, version.Validate())
|
||||
require.Error(t, exec.Command("bash", "release_version.sh", "version", version.Version).Run())
|
||||
}
|
||||
|
||||
func TestPreviousReleaseImage(t *testing.T) {
|
||||
@@ -121,28 +135,29 @@ func TestPreviousReleaseImage(t *testing.T) {
|
||||
runGit("commit", "--allow-empty", "-m", "baseline")
|
||||
runGit("tag", "v0.31.0")
|
||||
runGit("commit", "--allow-empty", "-m", "first calendar release")
|
||||
runGit("tag", "26.09")
|
||||
runGit("tag", "26.09.0")
|
||||
check("v0.31.0")
|
||||
runGit("commit", "--allow-empty", "-m", "point release")
|
||||
runGit("tag", "26.09.2")
|
||||
check("26.09")
|
||||
check("26.09.0")
|
||||
runGit("commit", "--allow-empty", "-m", "tenth point release")
|
||||
runGit("tag", "26.09.10")
|
||||
// Two-part tags are image aliases, never releases.
|
||||
runGit("tag", "99.99")
|
||||
runGit("commit", "--allow-empty", "-m", "release candidate")
|
||||
runGit("tag", "26.10-rc.1")
|
||||
runGit("tag", "26.10.0-rc.1")
|
||||
check("26.09.10")
|
||||
runGit("commit", "--allow-empty", "-m", "after release candidate")
|
||||
check("26.09.10")
|
||||
runGit("checkout", "--orphan", "unrelated")
|
||||
runGit("commit", "--allow-empty", "-m", "unrelated release")
|
||||
runGit("tag", "29.01")
|
||||
runGit("tag", "29.01.0")
|
||||
runGit("checkout", "main")
|
||||
check("26.09.10")
|
||||
runGit("tag", "26.10")
|
||||
runGit("tag", "26.10.0")
|
||||
runGit("commit", "--allow-empty", "-m", "next year")
|
||||
runGit("tag", "27.01")
|
||||
check("26.10")
|
||||
runGit("tag", "27.01.0")
|
||||
check("26.10.0")
|
||||
// The floor excludes pre-baseline tags even if no supported release exists.
|
||||
repo = t.TempDir()
|
||||
runGit("init", "-b", "main")
|
||||
|
||||
@@ -42,7 +42,7 @@ func TestUpgradeFromBaselineRelease(t *testing.T) {
|
||||
require.Equal(t, "0.31.8", baseline.SchemaVersion)
|
||||
|
||||
requireUpgradePreservesData(ctx, t, previous, &profile.Profile{
|
||||
Data: t.TempDir(), DSN: hostDSN, Driver: driver, Version: "26.10",
|
||||
Data: t.TempDir(), DSN: hostDSN, Driver: driver, Version: "26.10.0",
|
||||
})
|
||||
}
|
||||
|
||||
@@ -51,10 +51,10 @@ func TestUpgradeFromBaselineRelease(t *testing.T) {
|
||||
// only migrations do.
|
||||
func TestUpgradeFromCalendarRelease(t *testing.T) {
|
||||
for _, tc := range []struct{ previous, candidate string }{
|
||||
{previous: "26.09", candidate: "26.10"},
|
||||
{previous: "26.10", candidate: "26.10.1"},
|
||||
{previous: "26.10-rc.1", candidate: "26.10"},
|
||||
{previous: "26.12.9", candidate: "27.01"},
|
||||
{previous: "26.09.0", candidate: "26.10.0"},
|
||||
{previous: "26.10.0", candidate: "26.10.1"},
|
||||
{previous: "26.10.0-rc.1", candidate: "26.10.0"},
|
||||
{previous: "26.12.9", candidate: "27.01.0"},
|
||||
} {
|
||||
t.Run(tc.previous+"-to-"+tc.candidate, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Release links accept current calendar versions and historical 0.x releases.
|
||||
// Release links accept calendar releases YY.MM.N[-rc.K] and historical 0.x releases.
|
||||
const isReleaseVersion = (version: string): boolean =>
|
||||
/^(?:[1-9]\d\.(?:0[1-9]|1[0-2])(?:\.[1-9]\d*)?|0\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*))(?:-rc\.[1-9]\d*)?$/.test(version);
|
||||
/^(?:[1-9]\d\.(?:0[1-9]|1[0-2])\.(?:0|[1-9]\d*)|0\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*))(?:-rc\.[1-9]\d*)?$/.test(version);
|
||||
|
||||
export const getReleaseTag = (version: string): string | undefined => {
|
||||
if (!isReleaseVersion(version)) return undefined;
|
||||
|
||||
@@ -2,20 +2,30 @@ import { describe, expect, it } from "vitest";
|
||||
import { getReleaseTag } from "@/lib/release-version";
|
||||
|
||||
describe("release version links", () => {
|
||||
it.each(["26.09", "26.09.1", "26.09.10", "26.09-rc.1", "26.09.1-rc.2", "27.01", "0.31.0", "0.31.0-rc.2"])("links release %s", (version) =>
|
||||
expect(getReleaseTag(version)).toBe(version.startsWith("0.") ? `v${version}` : version));
|
||||
it.each([
|
||||
"26.09.0",
|
||||
"26.09.1",
|
||||
"26.09.10",
|
||||
"26.09.0-rc.1",
|
||||
"26.09.1-rc.2",
|
||||
"27.01.0",
|
||||
"0.31.0",
|
||||
"0.31.0-rc.2",
|
||||
])("links release %s", (version) => expect(getReleaseTag(version)).toBe(version.startsWith("0.") ? `v${version}` : version));
|
||||
|
||||
it.each([
|
||||
"dev",
|
||||
"manual-abcdef0",
|
||||
"v26.09",
|
||||
"26.9",
|
||||
"26.00",
|
||||
"26.13",
|
||||
"26.09.0",
|
||||
"v26.09.0",
|
||||
"26.09",
|
||||
"26.09-rc.1",
|
||||
"26.9.0",
|
||||
"26.00.0",
|
||||
"26.13.0",
|
||||
"26.09.01",
|
||||
"26.09-rc.0",
|
||||
"26.09extra",
|
||||
"26.09.0-rc.0",
|
||||
"26.09.0-dev.abc1234",
|
||||
"26.09.0extra",
|
||||
"0.31.0oops",
|
||||
])("does not link non-release %s", (version) => expect(getReleaseTag(version)).toBeUndefined());
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user