Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/release-policy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Release policy

on:
pull_request:
branches: [main, 3.x]
push:
branches: [main, 3.x]

permissions:
contents: read

jobs:
verify:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
with:
node-version: 24
- name: Install release verification dependencies
run: npm install --prefix .tmp/release-check --package-lock=false --no-audit --no-fund semantic-release@25.0.9 @semantic-release/commit-analyzer@13.0.1 yaml@2.8.1 semver@7.7.2
- name: Verify candidate release and branch range
env:
RELEASE_BRANCH: ${{ github.base_ref || github.ref_name }}
run: node hack/verify-release.mjs "$RELEASE_BRANCH"
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:
fetch-depth: 0
- uses: cycjimmy/semantic-release-action@b12c8f6015dc215fe37bc154d4ad456dd3833c90 # v6.0.0
id: semantic
with:
semantic_version: 25.0.9
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
outputs:
Expand Down
11 changes: 6 additions & 5 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

| Branch | Go module | CEL module | Support |
| --- | --- | --- | --- |
| main | github.com/flanksource/gomplate/v4 | cel.dev/cel-go | Active development |
| main (before v4 publication) | github.com/flanksource/gomplate/v3 | github.com/google/cel-go | Active v3 publication |
| main (after v4 publication) | github.com/flanksource/gomplate/v4 | cel.dev/cel-go | Active development |
| 3.x | github.com/flanksource/gomplate/v3 | github.com/google/cel-go | Security fixes only |

The v3 maintenance line starts at v3.24.90. There is no announced end-of-support date. Security patches preserve the v3 API, expression behavior, and CEL import path. Each patch must identify its advisory and use the lowest compatible fixed dependency version. Ordinary feature and dependency refreshes belong on main. Security fixes should be applied to every affected supported branch.

Renovate processes both branches. Routine updates are disabled on 3.x, while vulnerability fixes require review. OSV checks direct dependencies; daily Go vulnerability and production web dependency scans supplement them, including transitive dependencies. A scheduled scan runs from main and explicitly checks out both supported branches. Failed scans require investigation; scanner errors are not passing results.

Releases use v4.x tags from main and v3.x patch tags from 3.x. Existing downstream v3 dependency-update PR automation runs only for v3 releases. Consumers must migrate explicitly to v4.
Until main publishes v4.0.0, publish v3 security fixes from main and keep the 3.x branch synchronized with that published history. Semantic-release does not allow a maintenance branch to publish a version newer than the active main release line. After main publishes v4, v3.x patch releases are published from 3.x. Existing downstream v3 dependency-update PR automation runs only for v3 releases. Consumers must migrate explicitly to v4.

## Migrating to v4

Expand All @@ -24,9 +25,9 @@ The initial v4 migration must use a Conventional Commit with a BREAKING CHANGE f
Run from the repository root:

```sh
npm install --prefix .tmp/release-check --package-lock=false --no-audit --no-fund @semantic-release/commit-analyzer@13.0.1 yaml@2.8.1 semver@7.7.2
node hack/verify-release.mjs
npm install --prefix .tmp/release-check --package-lock=false --no-audit --no-fund semantic-release@25.0.9 @semantic-release/commit-analyzer@13.0.1 yaml@2.8.1 semver@7.7.2
node hack/verify-release.mjs main
go test ./internal/releasepolicy
```

This checks synthetic breaking and security-fix commits against the actual commit analyzer, parses the workflow YAML, and checks the v3 downstream-update guard. It does not create commits, tags, releases, or external PRs.
This checks the actual unreleased commits against the target branch's normalized semantic-release range and verifies that the candidate version matches the Go module major. Pass 3.x instead of main when validating a maintenance release. It also checks synthetic breaking and security-fix commits, workflow syntax, and the v3 downstream-update guard. The Release policy workflow runs this check before PRs are merged. It does not create commits, tags, releases, or external PRs.
55 changes: 55 additions & 0 deletions hack/verify-release.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,62 @@ const require = createRequire(new URL("../.tmp/release-check/package.json", impo
const { parse } = require("yaml");
const semver = require("semver");
const { analyzeCommits } = await import(require.resolve("@semantic-release/commit-analyzer"));
const normalize = await import(require.resolve("semantic-release/lib/branches/normalize.js"));
const definitions = await import(require.resolve("semantic-release/lib/definitions/branches.js"));
const config = parse(readFileSync(".releaserc", "utf8"));
const options = config.plugins[0][1];
const logger = { log() {} };
const git = (...args) => execFileSync("git", args, { encoding: "utf8" }).trim();
const target = process.argv[2] ?? "main";
const revision = process.argv[3] ?? "HEAD";
const branches = config.branches.map((branch) => {
const options = typeof branch === "string" ? { name: branch } : branch;
const tags = git("tag", "--merged", `origin/${options.name}`).split("\n")
.map((gitTag) => ({ gitTag, version: semver.valid(gitTag), channels: [null] }))
.filter(({ version }) => version && !semver.prerelease(version));
return { ...options, tags };
});
function normalizeBranches(branches) {
const groups = {
maintenance: branches.filter(definitions.maintenance.filter),
release: branches.filter(definitions.release.filter),
};
return [...normalize.maintenance(groups), ...normalize.release(groups)];
}
const normalized = normalizeBranches(branches);
const fixtureTags = (versions) => versions.map((version) => ({ version, gitTag: `v${version}`, channels: [null] }));
for (const scenario of [
{ main: ["3.24.90"], maintenance: ["3.24.90"], target: "main", candidate: "3.24.91", allowed: true },
{ main: ["3.24.90"], maintenance: ["3.24.90"], target: "3.x", candidate: "3.24.91", allowed: false },
{ main: ["3.24.90"], maintenance: ["3.24.90"], target: "main", candidate: "4.0.0", allowed: true },
{ main: ["3.24.90", "3.24.91", "4.0.0"], maintenance: ["3.24.90", "3.24.91"], target: "3.x", candidate: "3.24.92", allowed: true },
]) {
const fixtureBranches = branches.map((branch) => ({ ...branch,
tags: fixtureTags(branch.name === "main" ? scenario.main : scenario.maintenance),
}));
const branch = normalizeBranches(fixtureBranches).find(({ name }) => name === scenario.target);
assert.equal(semver.satisfies(scenario.candidate, branch.range), scenario.allowed, JSON.stringify(scenario));
}
const branch = normalized.find(({ name }) => name === target);
assert(branch, `Unknown release branch: ${target}`);
const lastVersion = semver.rsort(branch.tags.map(({ version }) => version))[0];
assert(lastVersion, `No published release found on ${target}`);
const lastTag = branch.tags.find(({ version }) => version === lastVersion).gitTag;
const commits = git("log", "--format=%B%x00", `${lastTag}..${revision}`).split("\0")
.map((message, index) => ({ hash: String(index), message: message.trim() }))
.filter(({ message }) => message);
const kind = await analyzeCommits(options, { commits, logger, cwd: process.cwd() });
if (kind) {
const candidate = semver.inc(lastVersion, kind);
assert(semver.satisfies(candidate, branch.range),
`${target} cannot publish ${candidate}: allowed range is ${branch.range}. Publish v3 fixes from main until main publishes v4.`);
const moduleMajor = readFileSync("go.mod", "utf8").match(/^module github.com\/flanksource\/gomplate\/v(\d+)$/m);
assert(moduleMajor, "Cannot determine gomplate module major");
assert.equal(semver.major(candidate), Number(moduleMajor[1]), "Release major must match the Go module");
process.stdout.write(`${target} can publish ${candidate} (${branch.range})\n`);
} else {
process.stdout.write(`${target}: no unreleased conventional commits\n`);
}
for (const [message, expected] of [
["feat!: migrate gomplate and CEL module paths\n\nBREAKING CHANGE: use /v4 and cel.dev/cel-go imports", "major"],
["fix(security): remediate dependency advisory", "patch"],
Expand All @@ -22,6 +75,8 @@ for (const file of ["test.yml", "lint.yml", "web.yml", "release.yml", "security.
assert(workflow.on.push.branches.includes("3.x"), file);
}
const release = parse(readFileSync(".github/workflows/release.yml", "utf8"));
assert.equal(release.jobs["semantic-release"].steps.find(({ id }) => id === "semantic").with.semantic_version,
require("semantic-release/package.json").version, "Verification and publishing must use the same semantic-release version");
for (const file of readdirSync(".github/workflows").filter(file => file.endsWith(".yml"))) {
const workflow = parse(readFileSync(".github/workflows/" + file, "utf8"));
for (const job of Object.values(workflow.jobs)) {
Expand Down
Loading