foundation/.forgejo/workflows/reusable-semantic-release.yml
Andreas Niemann 290f48ba18
All checks were successful
CI / preflight (push) Successful in 4s
CI / typecheck (push) Successful in 15s
ecosystem-selftest / semantic-release-bumptest (push) Successful in 12s
ecosystem-selftest / eslint-gate (push) Successful in 4s
ecosystem-selftest / yamllint-gate (push) Successful in 4s
pulumi-preview / preview (push) Successful in 18s
revert(ci): reusable workflows after all — Forgejo 11 supports them
Correction to the previous commit. Forgejo 11.0.15 DOES support reusable
workflows; my earlier "not supported" was a false negative — the test caller
omitted `runs-on`, and the pre-v15 "limited" implementation REQUIRES `runs-on`
on the calling job (omitting it makes Forgejo silently schedule no run). Verified
live: a caller with `runs-on` runs green, same-repo and cross-repo (short ref);
the full-URL form fails for reusable workflows (it was only needed for composite
ACTIONS, which resolve via DEFAULT_ACTIONS_URL).

- Restore the four reusable-*.yml (on: workflow_call), the architecture the
  handover + 999_testing chose; fix the caller examples to include `runs-on`.
- Remove the composite-action layer (actions/) — single mechanism, no redundancy.
- .forgejo/workflows/README.md documents the v11 caller-`runs-on` + short-ref
  quirks (both removed by a future Forgejo v15 upgrade) and the candidate coverage.
- ecosystem-selftest paths filter back to reusable-*.yml.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-01 01:48:29 +02:00

82 lines
3.4 KiB
YAML

# reusable-semantic-release — compute the next semver from conventional commits
# (999_testing "semantic-release testing"). Mirrors the canonical GitLab template
# (olsitec/gitlab ci_templates/release-automation/semantic-release.yaml): the
# conventionalcommits preset + Olsitec's releaseRules, run as a `--dry-run --no-ci
# --tag-format '${version}'` version probe. Exposes the computed version as an output.
#
# jobs:
# version:
# runs-on: docker # REQUIRED on Forgejo 11 (pre-v15 reusable-workflow quirk; see README)
# uses: olsitec/foundation/.forgejo/workflows/reusable-semantic-release.yml@master
# build:
# needs: version
# runs-on: docker
# steps: [ run: echo "releasing ${{ needs.version.outputs.version }}" ]
#
# NOTE: dry-run only — it computes/prints the next version (the part exercised by
# 999_testing and the GitLab `generate-release-version` job). Actually PUBLISHING a
# release to Forgejo (tag + release + changelog) needs a Forgejo-side publish step
# and a token; that is deferred until the package/release flow is wired (the GitLab
# template publishes via @semantic-release/gitlab, which has no Forgejo analogue yet).
name: reusable-semantic-release
on:
workflow_call:
inputs:
branch:
type: string
default: master
outputs:
version:
description: "next release version (empty if the commits warrant no release)"
value: ${{ jobs.version.outputs.version }}
jobs:
version:
runs-on: docker
container:
image: foundation-ci:latest
outputs:
version: ${{ steps.compute.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # semantic-release needs full history + tags
- name: Write .releaserc.yaml (Olsitec conventionalcommits ruleset)
run: |
cat > .releaserc.yaml <<'EOF'
branches:
- name: ${{ inputs.branch }}
tagFormat: "${version}"
plugins:
- - "@semantic-release/commit-analyzer"
- preset: conventionalcommits
releaseRules:
- { breaking: true, release: major }
- { type: breaking, release: major }
- { type: feature, release: minor }
- { type: feat, release: minor }
- { type: fix, release: patch }
- { type: build, release: patch }
- { type: chore, release: patch }
- { type: ci, release: patch }
- { type: docs, release: patch }
- { type: perf, release: patch }
- { type: refactor, release: patch }
- { type: style, release: patch }
- { type: test, release: patch }
parserOpts:
noteKeywords: [ "BREAKING CHANGE", "BREAKING CHANGES" ]
- "@semantic-release/release-notes-generator"
EOF
- name: Compute next version (dry-run)
id: compute
run: |
out=$(semantic-release --dry-run --no-ci --tag-format '${version}' --branches "${{ inputs.branch }}" 2>&1 || true)
printf '%s\n' "$out"
ver=$(printf '%s\n' "$out" \
| grep -oiE 'next release version is [0-9]+\.[0-9]+\.[0-9]+' \
| grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | tail -1)
echo "computed next version: ${ver:-<none>}"
echo "version=$ver" >> "$GITHUB_OUTPUT"