foundation/actions/semantic-release-version/action.yml

72 lines
3 KiB
YAML
Raw Normal View History

# semantic-release-version — compute the next semver from conventional commits
# (999_testing "semantic-release testing"). Composite action (see actions/node-build).
# Mirrors the canonical GitLab template (olsitec/gitlab ci_templates/release-automation/
# semantic-release.yaml): conventionalcommits preset + Olsitec's releaseRules, run as a
# `--dry-run --no-ci --tag-format '${version}'` probe. Outputs the computed version.
#
# jobs:
# version:
# runs-on: docker
# container: { image: foundation-ci:latest }
# outputs: { version: "${{ steps.sr.outputs.version }}" }
# steps:
# - uses: actions/checkout@v4
# with: { fetch-depth: 0 } # REQUIRED: full history + tags
# - id: sr
# uses: https://forge.olsitec.net/olsitec/foundation/actions/semantic-release-version@master
#
# NOTE: dry-run version compute only (the part 999_testing checks + the GitLab
# `generate-release-version` job). Publishing a Forgejo release is deferred (no
# @semantic-release/forgejo analogue yet).
name: semantic-release-version
description: Compute the next semantic-release version (dry-run) from conventional commits.
inputs:
branch:
default: master
outputs:
version:
description: "next release version (empty if the commits warrant no release)"
value: ${{ steps.compute.outputs.version }}
runs:
using: composite
steps:
- name: Write .releaserc.yaml (Olsitec conventionalcommits ruleset)
shell: bash
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
shell: bash
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"