Skip to content

Commit b7de9da

Browse files
committed
Fix automated release process
1 parent 194f55e commit b7de9da

4 files changed

Lines changed: 24 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
- Add automated release process
2525
- Ensure smoke tests use local scripts for bootstrap URLs
2626
- Improve install and download output layouts
27+
- Fix automated release process
2728

2829
## 0.10.0 - 2023-06-10
2930

bin/release

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,13 @@ validate_release_request() {
9292
git diff --quiet -- bin/g CHANGELOG.md \
9393
|| die "bin/g or CHANGELOG.md has uncommitted changes"
9494

95-
git rev-parse -q --verify "refs/tags/$version" > /dev/null \
96-
&& die "tag already exists: $version"
95+
if git rev-parse -q --verify "refs/tags/$version" > /dev/null; then
96+
die "tag already exists: $version"
97+
fi
9798

98-
gh release view "$version" > /dev/null 2>&1 \
99-
&& die "release already exists: $version"
99+
if gh release view "$version" > /dev/null 2>&1; then
100+
die "release already exists: $version"
101+
fi
100102
}
101103

102104
prepare_release_files() {
@@ -150,6 +152,7 @@ prepare_release_files() {
150152
}
151153
}
152154
' bin/g > bin/g.tmp
155+
chmod +x bin/g.tmp
153156
mv bin/g.tmp bin/g
154157

155158
awk -v version="$version" '
@@ -173,17 +176,26 @@ prepare_release_files() {
173176
validate_release_files() {
174177
make format
175178
make lint
179+
}
180+
181+
validate_source_files() {
182+
make format
183+
make lint
176184
make test
177185
}
178186

179187
commit_and_tag_release() {
188+
git add bin/g CHANGELOG.md
189+
180190
if [ -n "${GITHUB_ACTIONS:-}" ]; then
181-
git config user.name 'github-actions[bot]'
182-
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
191+
git \
192+
-c user.name='github-actions[bot]' \
193+
-c user.email='41898282+github-actions[bot]@users.noreply.github.com' \
194+
commit -m "$version"
195+
else
196+
git commit -m "$version"
183197
fi
184198

185-
git add bin/g CHANGELOG.md
186-
git commit -m "$version"
187199
git tag -a "$version" -F release-notes.md
188200
git push origin "HEAD:$(current_branch)" "$version"
189201
}
@@ -218,6 +230,7 @@ require_command make
218230

219231
validate_version "$version"
220232
validate_release_request
233+
validate_source_files
221234
prepare_release_files
222235
validate_release_files
223236
commit_and_tag_release

tests/metadata.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ test_expect_success 'create mock Go archive' '
6262

6363
test_expect_success 'g accepts exact GOPATH bin PATH entry' '
6464
output=$(run_with_path "$GOPATH/bin:$mock_path:/bin:/usr/bin" "$g_bin --version") &&
65-
test "$output" = "0.10.0"
65+
echo "$output" | grep -E "^[0-9]+\.[0-9]+\.[0-9]+$"
6666
'
6767

6868
test_expect_success 'g rejects substring-only GOPATH bin PATH entry' '

tests/smoke.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ test_expect_success 'install script configures g' '
8585

8686
test_expect_success 'g reports its version' '
8787
output=$(run_with_g_env "g --version") &&
88-
test "$output" = "0.10.0"
88+
echo "$output" | grep -E "^[0-9]+\.[0-9]+\.[0-9]+$"
8989
'
9090

9191
test_expect_success 'go is installed by g and present on PATH' '

0 commit comments

Comments
 (0)