mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-18 22:16:18 -05:00
ci: allow flake hashes from snapshot assets
This commit is contained in:
4 files changed
+43
-11
No files matched your search
@@ -6,6 +6,9 @@ on:
|
||||
version:
|
||||
description: "Release version. Defaults to Cargo.toml workspace version."
|
||||
required: false
|
||||
release_tag:
|
||||
description: "GitHub release tag to fetch assets from. Defaults to v<version>; use snapshot for snapshot assets."
|
||||
required: false
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
@@ -24,11 +27,12 @@ jobs:
|
||||
- name: Update flake hashes
|
||||
env:
|
||||
RELEASE_VERSION: ${{ inputs.version }}
|
||||
RELEASE_TAG: ${{ inputs.release_tag }}
|
||||
run: |
|
||||
if [[ -n "$RELEASE_VERSION" ]]; then
|
||||
scripts/update-flake-hashes.sh "$RELEASE_VERSION"
|
||||
scripts/update-flake-hashes.sh "$RELEASE_VERSION" "$RELEASE_TAG"
|
||||
else
|
||||
scripts/update-flake-hashes.sh
|
||||
scripts/update-flake-hashes.sh "" "$RELEASE_TAG"
|
||||
fi
|
||||
|
||||
- name: Upload updated flake
|
||||
@@ -112,4 +116,5 @@ jobs:
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
RELEASE_VERSION: ${{ inputs.version }}
|
||||
run: scripts/open-flake-hashes-pr.sh "$RELEASE_VERSION"
|
||||
RELEASE_TAG: ${{ inputs.release_tag }}
|
||||
run: scripts/open-flake-hashes-pr.sh "$RELEASE_VERSION" "$RELEASE_TAG"
|
||||
@@ -26,6 +26,7 @@
|
||||
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
|
||||
pname = "globalprotect-openconnect";
|
||||
version = cargoToml.workspace.package.version;
|
||||
releaseTag = "v${version}";
|
||||
|
||||
toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
|
||||
|
||||
@@ -35,7 +36,7 @@
|
||||
};
|
||||
|
||||
src = pkgs.fetchzip {
|
||||
url = "https://github.com/yuezk/GlobalProtect-openconnect/releases/download/v${version}/globalprotect-openconnect-${version}.tar.gz";
|
||||
url = "https://github.com/yuezk/GlobalProtect-openconnect/releases/download/${releaseTag}/globalprotect-openconnect-${version}.tar.gz";
|
||||
hash = "sha256-R7wS207jTujDYm4x7ucFY/cLvYw88zIVkVqRrCiEp80=";
|
||||
};
|
||||
|
||||
@@ -47,7 +48,7 @@
|
||||
};
|
||||
|
||||
gpgui = pkgs.fetchzip {
|
||||
url = "https://github.com/yuezk/GlobalProtect-openconnect/releases/download/v${version}/gpgui_${cpu}.bin.tar.xz";
|
||||
url = "https://github.com/yuezk/GlobalProtect-openconnect/releases/download/${releaseTag}/gpgui_${cpu}.bin.tar.xz";
|
||||
hash = gpguiHashes.${cpu};
|
||||
};
|
||||
|
||||
@@ -57,7 +58,7 @@
|
||||
};
|
||||
|
||||
binaryPackage = pkgs.fetchzip {
|
||||
url = "https://github.com/yuezk/GlobalProtect-openconnect/releases/download/v${version}/globalprotect-openconnect_${version}_${cpu}.bin.tar.xz";
|
||||
url = "https://github.com/yuezk/GlobalProtect-openconnect/releases/download/${releaseTag}/globalprotect-openconnect_${version}_${cpu}.bin.tar.xz";
|
||||
hash = binaryHashes.${cpu};
|
||||
};
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
set -euo pipefail
|
||||
|
||||
release_version="${1:-}"
|
||||
release_tag="${2:-}"
|
||||
|
||||
if git diff --quiet -- flake.nix; then
|
||||
echo "flake.nix hashes are already up to date"
|
||||
@@ -14,10 +15,22 @@ if [[ -z "$release_version" ]]; then
|
||||
fi
|
||||
|
||||
version="${release_version#v}"
|
||||
branch="chore/update-flake-hashes-v${version}"
|
||||
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 fetchzip hashes for v${version} release assets."
|
||||
|
||||
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 fetchzip hashes for v${version} using ${release_tag} release assets."
|
||||
fi
|
||||
|
||||
branch="chore/update-flake-hashes-${branch_suffix}"
|
||||
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||
git switch -C "$branch"
|
||||
|
||||
@@ -9,10 +9,11 @@ PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
|
||||
FLAKE_FILE="$PROJECT_DIR/flake.nix"
|
||||
|
||||
usage() {
|
||||
echo "Usage: $0 [version]"
|
||||
echo "Usage: $0 [version] [release-tag]"
|
||||
echo
|
||||
echo "Updates flake.nix fetchzip hashes from the published GitHub release assets."
|
||||
echo "When version is omitted, the workspace package version from Cargo.toml is used."
|
||||
echo "When release-tag is omitted, v<version> is used. Use snapshot to test snapshot assets."
|
||||
}
|
||||
|
||||
if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then
|
||||
@@ -35,12 +36,21 @@ if [[ -z "$version" ]]; then
|
||||
version="$(grep '^version' "$PROJECT_DIR/Cargo.toml" | head -1 | sed 's/version *= *"\(.*\)"/\1/')"
|
||||
fi
|
||||
version="${version#v}"
|
||||
release_tag="${2:-}"
|
||||
if [[ -z "$release_tag" ]]; then
|
||||
release_tag="v$version"
|
||||
fi
|
||||
|
||||
if [[ -z "$version" ]]; then
|
||||
echo "Could not determine release version" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -z "$release_tag" ]]; then
|
||||
echo "Could not determine release tag" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
prefetch_hash() {
|
||||
local url="$1"
|
||||
local attempt
|
||||
@@ -67,7 +77,7 @@ prefetch_hash() {
|
||||
|
||||
release_url() {
|
||||
local asset="$1"
|
||||
echo "https://github.com/$REPO/releases/download/v$version/$asset"
|
||||
echo "https://github.com/$REPO/releases/download/$release_tag/$asset"
|
||||
}
|
||||
|
||||
source_hash="$(prefetch_hash "$(release_url "globalprotect-openconnect-$version.tar.gz")")"
|
||||
@@ -81,8 +91,10 @@ GPGUI_X86_64_HASH="$gpgui_x86_64_hash" \
|
||||
GPGUI_AARCH64_HASH="$gpgui_aarch64_hash" \
|
||||
BINARY_X86_64_HASH="$binary_x86_64_hash" \
|
||||
BINARY_AARCH64_HASH="$binary_aarch64_hash" \
|
||||
RELEASE_TAG="$release_tag" \
|
||||
perl -0pi -e '
|
||||
s|(url = "https://github\.com/yuezk/GlobalProtect-openconnect/releases/download/v\$\{version\}/globalprotect-openconnect-\$\{version\}\.tar\.gz";\n\s*hash = ")[^"]+(";)|$1 . $ENV{"SOURCE_HASH"} . $2|e;
|
||||
s|(releaseTag = ")[^"]+(";)|$1 . $ENV{"RELEASE_TAG"} . $2|e;
|
||||
s|(url = "https://github\.com/yuezk/GlobalProtect-openconnect/releases/download/\$\{releaseTag\}/globalprotect-openconnect-\$\{version\}\.tar\.gz";\n\s*hash = ")[^"]+(";)|$1 . $ENV{"SOURCE_HASH"} . $2|e;
|
||||
s|(gpguiHashes = \{\n\s*x86_64 = ")[^"]+(";)|$1 . $ENV{"GPGUI_X86_64_HASH"} . $2|e;
|
||||
s|(gpguiHashes = \{\n\s*x86_64 = "[^"]+";\n\s*aarch64 = ")[^"]+(";)|$1 . $ENV{"GPGUI_AARCH64_HASH"} . $2|e;
|
||||
s|(binaryHashes = \{\n\s*x86_64 = ")[^"]+(";)|$1 . $ENV{"BINARY_X86_64_HASH"} . $2|e;
|
||||
@@ -94,5 +106,6 @@ grep -F "$gpgui_x86_64_hash" "$FLAKE_FILE" > /dev/null
|
||||
grep -F "$gpgui_aarch64_hash" "$FLAKE_FILE" > /dev/null
|
||||
grep -F "$binary_x86_64_hash" "$FLAKE_FILE" > /dev/null
|
||||
grep -F "$binary_aarch64_hash" "$FLAKE_FILE" > /dev/null
|
||||
grep -F "releaseTag = \"$release_tag\";" "$FLAKE_FILE" > /dev/null
|
||||
|
||||
echo "Updated flake.nix hashes for v$version"
|
||||
echo "Updated flake.nix hashes for v$version assets from $release_tag"
|
||||
Reference in new issue
Block a user