Compare commits
5 Commits
v0.4.1
..
d21237cfdc
| Author | SHA1 | Date | |
|---|---|---|---|
| d21237cfdc | |||
| 14301586e0 | |||
| 2c835120f8 | |||
| 84d3b03485 | |||
| d293e6b5b6 |
@@ -6,6 +6,9 @@ name: Release
|
||||
# the vX.Y.Z tag. The build matrix + release job then run off that tag. No
|
||||
# more hand-editing versions across Cargo.toml and individual crate manifests.
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v[0-9]+.[0-9]+.[0-9]+*'
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
@@ -32,8 +35,6 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
# Push the release commit + tag back with a write-capable token.
|
||||
token: ${{ secrets.RELEASE_TOKEN }}
|
||||
|
||||
- uses: dtolnay/rust-toolchain@1.83
|
||||
|
||||
@@ -48,26 +49,43 @@ jobs:
|
||||
restore-keys: |
|
||||
${{ runner.os }}-cargo-prepare-
|
||||
|
||||
- name: Validate version + stamp
|
||||
- name: Stamp version + tag
|
||||
id: stamp
|
||||
env:
|
||||
VERSION: ${{ inputs.version }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
ver="${VERSION#v}" # tolerate a leading v
|
||||
if ! printf '%s' "$ver" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+([-.][0-9A-Za-z.-]+)?$'; then
|
||||
echo "::error::'$ver' is not a semver version (expected e.g. 0.4.0)"
|
||||
if [ "${GITHUB_EVENT_NAME}" = "push" ]; then
|
||||
# Tag pushed locally: tag already exists, just extract version
|
||||
tag="${GITHUB_REF_NAME}"
|
||||
ver="${tag#v}"
|
||||
else
|
||||
# Manual dispatch from Gitea UI: use the input version
|
||||
ver="${VERSION#v}"
|
||||
tag="v${ver}"
|
||||
if ! printf '%s' "$ver" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+([-.][0-9A-Za-z.-]+)?$'; then
|
||||
echo "::error::'$ver' is not a semver version (expected e.g. 0.4.0)"
|
||||
exit 1
|
||||
fi
|
||||
# If the tag already exists locally, skip version stamping.
|
||||
# This covers the case where the tag was created outside this
|
||||
# workflow — we just need the version number for downstream jobs.
|
||||
if git rev-parse -q --verify "refs/tags/$tag" >/dev/null && \
|
||||
! git ls-remote --exit-code --tags origin "$tag" >/dev/null 2>&1; then
|
||||
echo "Tag already exists locally — skipping version stamp."
|
||||
else
|
||||
echo "Stamping version $ver …"
|
||||
bash scripts/set-version.sh "$ver"
|
||||
fi
|
||||
fi
|
||||
# Verify the Cargo.toml version matches so downstream jobs are safe.
|
||||
manifest_ver=$(grep '^version' Cargo.toml | head -1 | sed 's/version = "//;s/"//')
|
||||
if [ "$ver" != "$manifest_ver" ]; then
|
||||
echo "::error::version mismatch: step says $ver but Cargo.toml says $manifest_ver"
|
||||
exit 1
|
||||
fi
|
||||
tag="v$ver"
|
||||
if git rev-parse -q --verify "refs/tags/$tag" >/dev/null \
|
||||
|| git ls-remote --exit-code --tags origin "$tag" >/dev/null 2>&1; then
|
||||
echo "::error::tag $tag already exists"
|
||||
exit 1
|
||||
fi
|
||||
bash scripts/set-version.sh "$ver"
|
||||
echo "version=$ver" >> "$GITHUB_OUTPUT"
|
||||
echo "tag=$tag" >> "$GITHUB_OUTPUT"
|
||||
env:
|
||||
VERSION: ${{ inputs.version }}
|
||||
|
||||
# Gate: never tag code that doesn't build/test. If this fails nothing
|
||||
# is committed or pushed, so the release simply doesn't happen.
|
||||
@@ -75,6 +93,7 @@ jobs:
|
||||
run: cargo test --workspace
|
||||
|
||||
- name: Commit, tag, push
|
||||
if: github.event_name == 'workflow_dispatch'
|
||||
env:
|
||||
VER: ${{ steps.stamp.outputs.version }}
|
||||
TAG: ${{ steps.stamp.outputs.tag }}
|
||||
@@ -84,10 +103,18 @@ jobs:
|
||||
git config user.email "gitea-actions@users.noreply.code.gfran.co"
|
||||
git add Cargo.toml Cargo.lock \
|
||||
crates/nuwiki-lsp/Cargo.toml crates/nuwiki-ls/Cargo.toml
|
||||
git commit -m "chore(release): $VER"
|
||||
git tag -a "$TAG" -m "nuwiki $VER"
|
||||
git push origin "HEAD:${GITHUB_REF_NAME}"
|
||||
git push origin "$TAG"
|
||||
# Check if there are staged changes. If not, the version was already
|
||||
# correct — create an empty commit just to have a release commit,
|
||||
# and skip the tag push since it already exists on origin.
|
||||
if git diff --cached --quiet; then
|
||||
git commit --allow-empty -m "chore(release): $VER"
|
||||
echo "No version changes — skipping tag push."
|
||||
else
|
||||
git commit -m "chore(release): $VER"
|
||||
git tag -a "$TAG" -m "nuwiki $VER"
|
||||
git push origin "HEAD:${GITHUB_REF_NAME}"
|
||||
git push origin "$TAG"
|
||||
fi
|
||||
|
||||
build:
|
||||
name: build ${{ matrix.target }}
|
||||
@@ -115,8 +142,7 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
# Build the just-tagged commit, not the branch tip.
|
||||
ref: ${{ needs.prepare.outputs.tag }}
|
||||
ref: main
|
||||
|
||||
- uses: dtolnay/rust-toolchain@1.83
|
||||
with:
|
||||
@@ -176,8 +202,7 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ needs.prepare.outputs.tag }}
|
||||
fetch-depth: 0
|
||||
ref: main
|
||||
|
||||
- name: Download all build artifacts
|
||||
# download-artifact@v3 nests each artifact under its own dir
|
||||
|
||||
Reference in New Issue
Block a user