Shared release policy, workflows and actions for john/* repos
  • Python 94.6%
  • Shell 3.4%
  • Go 2%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-11-26 07:52:59 +00:00
.forgejo/workflows feat(review): show changed static call paths before head architecture 2026-11-23 14:30:41 +00:00
actions feat(require-checks): optional wait for checks still pending 2026-11-26 07:50:36 +00:00
scripts feat(require-checks): optional wait for checks still pending 2026-11-26 07:50:36 +00:00
tests feat(require-checks): optional wait for checks still pending 2026-11-26 07:50:36 +00:00
tools chore: drop permissions blocks Forgejo ignores; document the real token model 2026-11-17 13:18:36 +00:00
.gitignore chore: ignore Python bytecode 2026-11-16 21:31:54 +00:00
README.md feat(require-checks): optional wait for checks still pending 2026-11-26 07:50:36 +00:00
yawn.json remove actions/attest (replaced by yawn request sign) 2026-11-18 21:22:08 +00:00

john/release

Shared release policy for every john/* repository that ships a versioned artifact. One script decides versions; nothing is typed or guessed by hand.

This repository is public on purpose. Forgejo Actions fetches shared workflows and actions without credentials, so private repositories can only use them from a public repository. It holds code only: no secrets, tokens or infrastructure details.

Review channel

Consumer PRs call the composite action https://code.yawn.dev/john/release/actions/review-v1@review-v1 in one trusted pull_request_target job. Pass mode: impact and read-token: ${{ secrets.CODE_REVIEW_READ_TOKEN }} only on same-repo PRs targeting protected main; do not check out PR code in this job. A separate main push/manual workflow uses mode: wiki. Do not register a PR inventory or a nested reusable workflow in either job. Required application tests and security checks remain separate. Existing SHA-pinned legacy callers remain supported.

review-v1 is a protected branch, not a moving tag. Its wrapper chooses one immutable implementation commit; that implementation pins the private CLI bundle and checksum. To promote, merge the implementation into main and verify CI first, then update the pin in a reviewed change and promote the tested wrapper through a PR into review-v1. Roll back by a reviewed pin reversal, never a force-push. Do not create a tag named review-v1 or consume the channel before protection is verified.

Version scheme

Form Channel Forgejo release
X.Y.Z-dev.N dev pre-release
X.Y.Z stable release

Tags are v + version. For one X.Y.Z, dev is the candidate channel before stable. A version is never reused and must be newer than every existing version tag.

After publishing assets, a repository can opt into actions/promote-channel. It follows the package moving tags: -dev.N → dev, suffix-free → latest. The caller cannot supply a destination; only the matching alias moves. Discover via the alias; pin the version tag or digest for builds. release.py moving-tag v1.2.3 prints latest without changing any refs.

How a release happens

  1. Open a PR that changes the version: python3 scripts/release.py bump X.Y.Z-dev.N (or ask next CHANNEL for the right number). Add release notes where release.json says.
  2. PR CI runs release-check.yml: version files agree, new version is newer than all tags, notes exist. The check also says whether merging will release.
  3. Merging the reviewed PR is the approval. On the push to main, release.yml tags that exact commit, records the Forgejo release and starts every workflow in release.json deploy at the tag. A merge that doesn't change the version releases nothing.
  4. Each deploy workflow begins with the guard action. It runs only from a release tag on main whose files match the tag, or from a manual run on main.

Test once: release only after CI passes on main

To avoid running the same tests in CI and again in the deploy, run CI on the push to main and make the release job depend on it in the same workflow. A red main then creates no tag. The deploy workflow starts with require-checks, which confirms that CI passed on exactly the tagged commit, and goes straight to building and shipping:

# .forgejo/workflows/ci.yml
on:
  pull_request:
  push:
    branches: [main]
jobs:
  checks:
    # ... the repository's tests ...
  release:
    needs: checks
    if: github.event_name == 'push' && github.ref == 'refs/heads/main'
    uses: john/release/.forgejo/workflows/release.yml@main
    with:
      service: my-service
# deploy workflow, after checkout and guard
- uses: https://code.yawn.dev/john/release/actions/require-checks@main
  with:
    token: ${{ github.token }}
    contexts: |
      CI / checks (push)

A workflow that starts at the same moment as CI (publish at a release tag) sets wait: "900": it polls while a check is pending or not yet reported and fails at once if one fails. Without it, the publish asks for a signature before CI has finished, and the signer refuses it.

The shared workflows use their own job token (github.token); callers pass no token.

Forgejo ignores permissions: (it shows a pre-execution warning and drops the field). The job token always has write access to its own repository, read-only for pull requests from forks, and nothing else. So do not add permissions: blocks; least privilege comes from:

  • running PR jobs only for same-repository PRs (head.repo.full_name == github.repository), so fork code never gets a token or secrets;
  • branch protection on main, so write-capable jobs only run reviewed code;
  • keeping secrets out of PR jobs (live jobs run on main or a release tag only);
  • Authorized Integrations with an OIDC ID token (enable-openid-connect: true) when a job needs access to another repository, instead of a personal token.

Forgejo refuses a reusable workflow that declares on.workflow_call.secrets ("workflow_call only supports keys inputs and outputs"), so none is declared. Optional secrets such as ntfy_token are still mapped by the caller and arrive as secrets.<name>. CI parses every workflow with Forgejo's own parser.

Per-repository release.json

Lists the only places that carry the version. The script edits nothing else.

{
  "version": 1,
  "files": [
    {"kind": "regex", "path": "pyproject.toml", "pattern": "^version = \"{version}\"$"},
    {"kind": "json",  "path": "package.json", "key": "version"},
    {"kind": "notes", "path": "docs/RELEASE-{version}.md"},
    {"kind": "changelog", "path": "CHANGELOG.md"}
  ],
  "deploy": ["publish.yml"]
}
  • regex: {version} appears once; the pattern must match exactly one line.
  • json: dotted key to a string; formatting is preserved.
  • notes: per-version notes file (must exist for a new version).
  • changelog: Keep a Changelog ## [X.Y.Z] section; stable needs a date.
  • deploy: workflow files started at the new tag. Each must use guard.

Script

python3 path/to/release/scripts/release.py current       # version the files carry
python3 path/to/release/scripts/release.py next dev      # next dev version
python3 path/to/release/scripts/release.py next stable --bump minor
python3 path/to/release/scripts/release.py bump 1.2.0-dev.1
python3 path/to/release/scripts/release.py check         # same as PR CI

Run from the repository root with a full clone (all tags). Standard library only.

Calling from a repository

# .forgejo/workflows/release.yml
on:
  push:
    branches: [main]
jobs:
  release:
    uses: john/release/.forgejo/workflows/release.yml@main
    with:
      service: my-service
    secrets:
      ntfy_token: ${{ secrets.NTFY_RELEASES_TOKEN }}
      ntfy_topic: ${{ secrets.NTFY_RELEASES_TOPIC }}
# first steps of each deploy job (deploy workflow: on: workflow_dispatch only)
- uses: https://github.com/actions/checkout@11d5960a326750d5838078e36cf38b85af677262
  with:
    fetch-depth: 0
    persist-credentials: false
- id: guard
  uses: https://code.yawn.dev/john/release/actions/guard@main

Use the full https://code.yawn.dev/... URL for actions; the short form resolves to github.com. Tags created by a workflow token don't trigger other workflows, so release.yml starts deploys explicitly with a workflow dispatch at the tag.

Notifications

actions/ntfy-release is the shared ntfy notification used by every repository. Its kind input picks the stage, and every stage has the same structure:

kind Success title Failure title
release (default) Released: <service> (<sha>) Release <status>: <service> (<sha>)
publish Published: <service> (<sha>) Publish <status>: <service> (<sha>)
deploy Deployed: <service> (<sha>) Deploy <status>: <service> (<sha>)

The body is always Repo: <owner/repo> (<ref>), Event: <event> · Actor: <actor> and the optional summary; the notification opens the run. Failures are priority 4.

Security scan

security.yml (reusable) scans a repository with three pinned, checksum-verified scanners on your own runners. Nothing is uploaded; only public vulnerability data is downloaded (osv.dev for dependencies; Trivy's misconfiguration checks are bundled).

Scanner Finds Blocks
gitleaks secrets in git history (on a PR: only the PR's commits) always
osv-scanner known vulnerabilities in go.mod, lockfiles, requirements at block severity or above (default high)
trivy Dockerfile and IaC misconfiguration at block severity or above
  • Pull requests: the check fails while anything blocks.
  • Nightly and manual runs on main: scan all history and keep one "Security scan" issue up to date. It is opened when something blocks, updated when the blocking set changes, and closed when clean. ntfy is notified when the issue opens or changes, or when a scanner fails, not on every run.

Call it from each repository:

# .forgejo/workflows/security.yml
name: Security
on:
  pull_request:
  schedule:
    - cron: "17 3 * * *"
  workflow_dispatch:
jobs:
  security:
    uses: john/release/.forgejo/workflows/security.yml@main
    with:
      service: my-service
    secrets:
      ntfy_token: ${{ secrets.NTFY_RELEASES_TOKEN }}
      ntfy_topic: ${{ secrets.NTFY_RELEASES_TOPIC }}

Handling findings

Fix first. When a finding is genuinely not a risk:

  • Vulnerability or misconfiguration: add it to .security.json with a reason and an expiry no more than a year away. Expired entries block again.

    {"block": "high",
     "trivy_skip": ["DS-0026"],
     "accept": [{"id": "GO-2026-1234", "reason": "not reachable: govulncheck shows no call path", "until": "2027-02-01"}]}
    
  • Secret false positive: add gitleaks' fingerprint (commit:file:rule:line, printed in the finding) to .gitleaksignore, directly under a # reason comment. A real secret must be rotated first; removing it from the latest commit is not enough.

Run locally: python3 scripts/security.py install /tmp/sec && python3 scripts/security.py scan --tools /tmp/sec --out /tmp/out.

Wiki publishing

The reusable wiki.yml and actions/wiki publish a structured Markdown tree to the calling repository's wiki, not this repository's wiki. Source remains in Git and is reviewed in PRs. No bot or personal token is needed: the job's own token is used; it can write the calling repository's wiki.

Structure and configuration

wiki/
  index.md              -> Home
  guides/setup.md       -> Guides-setup
  guides/deploy.md      -> Guides-deploy
  _sidebar.md           -> _Sidebar (optional; otherwise generated)

Folder paths are flattened into page names. Each folder becomes a navigation section; index.md is required. Use simple ASCII filenames (letters, digits, underscore, dot, hyphen), with no symlinks. Colliding page names fail validation. Relative Markdown links and reference-style link definitions are rewritten; local anchors are checked, and fenced code is preserved. Front matter is stripped. Only Markdown is supported in v1: local images/assets fail validation. External URLs are kept as-is, not fetched or checked. No author-supplied scripts run.

Optional release.json configuration (omit to use wiki/):

"wiki": {
  "source": "docs",
  "title": "My project",
  "titles": {"guides": "Getting started", "api": "API reference"},
  "home_index": true
}

titles changes navigation headings, not URLs. An optional _sidebar.md uses ordinary source-relative .md links. The generated footer records the exact source commit/ref and warns that manual wiki edits are overwritten. Publishing replaces the Markdown page set, removes stale pages, and makes no commit if the result is unchanged. It never force-pushes. Enable the wiki in repository settings; an enabled but empty wiki is initialised automatically on first publish.

Release-tied wiki (provider/library documentation)

Add wiki.yml to the repository's release.json deploy list:

"deploy": ["publish.yml", "wiki.yml"]

Add this caller workflow:

name: Wiki
on:
  workflow_dispatch:
concurrency:
  group: wiki
  cancel-in-progress: false
jobs:
  wiki:
    uses: john/release/.forgejo/workflows/wiki.yml@main
    with:
      mode: release

The existing release dispatcher starts it at the exact new release tag. Historical versions count for ordering; new releases publish only to dev or stable. A tag must be on main, match the checked-out version, and not be older than the latest local tag or the release already recorded in the wiki. Re-running an old release cannot overwrite a newer wiki. A manual run on main is an explicit maintenance/bootstrap override; its footer says refs/heads/main, not a release. The wiki is not versioned by channel and does not wait for binary publishing: publish.yml and wiki.yml are independent dispatches. A wiki failure never rolls back an artifact. Re-run the failed wiki workflow to recover.

Merge-tied wiki (internal documentation, no release required)

Use the same caller with mode: main; add push: {branches: [main]} and optional path filters for the source/config. These repositories need no version files or release.json; wiki/ is the default. Source overrides can also be passed with with: {source: docs, mode: main}. Both publishing modes reject PR/feature-branch runs and stale main commits.

PR validation / local preview

Opted-in release repos (a wiki block in release.json) automatically validate the wiki in the shared release-check action. Others can call actions/wiki with mode: check and no token. This reads the source only and never publishes. The Markdown support is deliberately limited: inline links, reference definitions, ATX headings and explicit HTML IDs. Use absolute URLs for non-wiki files.

python3 path/to/release/scripts/wiki.py check --root . --source docs
python3 path/to/release/scripts/wiki.py build /tmp/wiki-preview --root . --source docs

Build output must be outside the source repository and not another Git checkout.

Code Architecture review workflow

Call .forgejo/workflows/code-architecture.yml at a full john/release SHA and pass the same SHA as library-revision. For the Corn and Arch pilot, call it automatically on pushes to protected main with analyze: true. It waits for the exact main CI check, runs the pinned code-review graph, and reports a bounded Mermaid diagram and coverage in the job summary. It fails if the analyzer is unavailable, not if a separate wiki flag is unset. Supply a read-only CODE_REVIEW_READ_TOKEN scoped solely to john/code-review in the trusted main job; never map it into the PR caller or inherit all secrets. The credential-free PR inventory is not a CLI run.

For the MR conversation, opt the repo in by calling the separate shared .forgejo/workflows/code-review.yml from a base-branch pull_request_target workflow. Pin the same full library SHA in uses and library-revision; explicitly map code_review_read_token. The shared job always posts or updates its Mermaid comment after the required checks pass. There is no posting input or variable. If the credential, analysis, post or readback fails, the job fails; it cannot pass with a diagram only in the job summary.

The job uses only committed objects from same-repo, non-draft PRs to protected main. It never checks out or runs PR head code, and Go downloads come only from the trusted base. It waits for required checks on the current head and rechecks before writing. A failed or stale head gets no new diagram. The first activation requires the caller on main and a fresh PR event. This does not use the Wiki publisher.

name: Code Review
on:
  pull_request_target:
    branches: [main]
    types: [opened, synchronize, reopened]
concurrency:
  group: code-review-${{ github.event.pull_request.number }}
  cancel-in-progress: false
jobs:
  review:
    if: github.event.pull_request.head.repo.full_name == github.repository
    uses: john/release/.forgejo/workflows/code-review.yml@REVIEWED_SHA
    with:
      library-revision: REVIEWED_SHA
    secrets:
      code_review_read_token: ${{ secrets.CODE_REVIEW_READ_TOKEN }}

Wiki publishing is separate: publish: true in the reviewed caller is the opt-in; no repository variable is needed. Verify Wiki writer permissions before opting in. Corn has public fixed area labels; Arch stays private. Raw graphs and diagnostics are not uploaded.

Publication checks protected current main, the explicit main CI context, and repository visibility before generating and again before writing. It owns only Code-Architecture.md, refuses to overwrite an unmarked page, uses a non-force Git update for an existing Wiki, and reads back the page. It does not make Forgejo Wiki permissions per-page. Repositories that use the full-tree wiki publisher must not enable this separate writer until the two ownership models are coordinated; that publisher can remove pages that are absent from its source.

Tests

python3 -B -m unittest discover -s tests -v

Sign a release

Generated publish jobs use release:submit-release with a registered repository ID and entry, the artifact digest, and a start-only trigger secret. The action submits a versioned release_request with a fresh Forgejo OIDC token and waits for the matching terminal result of the submitted xyOps job. For signing on release_sign, that job performs the signature (and provider registry publish) before returning success. For an intake that launches a downstream workflow, acceptance does not mean that the deployment, approval, or publication finished. The deployer's release_sign event checks the release against the slot in john/arch (repository, publish workflow, release tag on main, green required checks) and signs: images with cosign, providers by GPG-signing SHA256SUMS and publishing them on registry.yawn.dev. See the cdk wiki, Generated CI.

Publish an image (actions/publish-image)

Rootless, daemonless multi-arch image build and push with Buildah. The job must run in the pinned upstream Buildah image (Ubuntu's Buildah 1.33 builds the final stage of cross-platform multi-stage builds from the wrong base):

  publish:
    runs-on: ubuntu-latest   # chaos only: zuko's Colima jobs cannot unshare user namespaces
    container:
      image: quay.io/buildah/stable@sha256:e5a33092657823b0830186ea525054cf4cdeef29b6a44833444c59d86f561f29  # v1.45.1
    steps:
      # the Buildah image has no node: check out with git, and `dnf install nodejs`
      # before any node action (e.g. forgejo/download-artifact)
      - id: image
        uses: https://code.yawn.dev/john/release/actions/publish-image@main
        with:
          image: code.yawn.dev/john/example
          tag: latest
          check-binary: /usr/sbin/nginx           # optional, per platform
          smoke: buildah run "$IMAGE" -- nginx -t  # optional, native image
          username: ${{ secrets.FORGE_REGISTRY_USER }}
          password: ${{ secrets.FORGE_REGISTRY_TOKEN }}
      # Example: the actual website registration, at the reviewed action revision.
      # The workflow must enable Forgejo OIDC and run this step on a release tag.
      - uses: https://code.yawn.dev/john/release/actions/submit-release@e3b07de98a1274c645a0c07bb2df600b962e7410
        with:
          repository-id: '9'
          entry: website_sign
          audience: yawn-sign:website
          digest: ${{ steps.image.outputs.digest }}
          trigger: ${{ secrets.RELEASE_SIGN_KEY }}
          timeout: '1450'

It refuses Buildah older than 1.45, checks the pushed index lists exactly the requested platforms, and outputs the index digest. RUN steps in a non-native stage need the runner host's qemu-user binfmt (F flag); keep target stages free of RUN (build natively with --platform=$BUILDPLATFORM and copy the result) and no emulation is needed. Run it on ubuntu-latest (chaos): ci-linux also matches zuko, whose job containers cannot create the user namespaces Buildah needs.