mirror of
https://github.com/microsoft/BCQuality.git
synced 2026-08-06 09:26:52 +01:00
Derive release version from git tags, drop VERSION file
This commit is contained in:
parent
f6de288171
commit
862110748b
3 changed files with 39 additions and 21 deletions
54
.github/workflows/release-version.yml
vendored
54
.github/workflows/release-version.yml
vendored
|
|
@ -1,21 +1,26 @@
|
||||||
# Cuts a BCQuality content release on demand (roughly monthly), NOT on every
|
# Cuts a BCQuality content release on demand (roughly monthly), NOT on every
|
||||||
# commit. Run this workflow manually once the `main` content is ready to be
|
# commit. Run this workflow manually once the `main` content is ready, and choose
|
||||||
# consumed by a new engine release.
|
# whether to bump the minor (usual periodic content update) or the major
|
||||||
|
# (breaking change).
|
||||||
#
|
#
|
||||||
# The release version is a `major.minor` value in the repo-root VERSION file.
|
# The version is a `major.minor` value derived from existing git tags — there is
|
||||||
# This workflow tags the current commit as `v{VERSION}` and refuses to re-tag an
|
# no VERSION file. The minor is a monotonic counter: it only ever increments and
|
||||||
# existing version, so bumping VERSION is the deliberate act that starts a new
|
# never resets, even across a major bump, so it uniquely identifies a release.
|
||||||
# release. The minor is a monotonic counter: bump it (only ever increment, never
|
# This workflow computes the next version and tags the current commit as
|
||||||
# reset) for the usual ~monthly content release; bump the major for a breaking
|
# `v{major}.{minor}`.
|
||||||
# change but keep incrementing the minor across it. Because the minor is never
|
|
||||||
# reused, it uniquely identifies a release. Downstream, the PR-review engine pins
|
|
||||||
# this version in its bcquality.config.yaml and uses this MINOR as Z in its own
|
|
||||||
# X.Y.Z version.
|
|
||||||
|
|
||||||
name: Release version
|
name: Release version
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
bump:
|
||||||
|
description: Which part to bump
|
||||||
|
type: choice
|
||||||
|
options:
|
||||||
|
- minor
|
||||||
|
- major
|
||||||
|
default: minor
|
||||||
|
|
||||||
# Only tag creation needs write.
|
# Only tag creation needs write.
|
||||||
permissions:
|
permissions:
|
||||||
|
|
@ -33,17 +38,30 @@ jobs:
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Tag release
|
- name: Compute and tag release
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
version="$(tr -d ' \t\r\n' < VERSION)"
|
git fetch --tags --force --quiet
|
||||||
if [[ ! "$version" =~ ^[0-9]+\.[0-9]+$ ]]; then
|
tags="$(git tag -l | grep -E '^v[0-9]+\.[0-9]+$' || true)"
|
||||||
echo "::error::VERSION must be a 'major.minor' value (got: '$version')"
|
|
||||||
exit 1
|
if [[ -z "$tags" ]]; then
|
||||||
|
# First release.
|
||||||
|
major=1
|
||||||
|
minor=0
|
||||||
|
else
|
||||||
|
latest_major="$(printf '%s\n' "$tags" | sed -E 's/^v([0-9]+)\..*/\1/' | sort -n | tail -1)"
|
||||||
|
latest_minor="$(printf '%s\n' "$tags" | sed -E 's/^v[0-9]+\.([0-9]+)$/\1/' | sort -n | tail -1)"
|
||||||
|
minor=$(( latest_minor + 1 )) # monotonic, never resets
|
||||||
|
if [[ "${{ inputs.bump }}" == "major" ]]; then
|
||||||
|
major=$(( latest_major + 1 ))
|
||||||
|
else
|
||||||
|
major="$latest_major"
|
||||||
fi
|
fi
|
||||||
tag="v${version}"
|
fi
|
||||||
|
|
||||||
|
tag="v${major}.${minor}"
|
||||||
if git rev-parse -q --verify "refs/tags/${tag}" >/dev/null; then
|
if git rev-parse -q --verify "refs/tags/${tag}" >/dev/null; then
|
||||||
echo "::error::Tag ${tag} already exists — bump VERSION before releasing"
|
echo "::error::Tag ${tag} already exists"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
git tag "$tag" "${{ github.sha }}"
|
git tag "$tag" "${{ github.sha }}"
|
||||||
|
|
|
||||||
|
|
@ -139,8 +139,9 @@ For the end-to-end flow — from orchestrator trigger through to how output reac
|
||||||
## Versioning
|
## Versioning
|
||||||
|
|
||||||
BCQuality content is released on demand — roughly monthly, not on every commit. A
|
BCQuality content is released on demand — roughly monthly, not on every commit. A
|
||||||
release is a `major.minor` value in [`VERSION`](VERSION), cut manually via the
|
release is a `major.minor` value derived from git tags, cut manually via the
|
||||||
`Release version` workflow, which tags the current `main` as `v{VERSION}`.
|
`Release version` workflow: pick whether to bump the minor or the major, and it
|
||||||
|
computes the next version and tags the current `main` as `v{major}.{minor}`.
|
||||||
|
|
||||||
- Bump the **minor** for the usual periodic content update; bump the **major**
|
- Bump the **minor** for the usual periodic content update; bump the **major**
|
||||||
only for a breaking change.
|
only for a breaking change.
|
||||||
|
|
|
||||||
1
VERSION
1
VERSION
|
|
@ -1 +0,0 @@
|
||||||
1.0
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue