Skip to content

Commit ce2fbaf

Browse files
committed
build: share release tag validation
1 parent df631c6 commit ce2fbaf

4 files changed

Lines changed: 62 additions & 70 deletions

File tree

.github/workflows/publish-debian-source.yml

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,36 +26,20 @@ jobs:
2626
run: |
2727
version="$(tr -d '[:space:]' < VERSION)"
2828
echo "version=$version" >> "$GITHUB_OUTPUT"
29-
3029
if [[ "${GITHUB_EVENT_NAME}" == "push" ]]; then
31-
tag="${GITHUB_REF_NAME}"
32-
case "$tag" in
33-
[0-9]*.[0-9]*.[0-9]*) ;;
34-
*)
35-
echo "expected a plain semantic version tag, got: $tag" >&2
36-
exit 1
37-
;;
38-
esac
39-
[[ "$tag" == "$version" ]] || {
40-
echo "VERSION contains $version, expected $tag" >&2
41-
exit 1
42-
}
43-
git fetch origin main --no-tags
44-
git merge-base --is-ancestor "${GITHUB_SHA}" origin/main || {
45-
echo "release tags must point to commits reachable from origin/main" >&2
46-
exit 1
47-
}
30+
bash ./scripts/validate-release-tag.sh "${GITHUB_REF_NAME}"
31+
else
32+
bash ./scripts/validate-release-tag.sh
4833
fi
49-
50-
./scripts/release-check.sh "$version"
34+
bash ./scripts/release-check.sh "$version"
5135
5236
- name: Install packaging dependencies
5337
run: |
5438
sudo apt-get update
5539
sudo apt-get install -y curl debhelper devscripts dpkg-dev rsync
5640
5741
- name: Build Debian source package
58-
run: ./scripts/package-debian-source.sh "${{ steps.meta.outputs.version }}"
42+
run: bash ./scripts/package-debian-source.sh "${{ steps.meta.outputs.version }}"
5943
env:
6044
DEBIAN_DISTRIBUTION: ${{ vars.PPA_UBUNTU_SERIES || 'noble' }}
6145
DEBIAN_REVISION: ${{ github.event.inputs.debian_revision || '1' }}

.github/workflows/publish-package-managers.yml

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,12 @@ jobs:
2121
run: |
2222
version="$(tr -d '[:space:]' < VERSION)"
2323
echo "version=$version" >> "$GITHUB_OUTPUT"
24-
2524
if [[ "${GITHUB_EVENT_NAME}" == "push" ]]; then
26-
tag="${GITHUB_REF_NAME}"
27-
case "$tag" in
28-
[0-9]*.[0-9]*.[0-9]*) ;;
29-
*)
30-
echo "expected a plain semantic version tag, got: $tag" >&2
31-
exit 1
32-
;;
33-
esac
34-
[[ "$tag" == "$version" ]] || {
35-
echo "VERSION contains $version, expected $tag" >&2
36-
exit 1
37-
}
38-
git fetch origin main --no-tags
39-
git merge-base --is-ancestor "${GITHUB_SHA}" origin/main || {
40-
echo "release tags must point to commits reachable from origin/main" >&2
41-
exit 1
42-
}
25+
bash ./scripts/validate-release-tag.sh "${GITHUB_REF_NAME}"
26+
else
27+
bash ./scripts/validate-release-tag.sh
4328
fi
44-
45-
./scripts/release-check.sh "$version"
29+
bash ./scripts/release-check.sh "$version"
4630
4731
publish-homebrew:
4832
runs-on: ubuntu-24.04
@@ -75,7 +59,7 @@ jobs:
7559
if: steps.gate.outputs.publish == 'true'
7660
env:
7761
TAP_REPO_DIR: ${{ github.workspace }}/.stage/homebrew-icey
78-
run: ./scripts/publish-homebrew.sh
62+
run: bash ./scripts/publish-homebrew.sh
7963

8064
- name: Commit formula update
8165
if: steps.gate.outputs.publish == 'true'
@@ -128,7 +112,7 @@ jobs:
128112
if: steps.gate.outputs.publish == 'true'
129113
env:
130114
AUR_REPO_DIR: ${{ github.workspace }}/.stage/aur-icey
131-
run: ./scripts/publish-aur.sh
115+
run: bash ./scripts/publish-aur.sh
132116

133117
- name: Commit AUR update
134118
if: steps.gate.outputs.publish == 'true'

.github/workflows/release.yml

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,33 +18,7 @@ jobs:
1818

1919
- name: Validate tag and release metadata
2020
run: |
21-
tag="${GITHUB_REF_NAME}"
22-
version="$(tr -d '[:space:]' < VERSION)"
23-
git fetch origin main --no-tags
24-
case "$tag" in
25-
[0-9]*.[0-9]*.[0-9]*) ;;
26-
*)
27-
echo "expected a plain semantic version tag, got: $tag" >&2
28-
exit 1
29-
;;
30-
esac
31-
git merge-base --is-ancestor "${GITHUB_SHA}" origin/main || {
32-
echo "release tags must point to commits reachable from origin/main" >&2
33-
exit 1
34-
}
35-
if [[ "$version" != "$tag" ]]; then
36-
echo "VERSION contains $version, expected $tag" >&2
37-
exit 1
38-
fi
39-
grep -Eq "^## \\[$tag\\]" CHANGELOG.md || {
40-
echo "CHANGELOG.md is missing [$tag]" >&2
41-
exit 1
42-
}
43-
section="$(awk '/^## \['"$tag"'\]/{found=1; next} /^## \[/{if(found) exit} found{print}' CHANGELOG.md)"
44-
printf '%s\n' "$section" | grep -Eq '[^[:space:]]' || {
45-
echo "CHANGELOG.md [$tag] section is empty" >&2
46-
exit 1
47-
}
21+
bash ./scripts/validate-release-tag.sh "${GITHUB_REF_NAME}"
4822
4923
- name: Extract changelog
5024
run: |

scripts/validate-release-tag.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
repo_root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
5+
cd "$repo_root"
6+
7+
tag="${1:-}"
8+
version="$(tr -d '[:space:]' < VERSION)"
9+
10+
if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
11+
echo "VERSION must contain a plain semantic version, got: $version" >&2
12+
exit 1
13+
fi
14+
15+
if [[ -n "$tag" ]]; then
16+
case "$tag" in
17+
[0-9]*.[0-9]*.[0-9]*) ;;
18+
*)
19+
echo "expected a plain semantic version tag, got: $tag" >&2
20+
exit 1
21+
;;
22+
esac
23+
24+
if [[ "$version" != "$tag" ]]; then
25+
echo "VERSION contains $version, expected $tag" >&2
26+
exit 1
27+
fi
28+
29+
git fetch origin main --no-tags
30+
commit_ref="${GITHUB_SHA:-HEAD}"
31+
git merge-base --is-ancestor "$commit_ref" origin/main || {
32+
echo "release tags must point to commits reachable from origin/main" >&2
33+
exit 1
34+
}
35+
fi
36+
37+
grep -Eq "^## \\[$version\\]" CHANGELOG.md || {
38+
echo "CHANGELOG.md is missing [$version]" >&2
39+
exit 1
40+
}
41+
42+
section="$(
43+
awk '/^## \['"$version"'\]/{found=1; next} /^## \[/{if(found) exit} found{print}' CHANGELOG.md
44+
)"
45+
printf '%s\n' "$section" | grep -Eq '[^[:space:]]' || {
46+
echo "CHANGELOG.md [$version] section is empty" >&2
47+
exit 1
48+
}
49+
50+
echo "release metadata is valid for $version"

0 commit comments

Comments
 (0)