Compare commits
11
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
42b07e9ab9 | ||
|
|
fdce59d77d | ||
|
|
e23f8d2618 | ||
|
|
a80c9ebf02 | ||
|
|
b1082b52fe | ||
|
|
ac2f919bf5 | ||
|
|
90ef58a8cb | ||
|
|
06e1d24977 | ||
|
|
7ffc6d73b6 | ||
|
|
1860e88156 | ||
|
|
93fcd4127c |
No files matched your search
@@ -17,6 +17,12 @@ jobs:
|
|||||||
release-please:
|
release-please:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
# The reconcile step below runs a file from this repository. The
|
||||||
|
# release-please action clones into its own temp directory and does not
|
||||||
|
# check the workspace out, so without this step the job fails with
|
||||||
|
# "Cannot find module .../scripts/reconcile-release-please.mjs".
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
# release-please marks its release PR with `autorelease: pending` and
|
# release-please marks its release PR with `autorelease: pending` and
|
||||||
# later finds the merged PR by that label. Gitea's label API resolves
|
# later finds the merged PR by that label. Gitea's label API resolves
|
||||||
# names and *silently ignores unknown ones* (GetLabelIDsInRepoByNames
|
# names and *silently ignores unknown ones* (GetLabelIDsInRepoByNames
|
||||||
@@ -49,6 +55,21 @@ jobs:
|
|||||||
echo "created label: ${name}"
|
echo "created label: ${name}"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# The label fix above is not retroactive. PR #22 was merged with
|
||||||
|
# `autorelease: pending` but its head branch had already been deleted,
|
||||||
|
# so the action reports `Bad branch name: refs/pull/22/head`, creates no
|
||||||
|
# tag and leaves the label behind. Every later run then aborts with
|
||||||
|
# "There are untagged, merged release PRs outstanding" and never opens a
|
||||||
|
# new release PR - green, no tags. This step reconciles that state before
|
||||||
|
# the action runs: mark a pending PR tagged when its tag already exists,
|
||||||
|
# or recreate the tag when the head branch is gone and release-please
|
||||||
|
# therefore cannot. See scripts/reconcile-release-please.mjs and
|
||||||
|
# OKF_Nuxt/decisions/release-engineering.md.
|
||||||
|
- name: Reconcile stale release-please state
|
||||||
|
env:
|
||||||
|
GITEA_TOKEN: ${{ secrets.PR_GITEA_TOKEN }}
|
||||||
|
run: node scripts/reconcile-release-please.mjs
|
||||||
|
|
||||||
- uses: joaquinjsb/gitea-release-please-action@v4
|
- uses: joaquinjsb/gitea-release-please-action@v4
|
||||||
with:
|
with:
|
||||||
# One well-scoped token for all workflow API work (see
|
# One well-scoped token for all workflow API work (see
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
".": "1.4.0"
|
".": "1.5.0"
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,22 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## [1.5.0](https://git.noelsabia.dev/CV_Website/CV_Site_Nuxt/compare/v1.4.0...v1.5.0) (2026-10-31)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **ci:** replace opencode review with PR-Agent ([c626cc9](https://git.noelsabia.dev/CV_Website/CV_Site_Nuxt/commit/c626cc9c1dc7db94e645d33eab3c7c7b9a860438))
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **ci:** check out the repo before the release-please reconcile step ([90ef58a](https://git.noelsabia.dev/CV_Website/CV_Site_Nuxt/commit/90ef58a8cb8917d547947ae0046a56b8be882114))
|
||||||
|
* **ci:** point changelog compare links at our Gitea ([a2259df](https://git.noelsabia.dev/CV_Website/CV_Site_Nuxt/commit/a2259df877615c34311a41c1a218ff4bea169d72))
|
||||||
|
* **ci:** repair PR-Agent model routing ([a43134a](https://git.noelsabia.dev/CV_Website/CV_Site_Nuxt/commit/a43134ad83bece7670543e557f40407892dbf48e))
|
||||||
|
* **ci:** validate the release tag and query pending PRs by label ([7ffc6d7](https://git.noelsabia.dev/CV_Website/CV_Site_Nuxt/commit/7ffc6d73b607d697a6086a6fe17d077ffc50d5c2))
|
||||||
|
* **deps:** sync lockfile and pin patched seroval ([3eac732](https://git.noelsabia.dev/CV_Website/CV_Site_Nuxt/commit/3eac73255ff5f5b34233576fc8cbcfa97a50d3dc))
|
||||||
|
* **deps:** unblock the dependency audit ([e0c69c1](https://git.noelsabia.dev/CV_Website/CV_Site_Nuxt/commit/e0c69c1b7727a65b240e5bcab91dad98cd80fdec))
|
||||||
|
|
||||||
## [1.4.0](https://github.com/CV_Website/CV_Site_Nuxt/compare/v1.3.0...v1.4.0) (2026-10-27)
|
## [1.4.0](https://github.com/CV_Website/CV_Site_Nuxt/compare/v1.3.0...v1.4.0) (2026-10-27)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,9 @@ sources:
|
|||||||
- id: workflow
|
- id: workflow
|
||||||
resource: .gitea/workflows/release-please.yml
|
resource: .gitea/workflows/release-please.yml
|
||||||
title: release-please workflow
|
title: release-please workflow
|
||||||
|
- id: reconcile
|
||||||
|
resource: scripts/reconcile-release-please.mjs
|
||||||
|
title: release-please state reconciliation
|
||||||
---
|
---
|
||||||
|
|
||||||
# Decision
|
# Decision
|
||||||
@@ -97,6 +100,86 @@ confirmed by comparison, not inference: while `fix/release_please` still
|
|||||||
existed, PR #23 reported `head.ref = fix/release_please`; every PR whose
|
existed, PR #23 reported `head.ref = fix/release_please`; every PR whose
|
||||||
branch was gone reported `refs/pull/<n>/head`.
|
branch was gone reported `refs/pull/<n>/head`.
|
||||||
|
|
||||||
|
# A pending label outlives the branch and blocks every later release (2026-10-31)
|
||||||
|
|
||||||
|
Flipping `default_delete_branch_after_merge` to `false` only protects
|
||||||
|
branches deleted *after* the change. PR #22's branch was already gone, so
|
||||||
|
its `head.ref` stayed `refs/pull/22/head` and its `autorelease: pending`
|
||||||
|
label stayed attached. Run 143 (task 475, 2026-10-27, the run immediately
|
||||||
|
after #22 merged) shows the full deadlock:
|
||||||
|
|
||||||
|
```
|
||||||
|
❯ Found pull request #22: 'chore: release main'
|
||||||
|
✖ Bad branch name: refs/pull/22/head
|
||||||
|
...
|
||||||
|
✔ Building candidate release pull request for path: .
|
||||||
|
❯ Found pull request #22: 'chore: release main'
|
||||||
|
⚠ There are untagged, merged release PRs outstanding - aborting
|
||||||
|
::set-output:: prs_created=false
|
||||||
|
::set-output:: releases_created=false
|
||||||
|
```
|
||||||
|
|
||||||
|
The first block fails the tagging phase. The second finds the same
|
||||||
|
still-pending PR and aborts the propose phase, so no new release PR is
|
||||||
|
even opened. Every later run (145, 148, 151, 153, 162, 164, 167) has the
|
||||||
|
same shape. The hand-created `v1.4.0` tag restores the baseline (`found:
|
||||||
|
v1.4.0`) but does not clear the label, so it does not break the
|
||||||
|
deadlock. This is the current reason the pipeline is still healthy-looking
|
||||||
|
and tagless.
|
||||||
|
|
||||||
|
The workflow now reconciles that state before the action runs
|
||||||
|
(`scripts/reconcile-release-please.mjs`):
|
||||||
|
|
||||||
|
* merged + `autorelease: pending` + a tag already at the merge commit ->
|
||||||
|
replace the label with `autorelease: tagged`;
|
||||||
|
* merged + `autorelease: pending` + head branch gone + no tag -> create
|
||||||
|
the tag from the version recorded in the manifest at the merge commit
|
||||||
|
(the exact tag release-please would have made), then swap the label;
|
||||||
|
* merged + `autorelease: pending` + head branch still present -> leave
|
||||||
|
it; release-please tags it in the same run.
|
||||||
|
|
||||||
|
The step is idempotent and runs on every push to `main` and every manual
|
||||||
|
dispatch, so a deleted branch cannot silently poison the release pipeline
|
||||||
|
again. #20 and #21 are not labelled pending, so they do not block; their
|
||||||
|
tags remain the one-time manual recovery in the table below.
|
||||||
|
|
||||||
|
Two details keep the reconciliation from suppressing a real release:
|
||||||
|
|
||||||
|
* pending PRs are fetched through the `autorelease: pending` label filter,
|
||||||
|
not by paging every closed PR, so concurrent PR closes cannot shift a
|
||||||
|
page and hide one;
|
||||||
|
* a tag at the merge commit counts only when its name is exactly
|
||||||
|
`v<manifest version>`. A CI or annotation tag on the same commit is
|
||||||
|
logged and ignored, and the release tag is still created.
|
||||||
|
|
||||||
|
# The release phase drops the PR on a component mismatch (2026-10-31)
|
||||||
|
|
||||||
|
With the branch kept and the label reconciled, PR #35 was still not
|
||||||
|
tagged. Run 181 (task 578, immediately after #35 merged) shows why:
|
||||||
|
|
||||||
|
```
|
||||||
|
❯ Found pull request #35: 'chore: release main'
|
||||||
|
...
|
||||||
|
⚠ PR component: undefined does not match configured component: CV_Site_Frontend
|
||||||
|
...
|
||||||
|
⚠ There are untagged, merged release PRs outstanding - aborting
|
||||||
|
```
|
||||||
|
|
||||||
|
`buildRelease()` compares the component parsed from the merged PR with the
|
||||||
|
strategy's component when the release body contains one component and that
|
||||||
|
component is empty. `include-component-in-tag: false` makes
|
||||||
|
`getComponent()` return an empty string, so the release PR is
|
||||||
|
`chore: release main` with an empty component and the branch is
|
||||||
|
`release-please--branches--main` (parsed component: undefined). But
|
||||||
|
`getBranchComponent()` ignores `include-component-in-tag` and returns
|
||||||
|
`package-name` - here `CV_Site_Frontend`. The two never match, so the
|
||||||
|
release is dropped before the tag is created.
|
||||||
|
|
||||||
|
The fix is to remove `package-name` from the package config. The strategy
|
||||||
|
component is then empty as well, the comparison matches, and the tag is
|
||||||
|
created. Nothing else changes: the changelog headings are already
|
||||||
|
version-only (`## [1.5.0]`), not component-prefixed.
|
||||||
|
|
||||||
# Recovering the versions that never got a tag
|
# Recovering the versions that never got a tag
|
||||||
|
|
||||||
The label alone cannot recover them — #20, #21 and #22 all lost their head
|
The label alone cannot recover them — #20, #21 and #22 all lost their head
|
||||||
@@ -121,8 +204,14 @@ whole history.
|
|||||||
|
|
||||||
# Not verified
|
# Not verified
|
||||||
|
|
||||||
* That the release phase tags correctly once the head branch survives a
|
* That the release phase now tags #35 after the component fix. The previous
|
||||||
merge. The next release cycle proves it.
|
run (181) kept the branch but dropped the release on the component
|
||||||
|
mismatch, so the next run is the proof.
|
||||||
|
* That the reconcile step's tag-creation fallback works with a live
|
||||||
|
token. Only the tag-already-exists path was exercised, in dry-run,
|
||||||
|
against the live PR #22. The fallback is written from the same Gitea
|
||||||
|
API shapes (`POST /tags`, `PUT /issues/{index}/labels`) the rest of the
|
||||||
|
workflow uses.
|
||||||
* That `RELEASE_PLEASE_TOKEN_CV_SITE_NUXT` carries the `write:issue`
|
* That `RELEASE_PLEASE_TOKEN_CV_SITE_NUXT` carries the `write:issue`
|
||||||
scope the same way `PR_GITEA_TOKEN` needed it; the previous failure
|
scope the same way `PR_GITEA_TOKEN` needed it; the previous failure
|
||||||
was an immediate API rejection consistent with a scope problem.
|
was an immediate API rejection consistent with a scope problem.
|
||||||
|
|||||||
@@ -1,5 +1,22 @@
|
|||||||
# Update Log
|
# Update Log
|
||||||
|
|
||||||
|
## 2026-10-31 (release-please component mismatch: no v1.5.0 tag)
|
||||||
|
|
||||||
|
* **Fix**: [release-please-config.json](../release-please-config.json) - removed `package-name: CV_Site_Frontend`. With `include-component-in-tag: false` the strategy component and the release PR body component are empty, but `getBranchComponent()` still returned `package-name`; the release phase logged `PR component: undefined does not match configured component: CV_Site_Frontend` and returned before creating the tag. The component now matches, so the next run should tag #35.
|
||||||
|
* **Evidence**: run 181 (task 578, immediately after #35 merged) - the reconcile step correctly left #35 for the action because its branch survived, then the action found #35, hit the component mismatch and aborted with "There are untagged, merged release PRs outstanding". The earlier label/branch fixes were correct; this was the remaining check.
|
||||||
|
* **Expected result**: the run after this merge creates `v1.5.0` at the #35 merge commit (`a80c9eb`), marks #35 `autorelease: tagged`, and stops opening duplicate release PRs.
|
||||||
|
|
||||||
|
## 2026-10-31 (release-please reconcile step needs a checkout)
|
||||||
|
|
||||||
|
* **Fix**: [release-please.yml](../.gitea/workflows/release-please.yml) - added `actions/checkout@v4` before the reconcile step. The job had no checkout because the release-please action clones the repository into its own temp directory; the new step runs `scripts/reconcile-release-please.mjs` from the workspace, so the first post-merge run failed with `Cannot find module '/workspace/CV_Website/CV_Site_Nuxt/scripts/reconcile-release-please.mjs'` (task 571). The checkout supplies the file; the action still uses its own temp clone for the release branch.
|
||||||
|
|
||||||
|
## 2026-10-31 (PR #33 second review: release tag validated, pending PRs queried by label)
|
||||||
|
|
||||||
|
* **Fix**: [reconcile-release-please.mjs](../scripts/reconcile-release-please.mjs) - both PR-Agent findings were confirmed. A tag at the merge commit now counts only when it is exactly `v<manifest version>`; a foreign CI/annotation tag is logged and ignored. Pending release PRs are fetched through the `autorelease: pending` label filter instead of paging every closed PR, so a concurrent close cannot shift a page and hide one.
|
||||||
|
* **Guard**: a merged PR without `merge_commit_sha`, or a manifest without a version, now fails loudly instead of producing `vundefined`.
|
||||||
|
* **Verified locally**: dry-run against the live repo still matches #22 to `v1.4.0`; `pnpm lint`, `pnpm typecheck`, `pnpm build` and `pnpm audit --prod --audit-level moderate` pass on the rebased tree.
|
||||||
|
* **Known issue**: PR-Agent's `/describe` posts `Failed to update PR description`; the bot token has `write:issue` but not the PR-edit scope. Recorded with the fix in [PR-Agent operations](pr-agent.md).
|
||||||
|
|
||||||
## 2026-10-31 (registry host corrected: Gitea's built-in registry on git.noelsabia.dev)
|
## 2026-10-31 (registry host corrected: Gitea's built-in registry on git.noelsabia.dev)
|
||||||
|
|
||||||
* **Correction**: `registry.noelsabia.dev` is gone from the documentation and the workflow. Gitea's built-in container registry is served on the Gitea hostname itself, so the image is **`git.noelsabia.dev/cv_website/nuxt:<tag>`** ([docs.gitea.com/usage/packages/container](https://docs.gitea.com/usage/packages/container/)). `registry.noelsabia.dev` was a separate hostname set up before that was known; the server-side setup is being reverted. No separate registry, no extra hostname, no extra certificate - Gitea already provides this by default.
|
* **Correction**: `registry.noelsabia.dev` is gone from the documentation and the workflow. Gitea's built-in container registry is served on the Gitea hostname itself, so the image is **`git.noelsabia.dev/cv_website/nuxt:<tag>`** ([docs.gitea.com/usage/packages/container](https://docs.gitea.com/usage/packages/container/)). `registry.noelsabia.dev` was a separate hostname set up before that was known; the server-side setup is being reverted. No separate registry, no extra hostname, no extra certificate - Gitea already provides this by default.
|
||||||
|
|||||||
@@ -52,6 +52,16 @@ access is a separate change.
|
|||||||
it, Gitea's default egress policy refuses deliveries to the Docker
|
it, Gitea's default egress policy refuses deliveries to the Docker
|
||||||
network.
|
network.
|
||||||
|
|
||||||
|
# Known issue: "Failed to update PR description"
|
||||||
|
|
||||||
|
On PR #33 (2026-10-31) `/describe` posted `Failed to update PR description`
|
||||||
|
before the reviewer guide. Comments work because the bot token has
|
||||||
|
`write:issue`; editing the PR body is a repository-route write and needs
|
||||||
|
`write:repository` as well. Add that scope to the `pr-agent` token and
|
||||||
|
restart the service, or remove `/describe` from `GITEA__PR_COMMANDS` if the
|
||||||
|
description update is not wanted. The review comment is still posted; this
|
||||||
|
affects only the description sync.
|
||||||
|
|
||||||
# Commands
|
# Commands
|
||||||
|
|
||||||
| Trigger | What runs |
|
| Trigger | What runs |
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "nuxt-app",
|
"name": "nuxt-app",
|
||||||
"version": "1.4.0",
|
"version": "1.5.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"private": true,
|
"private": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|||||||
Generated
+970
-1089
File diff suppressed because it is too large.
Load diff
@@ -56,3 +56,8 @@ minimumReleaseAgeExclude:
|
|||||||
- '@rollup/rollup-openharmony-arm64@4.64.8'
|
- '@rollup/rollup-openharmony-arm64@4.64.8'
|
||||||
- '@rollup/rollup-win32-ia32-msvc@4.64.8'
|
- '@rollup/rollup-win32-ia32-msvc@4.64.8'
|
||||||
- '@nuxt/icon@2.6.0'
|
- '@nuxt/icon@2.6.0'
|
||||||
|
permissions:
|
||||||
|
'@nuxtjs/seo':
|
||||||
|
skills:
|
||||||
|
dirs:
|
||||||
|
- .agents/skills
|
||||||
@@ -6,7 +6,6 @@
|
|||||||
"changelog-host": "https://git.noelsabia.dev",
|
"changelog-host": "https://git.noelsabia.dev",
|
||||||
"packages": {
|
"packages": {
|
||||||
".": {
|
".": {
|
||||||
"package-name": "CV_Site_Frontend",
|
|
||||||
"changelog-path": "CHANGELOG.md",
|
"changelog-path": "CHANGELOG.md",
|
||||||
"extra-files": [],
|
"extra-files": [],
|
||||||
"versioning": "default"
|
"versioning": "default"
|
||||||
|
|||||||
@@ -0,0 +1,205 @@
|
|||||||
|
// Repairs the release-please state that its Gitea fork cannot recover from.
|
||||||
|
//
|
||||||
|
// Why this exists (evidence in OKF_Nuxt/decisions/release-engineering.md):
|
||||||
|
//
|
||||||
|
// Gitea rewrites a merged PR's `head.ref` to `refs/pull/<n>/head` when the
|
||||||
|
// head branch is deleted. The fork parses that field as the release branch,
|
||||||
|
// logs `Bad branch name`, creates no tag - and still exits successfully.
|
||||||
|
// The merged PR keeps `autorelease: pending`, so every later run aborts with
|
||||||
|
// `There are untagged, merged release PRs outstanding` and opens no new
|
||||||
|
// release PR. That is a permanent deadlock, not a transient failure.
|
||||||
|
//
|
||||||
|
// This script runs before the action and reconciles the state:
|
||||||
|
//
|
||||||
|
// * a merged pending PR whose merge commit already has the expected
|
||||||
|
// `v<manifest version>` tag -> swap `autorelease: pending` for
|
||||||
|
// `autorelease: tagged` (the release exists, only the label is stale);
|
||||||
|
// * a merged pending PR whose head branch is gone and has no expected tag
|
||||||
|
// -> create the tag from the version recorded in the manifest at that
|
||||||
|
// merge commit. This is exactly the tag release-please would have made if
|
||||||
|
// the branch had survived; without it the PR blocks every future release;
|
||||||
|
// * a merged pending PR whose head branch still exists -> leave it alone,
|
||||||
|
// release-please tags it in the same run.
|
||||||
|
//
|
||||||
|
// Pending PRs are looked up by the label itself, not by paging through every
|
||||||
|
// closed PR: the set is tiny (normally zero or one) and cannot race with PRs
|
||||||
|
// closing while the pages are being read.
|
||||||
|
//
|
||||||
|
// Run locally against the public API with:
|
||||||
|
// DRY_RUN=1 node scripts/reconcile-release-please.mjs
|
||||||
|
// Reads work unauthenticated for a public repository; writes are skipped.
|
||||||
|
|
||||||
|
const API_URL = process.env.GITHUB_API_URL
|
||||||
|
const REPOSITORY = process.env.GITHUB_REPOSITORY
|
||||||
|
const TOKEN = process.env.GITEA_TOKEN
|
||||||
|
const DRY_RUN = process.env.DRY_RUN === '1' || process.argv.includes('--dry-run')
|
||||||
|
|
||||||
|
const PENDING = 'autorelease: pending'
|
||||||
|
const TAGGED = 'autorelease: tagged'
|
||||||
|
const MANIFEST = '.release-please-manifest.json'
|
||||||
|
|
||||||
|
if (!API_URL || !REPOSITORY) {
|
||||||
|
console.error('::error::GITHUB_API_URL and GITHUB_REPOSITORY must be set')
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
if (!TOKEN && !DRY_RUN) {
|
||||||
|
console.error('::error::GITEA_TOKEN is required (or set DRY_RUN=1)')
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
const repoUrl = `${API_URL}/repos/${REPOSITORY}`
|
||||||
|
|
||||||
|
const api = async (path, init = {}) => {
|
||||||
|
const response = await fetch(`${repoUrl}${path}`, {
|
||||||
|
...init,
|
||||||
|
headers: {
|
||||||
|
Accept: 'application/json',
|
||||||
|
...(TOKEN ? { Authorization: `token ${TOKEN}` } : {}),
|
||||||
|
...(init.headers ?? {}),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
const body = await response.text()
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(`${init.method ?? 'GET'} ${path} -> HTTP ${response.status}: ${body.slice(0, 300)}`)
|
||||||
|
}
|
||||||
|
return body ? JSON.parse(body) : null
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gitea caps page size at 50. The label-filtered issue list is normally one
|
||||||
|
// page; loop anyway so a backlog of stale pending PRs is still reconciled.
|
||||||
|
const listAll = async (path, params = {}) => {
|
||||||
|
const items = []
|
||||||
|
for (let page = 1; ; page++) {
|
||||||
|
const query = new URLSearchParams({ ...params, limit: '50', page: String(page) })
|
||||||
|
const batch = await api(`${path}?${query}`)
|
||||||
|
items.push(...batch)
|
||||||
|
if (batch.length < 50) return items
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const replaceLabels = async (number, labels) => {
|
||||||
|
if (DRY_RUN) {
|
||||||
|
console.log(`[dry-run] #${number}: labels -> ${labels.join(', ')}`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
await api(`/issues/${number}/labels`, {
|
||||||
|
method: 'PUT',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({ labels }),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const createTag = async (name, sha) => {
|
||||||
|
if (DRY_RUN) {
|
||||||
|
console.log(`[dry-run] create tag ${name} at ${sha}`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
await api('/tags', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({ tag_name: name, target: sha, message: `Release ${name}` }),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const versionAt = async (sha) => {
|
||||||
|
const file = await api(`/contents/${MANIFEST}?ref=${sha}`)
|
||||||
|
if (!file?.content) throw new Error(`no manifest content at ${sha}`)
|
||||||
|
const manifest = JSON.parse(Buffer.from(file.content, 'base64').toString('utf8'))
|
||||||
|
// Single-package repository: the root path is ".". Keep a fallback so a
|
||||||
|
// future second package cannot silently produce `vundefined`.
|
||||||
|
const version = manifest['.'] ?? Object.values(manifest)[0]
|
||||||
|
if (!version) throw new Error(`manifest at ${sha} has no version`)
|
||||||
|
return version
|
||||||
|
}
|
||||||
|
|
||||||
|
const run = async () => {
|
||||||
|
// One tag can point at the merge commit for a non-release reason (CI
|
||||||
|
// tooling, a manual annotation). Only the `v<manifest version>` tag proves
|
||||||
|
// the release exists; every other tag at that commit is ignored.
|
||||||
|
const tags = await listAll('/tags')
|
||||||
|
const tagsAtSha = new Map()
|
||||||
|
const tagSha = new Map()
|
||||||
|
for (const tag of tags) {
|
||||||
|
const sha = tag.commit?.sha
|
||||||
|
if (!sha) continue
|
||||||
|
if (!tagsAtSha.has(sha)) tagsAtSha.set(sha, [])
|
||||||
|
tagsAtSha.get(sha).push(tag.name)
|
||||||
|
tagSha.set(tag.name, sha)
|
||||||
|
}
|
||||||
|
|
||||||
|
const pendingIssues = await listAll('/issues', {
|
||||||
|
state: 'closed',
|
||||||
|
type: 'pulls',
|
||||||
|
labels: PENDING,
|
||||||
|
})
|
||||||
|
if (pendingIssues.length === 0) {
|
||||||
|
console.log('No merged release PR is pending - nothing to reconcile.')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const failures = []
|
||||||
|
const versionCache = new Map()
|
||||||
|
|
||||||
|
for (const issue of pendingIssues) {
|
||||||
|
const pull = await api(`/pulls/${issue.number}`)
|
||||||
|
if (!pull.merged_at) continue
|
||||||
|
|
||||||
|
const mergeSha = pull.merge_commit_sha
|
||||||
|
if (!mergeSha) {
|
||||||
|
failures.push(`#${pull.number}: merged PR has no merge_commit_sha`)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
const headRef = pull.head?.ref ?? ''
|
||||||
|
const branchGone = headRef.startsWith('refs/pull/') || headRef === ''
|
||||||
|
const labels = (pull.labels ?? []).map(label => label.name)
|
||||||
|
if (!versionCache.has(mergeSha)) versionCache.set(mergeSha, await versionAt(mergeSha))
|
||||||
|
const expectedTag = `v${versionCache.get(mergeSha)}`
|
||||||
|
const tagsHere = tagsAtSha.get(mergeSha) ?? []
|
||||||
|
|
||||||
|
if (tagsHere.includes(expectedTag)) {
|
||||||
|
console.log(`#${pull.number}: ${expectedTag} already points at merge commit ${mergeSha} - marking as tagged`)
|
||||||
|
const next = labels.filter(name => name !== PENDING)
|
||||||
|
if (!next.includes(TAGGED)) next.push(TAGGED)
|
||||||
|
await replaceLabels(pull.number, next)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tagsHere.length > 0) {
|
||||||
|
console.log(`#${pull.number}: ignoring non-release tag(s) at merge commit: ${tagsHere.join(', ')}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!branchGone) {
|
||||||
|
console.log(`#${pull.number}: head branch ${headRef} still exists - leaving it for release-please to tag`)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// The branch is gone and the expected tag is missing, so release-please
|
||||||
|
// will never get past `Bad branch name` for this PR. Recreate the tag it
|
||||||
|
// should have made, using the version the merged release PR wrote into the
|
||||||
|
// manifest.
|
||||||
|
try {
|
||||||
|
if (tagSha.has(expectedTag)) {
|
||||||
|
throw new Error(`${expectedTag} already exists at ${tagSha.get(expectedTag)}, not at merge commit ${mergeSha}; refusing to move a release tag`)
|
||||||
|
}
|
||||||
|
console.log(`#${pull.number}: head branch is gone (${headRef}) - creating ${expectedTag} at ${mergeSha}`)
|
||||||
|
await createTag(expectedTag, mergeSha)
|
||||||
|
const next = labels.filter(name => name !== PENDING)
|
||||||
|
if (!next.includes(TAGGED)) next.push(TAGGED)
|
||||||
|
await replaceLabels(pull.number, next)
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
failures.push(`#${pull.number}: ${error.message}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (failures.length > 0) {
|
||||||
|
for (const failure of failures) console.error(`::error::${failure}`)
|
||||||
|
console.error('::error::release-please state is unrecoverable automatically; repair the PR/tag by hand before the next release')
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
run().catch((error) => {
|
||||||
|
console.error(`::error::${error.message}`)
|
||||||
|
process.exit(1)
|
||||||
|
})
|
||||||
Reference in new issue
Block a user