Skip to content

Commit e249706

Browse files
committed
Add just recipes that trigger release.yml
This adds three recipes to the `justfile`. Two of these recipes trigger the release workflow. 1. `unique-v-tag`, which delegates to a script, looks at tags that point to `HEAD`, reports an error if none, or more than one, of them are named starting with `v`, and otherwise outputs the name of the unique `v*` tag that it found. 2. `run-release-workflow` triggers the `release.yml` workflow for a tag obtained via `unique-v-tag`. By default, it runs it on the `GitoxideLabs/gitoxide` repository. This can be adjusted by setting the `GH_REPO` environment variable, as usual for `gh`. It can also be adjusted by passing an optional argument to the recipe (which takes precedence over `GH_REPO` if set). 3. `roll-release` runs `cargo smart-release`, forwarding its arguments to it, and then runs the `release.yml` workflow via `run-release-workflow`. Because all arguments to `roll-release` are passed to `cargo smart-release`, the repository to run `release.yml` on cannot be specified as an argument to `roll-release`, but `GH_REPO` can still be used to customize it. (Also, since `roll-release` is meant to be used when actually creating releases and publishing them, it's not expected to run on forks nearly as often as the upstream.) See GitoxideLabs#1970.
1 parent 60c29a5 commit e249706

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

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)