Skip to content

Commit 541856d

Browse files
authored
Add some sanity checks for potential release commits/tags (#7968)
* Must have no leftover .unreleased files * The commit title must start with "Release \<version\>" * The tag must point to the actual release commit and not something else. * The release commit must modify version.config
1 parent df7c385 commit 541856d

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Prerelease Sanity
2+
"on":
3+
push:
4+
branches:
5+
- prerelease_test
6+
pull_request:
7+
branches: "?.*.x"
8+
paths:
9+
- version.config
10+
- .github/workflows/prerelease-sanity.yaml
11+
workflow_dispatch:
12+
13+
jobs:
14+
check_release_commit:
15+
name: Check Release Commit
16+
runs-on: timescaledb-runner-arm64
17+
18+
steps:
19+
- name: Checkout TimescaleDB
20+
uses: actions/checkout@v4
21+
# GitHub creates an empty merge commit even for fast-fordward merges, which
22+
# makes it needlessly difficult to inspect the actual commit title. Since
23+
# we require the PRs to release branches to be up to date before merging,
24+
# we can just work with the PR head here.
25+
with:
26+
ref: ${{ github.event.pull_request.head.sha }}
27+
fetch-depth: 2
28+
29+
# The combined changelog must reference all changes, and the respective
30+
# change files in the .unreleased folder must be deleted.
31+
- name: No .unreleased files are left behind
32+
run: |
33+
! compgen -G .unreleased/*
34+
35+
# The messages of the release commit and tag must start with Release <version>.
36+
# If this is the release tag, it must point to the release commit
37+
# and not something else.
38+
- name: The release commit message references the respective version
39+
run: |
40+
required_title=$(sed -n "s/^version = /Release /p" version.config)
41+
echo $required_title
42+
43+
tag_title=$(git log --oneline -1 --pretty=format:%s)
44+
echo $tag_title
45+
grep "$required_title" <<<"$tag_title"
46+
47+
# Our reference might be a tag, so check the pointed-to commit as well,
48+
# using the ^0 git path specification to find it.
49+
commit_title=$(git log --oneline -1 --pretty=format:%s @^0)
50+
echo $commit_title
51+
grep "$required_title" <<<"$commit_title"
52+
53+
# The release commit must modify the version.config
54+
- name: The release commit modifies the version.config
55+
run: |
56+
git log --oneline -1 @^0
57+
git log --oneline -1 @^0~
58+
! git diff --exit-code @^0~ @^0 -- version.config

0 commit comments

Comments
 (0)