Skip to content

Commit 1dd9329

Browse files
authored
Merge pull request GitoxideLabs#2077 from EliahKagan/releasing-events
Add `justfile` recipes to help with releasing
2 parents 60c29a5 + ef5fff1 commit 1dd9329

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed

.github/workflows/release.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,16 @@ on:
77
push:
88
# Enable when testing release infrastructure on a branch.
99
# branches:
10-
# - fix-releases
10+
# - fix-releases
1111
tags:
12-
- 'v*'
12+
# For now, real releases always use `workflow_dispatch`, and running the workflow on tag pushes
13+
# is only done in testing. This is because we usually push too many tags at once for the `push`
14+
# event to be triggered, since there are usually more than 3 crates tagged together. So the
15+
# `push` trigger doesn't usually work. If we allow it, we risk running the workflow twice if
16+
# it is also manually triggered based on the assumption that it would not run. See #1970 for
17+
# details. See also the `run-release-workflow` and `roll-release` recipes in the `justfile`.
18+
# - 'v*'
19+
- 'v*-DO-NOT-USE' # Pattern for tags used to test the workflow (usually done in a fork).
1320
workflow_dispatch:
1421

1522
permissions:

etc/unique-v-tag.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
3+
set -efu
4+
IFS=$'\n'
5+
6+
# shellcheck disable=SC2207 # Intentionally splitting. No globbing due to set -f.
7+
tags=(
8+
$(git tag --points-at HEAD -- 'v*')
9+
)
10+
11+
count="${#tags[@]}"
12+
if ((count != 1)); then
13+
printf '%s: error: Found %d matching v* tags, need exactly 1.\n' "$0" "$count" >&2
14+
exit 1
15+
fi
16+
17+
printf '%s\n' "${tags[0]}"

justfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,3 +295,20 @@ check-mode:
295295
# Delete `gix-packetline-blocking/src` and regenerate from `gix-packetline/src`
296296
copy-packetline:
297297
etc/copy-packetline.sh
298+
299+
# Get the unique `v*` tag at `HEAD`, or fail with an error
300+
unique-v-tag:
301+
etc/unique-v-tag.sh
302+
303+
# Trigger the `release.yml` workflow on the current `v*` tag
304+
run-release-workflow repo='':
305+
optional_repo_arg={{ quote(repo) }} && \
306+
export GH_REPO="${optional_repo_arg:-"${GH_REPO:-GitoxideLabs/gitoxide}"}" && \
307+
tag_name="$({{ j }} unique-v-tag)" && \
308+
printf 'Running release.yml in %s repo for %s tag.\n' "$GH_REPO" "$tag_name" && \
309+
gh workflow run release.yml --ref "refs/tags/$tag_name"
310+
311+
# Run `cargo smart-release` and then trigger `release.yml` for the `v*` tag
312+
roll-release *csr-args:
313+
cargo smart-release {{ csr-args }}
314+
{{ j }} run-release-workflow

0 commit comments

Comments
 (0)