Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ jobs:
- name: the release workflow's dry_run gating
run: nix build .#checks.x86_64-linux.dry-run-gating --no-link --print-build-logs

- name: release-only retries recheck remote tags before bumping
run: nix build .#checks.x86_64-linux.release-retry --no-link --print-build-logs

# Unknown actions, bad expressions and shell mistakes, caught before the run.
- name: lint the workflows
run: nix develop . -c actionlint
Expand Down
32 changes: 30 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ jobs:
set -euo pipefail
version=$(scripts/release-tags.sh | sed -n 's/^version=//p')
echo "version=$version" >>"$GITHUB_OUTPUT"
if ! git ls-remote --exit-code --tags origin "refs/tags/v$version" >/dev/null 2>&1; then
remote=$(git ls-remote --refs --tags origin "refs/tags/v$version")
remote=$(printf '%s\n' "$remote" | awk -v ref="refs/tags/v$version" '$2 == ref')
if [ -z "$remote" ]; then
{
echo "refusing: Cargo.toml carries $version and the remote has no tag v$version."
echo
Expand All @@ -137,7 +139,9 @@ jobs:
set -euo pipefail
# The last line of stdout is the version, and the only line on it.
next=$(scripts/bump-version.sh "$BUMP" --dry-run | tail -n 1)
if git ls-remote --exit-code --tags origin "refs/tags/v$next" >/dev/null 2>&1; then
remote=$(git ls-remote --refs --tags origin "refs/tags/v$next")
remote=$(printf '%s\n' "$remote" | awk -v ref="refs/tags/v$next" '$2 == ref')
if [ -n "$remote" ]; then
{
echo "refusing: v$next already exists on the remote; nothing was written or pushed."
echo
Expand Down Expand Up @@ -201,6 +205,30 @@ jobs:
# against the previous release's tag, which has to be a local ref for it.
fetch-depth: 0

# A release-only retry can reuse a successful plan after remote tags changed.
- name: recheck release tag preconditions before bumping
env:
TARGET: ${{ needs.plan.outputs.version }}
run: |
set -euo pipefail
current=$(sed -n 's/^version = "\(.*\)"$/\1/p' Cargo.toml | head -n 1)
if [ -z "$current" ]; then
echo "refusing: could not read the original version from Cargo.toml" >&2
exit 1
fi
current_tag=$(git ls-remote --refs --tags origin "refs/tags/v${current}")
current_tag=$(printf '%s\n' "$current_tag" | awk -v ref="refs/tags/v${current}" '$2 == ref')
target_tag=$(git ls-remote --refs --tags origin "refs/tags/v${TARGET}")
target_tag=$(printf '%s\n' "$target_tag" | awk -v ref="refs/tags/v${TARGET}" '$2 == ref')
if [ -z "$current_tag" ]; then
echo "refusing: the remote no longer has the current release tag v${current}; nothing was bumped" >&2
exit 1
fi
if [ -n "$target_tag" ]; then
echo "refusing: target tag v${TARGET} already exists on the remote; nothing was bumped" >&2
exit 1
fi

- name: bump the version this release carries
env:
BUMP: ${{ inputs.bump }}
Expand Down
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,23 @@
touch $out
'';

# Exercise plan, retry and exact remote tag checks without publishing.
release-retry =
pkgs.runCommand "release-retry-test" {
nativeBuildInputs = [
(pkgs.python3.withPackages (ps: [ps.pyyaml]))
pkgs.bash
pkgs.coreutils
pkgs.gnused
pkgs.gawk
pkgs.git
];
} ''
RELEASE_WORKFLOW=${./.github/workflows/release.yml} \
python3 -B ${./scripts/test_release_retry.py}
touch $out
'';

# The guard around a workflow's `dry_run` input: a plan step prints what a
# real run would do, and every step after it has to be excluded from a dry
# run. `actionlint` lints those
Expand Down
2 changes: 2 additions & 0 deletions lychee.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
root_dir = "."
exclude = [
"https://fsf.org/",
# The runner expands this workflow template before fetching the release asset.
'^[h]ttps://github[.]com/lycheeverse/lychee/releases/download/lychee-v[$]([{]|%7[Bb])LYCHEE_VERSION',
# The public demo's front proxying to its sibling containers by their Compose
# service names (`deploy/`). Those names resolve only inside that
# deployment's own network.
Expand Down
2 changes: 2 additions & 0 deletions scripts/ci-local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ job_checks() {
# one where a step after the plan can still run on a dry run.
say "checks: the release workflow's dry_run gating"
nix build .#checks.x86_64-linux.dry-run-gating --no-link --print-build-logs
say "checks: release-only retries recheck remote tags before bumping"
nix build .#checks.x86_64-linux.release-retry --no-link --print-build-logs
say "checks: lint the workflows"
nix develop . -c actionlint
# The same check the pre-commit hook runs: a commit made outside the dev shell cannot
Expand Down
Loading