Merge pull request 'fix(ci): create the release-please labels before the action runs' (#23) from fix/release_please into main
release-please / release-please (push) Successful in 9s
release-please / release-please (push) Successful in 9s
Reviewed-on: #23
This commit was merged in pull request #23.
This commit is contained in:
commit
f9ddbb7e1a
3 files changed
+86
-2
No files matched your search
@@ -2,6 +2,10 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
# Manual trigger so a missed release can be replayed without waiting for
|
||||
# the next push. The job is idempotent: it tags only merged release PRs
|
||||
# that carry the pending label.
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
@@ -13,6 +17,38 @@ jobs:
|
||||
release-please:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
# release-please marks its release PR with `autorelease: pending` and
|
||||
# later finds the merged PR by that label. Gitea's label API resolves
|
||||
# names and *silently ignores unknown ones* (GetLabelIDsInRepoByNames
|
||||
# filters by name in SQL), so on a repository without these labels the
|
||||
# PR is created unlabeled, the release phase finds no merged release PR
|
||||
# and creates no tag - while the run still reports success. That is the
|
||||
# bug this step prevents: make the labels exist first, every run.
|
||||
- name: Ensure release-please labels exist
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.PR_GITEA_TOKEN }}
|
||||
run: |
|
||||
set -eu
|
||||
existing="$(curl -sS -H "Authorization: token ${GITEA_TOKEN}" \
|
||||
"${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/labels?limit=50")"
|
||||
for name in "autorelease: pending" "autorelease: tagged"; do
|
||||
if printf '%s' "$existing" | grep -qF "\"name\":\"${name}\""; then
|
||||
echo "label exists: ${name}"
|
||||
continue
|
||||
fi
|
||||
code="$(curl -sS -o /tmp/label.json -w '%{http_code}' -X POST \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d "{\"name\":\"${name}\",\"color\":\"ededed\",\"description\":\"release-please state\"}" \
|
||||
"${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/labels")"
|
||||
if [ "$code" != "201" ]; then
|
||||
echo "::error::could not create label '${name}' (HTTP ${code})"
|
||||
cat /tmp/label.json
|
||||
exit 1
|
||||
fi
|
||||
echo "created label: ${name}"
|
||||
done
|
||||
|
||||
- uses: joaquinjsb/gitea-release-please-action@v4
|
||||
with:
|
||||
# One well-scoped token for all workflow API work (see
|
||||
|
||||
@@ -48,13 +48,54 @@ feeds this machine is enforced locally by the commitizen pre-commit hook.
|
||||
3. Merge the release PR → version bumped, changelog written, tag
|
||||
`vX.Y.Z` created.
|
||||
|
||||
# The label is load-bearing (2026-10-24)
|
||||
|
||||
Steps 2 and 3 are connected by a label, not by the merge alone:
|
||||
|
||||
* release-please creates the release PR with `autorelease: pending`;
|
||||
* on the next run it lists merged PRs and keeps only those carrying that
|
||||
label; those are the releases it tags.
|
||||
|
||||
Gitea resolves label **names** in `POST /issues/{index}/labels` with
|
||||
`GetLabelIDsInRepoByNames`, which is a SQL `IN` filter: names that do not
|
||||
exist are dropped **without an error**. A repository with no labels
|
||||
therefore accepts the call, returns 200, and attaches nothing.
|
||||
|
||||
That is exactly what happened here: PRs #20 and #21 were merged as release
|
||||
PRs with no label at all, so every run found zero merged release PRs,
|
||||
created zero tags, and opened the next release PR instead — while reporting
|
||||
success. Three release PRs, no tags.
|
||||
|
||||
The workflow now creates both labels (`autorelease: pending`,
|
||||
`autorelease: tagged`) before the action runs. Idempotent: it reads the
|
||||
label list and creates only what is missing.
|
||||
|
||||
# Recovering a release that was merged without a label
|
||||
|
||||
Labels exist only from the fixed workflow onwards. PRs merged before that
|
||||
still carry none, so tagging them is a one-time manual step:
|
||||
|
||||
```sh
|
||||
# add the pending label to the merged release PRs
|
||||
for n in 20 21; do
|
||||
curl -sS -X POST -H "Authorization: token $TOKEN" \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{"labels":["autorelease: pending"]}' \
|
||||
"https://git.noelsabia.dev/api/v1/repos/CV_Website/CV_Site_Nuxt/issues/$n/labels"
|
||||
done
|
||||
```
|
||||
|
||||
Then run the release-please workflow again (it now has
|
||||
`workflow_dispatch`). It creates `v1.2.0` and `v1.3.0` from those PRs'
|
||||
bodies and replaces the label with `autorelease: tagged`.
|
||||
|
||||
# Not verified
|
||||
|
||||
* The first release PR end to end — needs at least one `feat:`/`fix:`
|
||||
commit on `main` after the workflow merge.
|
||||
* That `RELEASE_PLEASE_TOKEN_CV_SITE_NUXT` carries the `write:issue`
|
||||
scope the same way `PR_GITEA_TOKEN` needed it; the previous failure
|
||||
was an immediate API rejection consistent with a scope problem.
|
||||
* That the release phase tags correctly once the label is present. The
|
||||
label path is now fixed at the source; the first recovery run proves it.
|
||||
|
||||
# Revisit when
|
||||
|
||||
@@ -62,3 +103,6 @@ feeds this machine is enforced locally by the commitizen pre-commit hook.
|
||||
`include-component-in-tag` and `separate-pull-requests` matter).
|
||||
* A release must trigger a deploy — the workflow gains a step after
|
||||
`release_created` is set.
|
||||
* The label step breaks: if Gitea ever starts rejecting unknown label
|
||||
names, the `Ensure release-please labels exist` step will fail loudly
|
||||
instead of silently, which is the point.
|
||||
@@ -1,5 +1,9 @@
|
||||
# Update Log
|
||||
|
||||
## 2026-10-24 (release-please never tagged: the missing labels)
|
||||
|
||||
* **Fix**: [release-please.yml](../.gitea/workflows/release-please.yml) - the workflow now creates `autorelease: pending` and `autorelease: tagged` before the action runs, and gained `workflow_dispatch` so a missed release can be replayed. Root cause: release-please finds merged release PRs **by label**, and Gitea resolves label names with `GetLabelIDsInRepoByNames`, a SQL `IN` filter that silently drops unknown names. The repository had no labels at all, so PRs #20 and #21 were merged unlabeled, every run found zero merged release PRs, created zero tags and opened the next release PR instead - reporting success each time. Evidence: run 137 green, 0 tags, 0 releases, `labels: []` on #20/#21/#22, and the repo's label list empty. See [Release engineering](decisions/release-engineering.md).
|
||||
|
||||
## 2026-10-24 (release publishes an image)
|
||||
|
||||
* **Creation**: [publish-image.yml](../.gitea/workflows/publish-image.yml) - a `vX.Y.Z` tag push builds `Dockerfile` on the arm64 runner and pushes `registry.noelsabia.dev/cv_website/nuxt` as the version and `sha-<12>`, plus `latest` when that tag is the newest release. Main pushes deliberately do not build: the registry holds releases, not commits. The job uses the runner's own Docker daemon (client only in the `node:22-bookworm` container), so the act_runner needs `container.docker_host: automount`; the first step fails with that cause if it is missing. That socket is root-equivalent, so it may only sit on a label PR jobs cannot use - recorded under the trust boundary in [Publishing images to the own registry](decisions/registry-publishing.md). Repo secrets: `REGISTRY_USERNAME`, `REGISTRY_PASSWORD`.
|
||||
|
||||
Reference in new issue
Block a user