mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-19 06:26:14 -05:00
Use raw release-asset hashes, keep the Nixpkgs lock current, and validate the prebuilt package across supported Nixpkgs branches and architectures. [skip ci]
60 lines
1.9 KiB
Bash
Executable File
60 lines
1.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
release_version="${1:-}"
|
|
release_tag="${2:-}"
|
|
|
|
if git diff --quiet -- flake.nix flake.lock; then
|
|
echo "flake hashes and lock are already up to date"
|
|
exit 0
|
|
fi
|
|
|
|
if [[ -z "$release_version" ]]; then
|
|
release_version="$(grep '^version' Cargo.toml | head -1 | sed 's/version *= *"\(.*\)"/\1/')"
|
|
fi
|
|
|
|
version="${release_version#v}"
|
|
if [[ -z "$release_tag" ]]; then
|
|
release_tag="v$version"
|
|
fi
|
|
|
|
branch_suffix="v${version}"
|
|
title="chore: update flake hashes for v${version}"
|
|
body="Updates the Nix flake fetchurl hashes for v${version} release assets and refreshes the Nixpkgs lock."
|
|
|
|
if [[ "$release_tag" != "v$version" ]]; then
|
|
branch_suffix="${branch_suffix}-${release_tag}"
|
|
title="chore: update flake hashes for v${version} from ${release_tag}"
|
|
body="Updates the Nix flake fetchurl hashes for v${version} using ${release_tag} release assets and refreshes the Nixpkgs lock."
|
|
fi
|
|
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
|
|
if [[ "$release_tag" == "snapshot" ]]; then
|
|
source_branch="${GITHUB_REF_NAME:-$(git branch --show-current)}"
|
|
source_branch_slug="$(printf '%s' "$source_branch" | sed -E 's#[/[:space:]]+#-#g; s#[^A-Za-z0-9._-]##g; s#^-+##; s#-+$##')"
|
|
branch="chore/flake-${source_branch_slug}"
|
|
git switch -C "$branch"
|
|
git add flake.nix flake.lock
|
|
git commit -m "$title"
|
|
git push --force origin "$branch"
|
|
echo "Updated snapshot flake hashes on branch $branch from $source_branch; skipping PR creation"
|
|
exit 0
|
|
fi
|
|
|
|
branch="chore/update-flake-hashes-${branch_suffix}"
|
|
|
|
git switch -C "$branch"
|
|
git add flake.nix flake.lock
|
|
git commit -m "$title"
|
|
git push --force origin "$branch"
|
|
|
|
pr_number="$(gh pr list --head "$branch" --state open --json number --jq '.[0].number')"
|
|
if [[ -n "$pr_number" ]]; then
|
|
gh pr edit "$pr_number" --title "$title" --body "$body"
|
|
else
|
|
gh pr create --title "$title" --body "$body" --base main --head "$branch"
|
|
fi
|