mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-18 22:16:18 -05:00
feat: prepare 3.0.0 release
This commit is contained in:
252 files changed
+26210
-7457
No files matched your search
Executable
+31
@@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
repo=$(CDPATH= cd "$(dirname "$0")/.." && pwd)
|
||||
cd "$repo"
|
||||
|
||||
if [ "$(id -u)" -eq 0 ]; then
|
||||
echo "Run this script as the desktop user; it invokes sudo to stage helpers and run gpservice." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
uid=$(id -u)
|
||||
if [ -n "${GP_DEV_BOOTSTRAP_SOCKET:-}" ]; then
|
||||
socket=$GP_DEV_BOOTSTRAP_SOCKET
|
||||
else
|
||||
socket=/var/run/gpservice-dev-$uid/dev-bootstrap.sock
|
||||
fi
|
||||
|
||||
cargo build -p gpservice -p gpclient
|
||||
|
||||
# The privileged resolver requires a root-owned executable and parent directories.
|
||||
helper_dir=$(sudo mktemp -d /var/run/gpservice-dev-helpers.XXXXXX)
|
||||
trap 'sudo rm -rf "$helper_dir"' 0
|
||||
sudo install -m 755 target/debug/gpclient "$helper_dir/gpclient"
|
||||
|
||||
echo "Debug credential socket: $socket"
|
||||
sudo env GP_CLIENT_BINARY="$helper_dir/gpclient" target/debug/gpservice \
|
||||
--dev-standalone \
|
||||
--dev-uid "$uid" \
|
||||
--dev-bootstrap-socket "$socket" \
|
||||
"$@"
|
||||
+165
-22
@@ -9,59 +9,202 @@ REPO="yuezk/GlobalProtect-openconnect"
|
||||
TAG=${1:-}
|
||||
|
||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||
GH_MAX_ATTEMPTS=8
|
||||
GH_DELETE_MAX_ATTEMPTS=3
|
||||
|
||||
if [ -z "$TAG" ]; then
|
||||
echo "Usage: ./scripts/gh-release.sh <tag>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
retry_gh() {
|
||||
local attempt=1
|
||||
local delay
|
||||
|
||||
until "$@"; do
|
||||
if (( attempt >= GH_MAX_ATTEMPTS )); then
|
||||
echo "GitHub operation failed after $attempt attempts" >&2
|
||||
return 1
|
||||
fi
|
||||
delay=$((attempt * 3))
|
||||
echo "GitHub operation failed; retrying in ${delay}s" >&2
|
||||
sleep "$delay"
|
||||
((attempt += 1))
|
||||
done
|
||||
}
|
||||
|
||||
upload_files() {
|
||||
local files=("$@")
|
||||
local file
|
||||
|
||||
if [ ${#files[@]} -eq 0 ]; then
|
||||
echo "No release assets found to upload"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
gh -R "$REPO" release upload "$TAG" "${files[@]}"
|
||||
for file in "${files[@]}"; do
|
||||
upload_file "$file"
|
||||
done
|
||||
}
|
||||
|
||||
release_assets() {
|
||||
"$SCRIPT_DIR/release-assets.sh" "$TAG"
|
||||
}
|
||||
|
||||
# For snapshot release, we don't create a release, just clear the existing assets and upload new ones.
|
||||
# This is to avoid notification spam.
|
||||
release_snapshot() {
|
||||
while IFS= read -r asset; do
|
||||
if [ -n "$asset" ]; then
|
||||
gh -R "$REPO" release delete-asset "$TAG" "$asset" --yes
|
||||
release_assets_json() {
|
||||
retry_gh gh -R "$REPO" release view "$TAG" --json assets
|
||||
}
|
||||
|
||||
release_asset_names() {
|
||||
retry_gh gh -R "$REPO" release view "$TAG" --json assets --jq '.assets[].name'
|
||||
}
|
||||
|
||||
delete_release_asset() {
|
||||
local asset=$1
|
||||
local assets
|
||||
local attempt=1
|
||||
local delay
|
||||
|
||||
while (( attempt <= GH_DELETE_MAX_ATTEMPTS )); do
|
||||
if gh -R "$REPO" release delete-asset "$TAG" "$asset" --yes; then
|
||||
return 0
|
||||
fi
|
||||
done < <(gh -R "$REPO" release view "$TAG" --json assets --jq '.assets[].name')
|
||||
if assets="$(release_asset_names)" && ! grep -Fqx -- "$asset" <<<"$assets"; then
|
||||
return 0
|
||||
fi
|
||||
if (( attempt >= GH_DELETE_MAX_ATTEMPTS )); then
|
||||
echo "Failed to delete release asset after $attempt attempts: $asset" >&2
|
||||
return 1
|
||||
fi
|
||||
delay=$((attempt * 3))
|
||||
echo "Failed to delete $asset; retrying in ${delay}s" >&2
|
||||
sleep "$delay"
|
||||
((attempt += 1))
|
||||
done
|
||||
}
|
||||
|
||||
upload_file() {
|
||||
local file=$1
|
||||
local asset
|
||||
local assets_json
|
||||
local local_digest
|
||||
local remote_digest
|
||||
local remote_exists
|
||||
local attempt=1
|
||||
local delay
|
||||
|
||||
asset="$(basename "$file")"
|
||||
local_digest="sha256:$(sha256sum "$file" | cut -d ' ' -f 1)"
|
||||
echo "Uploading $asset..."
|
||||
|
||||
while (( attempt <= GH_MAX_ATTEMPTS )); do
|
||||
if gh -R "$REPO" release upload "$TAG" "$file"; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
if assets_json="$(release_assets_json)"; then
|
||||
remote_digest="$(jq -r --arg name "$asset" \
|
||||
'.assets[] | select(.name == $name) | .digest // empty' <<<"$assets_json")"
|
||||
if [[ "$remote_digest" == "$local_digest" ]]; then
|
||||
echo "$asset is already uploaded with the expected digest"
|
||||
return 0
|
||||
fi
|
||||
|
||||
remote_exists="$(jq -r --arg name "$asset" \
|
||||
'[.assets[] | select(.name == $name)] | length' <<<"$assets_json")"
|
||||
if [[ "$remote_exists" != "0" ]]; then
|
||||
if ! delete_release_asset "$asset"; then
|
||||
echo "Could not replace release asset yet: $asset" >&2
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if (( attempt >= GH_MAX_ATTEMPTS )); then
|
||||
echo "Failed to upload release asset after $attempt attempts: $asset" >&2
|
||||
return 1
|
||||
fi
|
||||
delay=$((attempt * 3))
|
||||
echo "Failed to upload $asset; retrying in ${delay}s" >&2
|
||||
sleep "$delay"
|
||||
((attempt += 1))
|
||||
done
|
||||
}
|
||||
|
||||
# Update the existing snapshot release in place to avoid notification spam.
|
||||
# Preserve its macOS update assets when the current run does not replace them.
|
||||
release_snapshot() {
|
||||
mapfile -t files < <(release_assets)
|
||||
local existing_assets
|
||||
local is_current
|
||||
local asset
|
||||
local file
|
||||
local snapshot_commit
|
||||
|
||||
snapshot_commit="$(git -C "$SCRIPT_DIR/.." rev-parse HEAD)"
|
||||
if ! gh -R "$REPO" release view "$TAG" >/dev/null 2>&1; then
|
||||
gh -R "$REPO" release create "$TAG" \
|
||||
--prerelease \
|
||||
--target "$snapshot_commit" \
|
||||
--title "Snapshot" \
|
||||
--notes "Rolling snapshot release from trusted CI builds."
|
||||
fi
|
||||
|
||||
echo "Uploading new assets..."
|
||||
# Upload all artifacts for snapshot release because we don't need to guarantee stability.
|
||||
mapfile -t files < <(release_assets)
|
||||
# Upload first so a transient cleanup failure cannot leave the snapshot
|
||||
# release without the current artifacts.
|
||||
upload_files "${files[@]}"
|
||||
|
||||
if ! existing_assets="$(release_asset_names)"; then
|
||||
echo "::warning::Could not list stale snapshot assets for cleanup" >&2
|
||||
existing_assets=""
|
||||
fi
|
||||
while IFS= read -r asset; do
|
||||
if [[ -z "$asset" || "$asset" == "appcast.xml" ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
is_current=false
|
||||
for file in "${files[@]}"; do
|
||||
if [[ "$(basename "$file")" == "$asset" ]]; then
|
||||
is_current=true
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [[ "$is_current" == "true" ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
# The appcast publisher removes expired macOS snapshots after the new feed
|
||||
# is live. Removing them here would temporarily break the current feed.
|
||||
if [[ "$asset" == GPConnect_*_arm64.* ]]; then
|
||||
continue
|
||||
fi
|
||||
if ! delete_release_asset "$asset"; then
|
||||
echo "::warning::Could not remove stale snapshot asset: $asset" >&2
|
||||
fi
|
||||
done <<<"$existing_assets"
|
||||
|
||||
gh api --method PATCH "repos/$REPO/git/refs/tags/$TAG" \
|
||||
-f sha="$snapshot_commit" -F force=true >/dev/null
|
||||
gh -R "$REPO" release edit "$TAG" --prerelease --title "Snapshot"
|
||||
}
|
||||
|
||||
release_tag() {
|
||||
echo "Removing existing release..."
|
||||
gh -R "$REPO" release delete "$TAG" --yes --cleanup-tag || true
|
||||
|
||||
echo "Creating release..."
|
||||
local release_notes_file
|
||||
release_notes_file="$(mktemp)"
|
||||
"$SCRIPT_DIR/release-notes.sh" "$TAG" > "$release_notes_file"
|
||||
if ! gh -R "$REPO" release view "$TAG" >/dev/null 2>&1; then
|
||||
echo "Creating release..."
|
||||
release_notes_file="$(mktemp)"
|
||||
"$SCRIPT_DIR/release-notes.sh" "$TAG" > "$release_notes_file"
|
||||
|
||||
# Upload source tarballs, GUI components, and BSD packages. Other Linux
|
||||
# packages are built in `release.yml` from the standalone source tarball.
|
||||
gh -R "$REPO" release create "$TAG" \
|
||||
--title "$TAG" \
|
||||
--notes-file "$release_notes_file"
|
||||
# Upload source tarballs, GUI components, and BSD packages. Other Linux
|
||||
# packages are built in `release.yml` from the standalone source tarball.
|
||||
gh -R "$REPO" release create "$TAG" \
|
||||
--title "$TAG" \
|
||||
--notes-file "$release_notes_file"
|
||||
fi
|
||||
|
||||
mapfile -t files < <(release_assets)
|
||||
upload_files "${files[@]}"
|
||||
GITHUB_REPOSITORY="$REPO" "$SCRIPT_DIR/upload-release-assets.sh" "$TAG" "${files[@]}"
|
||||
}
|
||||
|
||||
if [[ $TAG == *"snapshot" ]]; then
|
||||
|
||||
@@ -5,8 +5,8 @@ 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"
|
||||
if git diff --quiet -- flake.nix flake.lock; then
|
||||
echo "flake hashes and lock are already up to date"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
@@ -21,12 +21,12 @@ 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."
|
||||
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 fetchzip hashes for v${version} using ${release_tag} release assets."
|
||||
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]"
|
||||
@@ -37,7 +37,7 @@ if [[ "$release_tag" == "snapshot" ]]; then
|
||||
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
|
||||
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"
|
||||
@@ -47,12 +47,12 @@ fi
|
||||
branch="chore/update-flake-hashes-${branch_suffix}"
|
||||
|
||||
git switch -C "$branch"
|
||||
git add flake.nix
|
||||
git add flake.nix flake.lock
|
||||
git commit -m "$title"
|
||||
git push --force origin "$branch"
|
||||
|
||||
if gh pr view "$branch" --json number > /tmp/flake-pr.json 2> /dev/null; then
|
||||
pr_number="$(jq -r '.number' /tmp/flake-pr.json)"
|
||||
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"
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
package_path="$(readlink -f "${1:-result}")"
|
||||
test_workspace="$(mktemp -d)"
|
||||
trap 'rm -rf "$test_workspace"' EXIT
|
||||
|
||||
# This probe runs on CI without a system Polkit wrapper and never authorizes a service.
|
||||
if [ -x /run/wrappers/bin/pkexec ]; then
|
||||
echo "Run this probe on a host without /run/wrappers/bin/pkexec" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p "$test_workspace/bin"
|
||||
cat > "$test_workspace/bin/pkexec" <<'EOF'
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
test "$#" -eq 4
|
||||
test "$1" = --user
|
||||
test "$2" = root
|
||||
test "$3" = "$GP_TEST_SERVICE_BINARY"
|
||||
test "$4" = --desktop-credentials
|
||||
if ! grep -Eq '^NoNewPrivs:[[:space:]]+0$' /proc/self/status; then
|
||||
echo "Authorization was attempted inside a sandbox" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "Authorization reached the host without NoNewPrivs" >&2
|
||||
exit 126
|
||||
EOF
|
||||
chmod +x "$test_workspace/bin/pkexec"
|
||||
|
||||
check_authorization() {
|
||||
rm -f "$test_workspace/data/gpclient/gpclient.log"
|
||||
if PATH="$test_workspace/bin:$PATH" \
|
||||
XDG_DATA_HOME="$test_workspace/data" \
|
||||
GP_TEST_SERVICE_BINARY="$package_path/bin/gpservice" \
|
||||
"$@"; then
|
||||
echo "The desktop launcher ignored the authorization rejection" >&2
|
||||
exit 1
|
||||
fi
|
||||
grep -Fx 'Authorization reached the host without NoNewPrivs' \
|
||||
"$test_workspace/data/gpclient/gpclient.log"
|
||||
}
|
||||
|
||||
check_authorization "$package_path/bin/gpclient" launch-gui --minimized
|
||||
check_authorization "$package_path/bin/gpclient" --lock-file "$test_workspace/client.lock" launch-gui
|
||||
check_authorization "$package_path/bin/gpgui" --minimized
|
||||
@@ -11,7 +11,7 @@ FLAKE_FILE="$PROJECT_DIR/flake.nix"
|
||||
usage() {
|
||||
echo "Usage: $0 [version] [release-tag]"
|
||||
echo
|
||||
echo "Updates flake.nix fetchzip hashes from the published GitHub release assets."
|
||||
echo "Updates flake.nix prebuilt package 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."
|
||||
}
|
||||
@@ -22,7 +22,7 @@ if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then
|
||||
fi
|
||||
|
||||
if ! command -v nix > /dev/null; then
|
||||
echo "nix is required to calculate unpacked fetchzip hashes" >&2
|
||||
echo "nix is required to calculate release asset hashes" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -61,7 +61,6 @@ prefetch_hash() {
|
||||
store prefetch-file \
|
||||
--hash-type sha256 \
|
||||
--json \
|
||||
--unpack \
|
||||
"$url" \
|
||||
| jq -r '.hash'; then
|
||||
return 0
|
||||
@@ -80,32 +79,32 @@ release_url() {
|
||||
echo "https://github.com/$REPO/releases/download/$release_tag/$asset"
|
||||
}
|
||||
|
||||
source_hash="$(prefetch_hash "$(release_url "globalprotect-openconnect-$version.tar.gz")")"
|
||||
gpgui_x86_64_hash="$(prefetch_hash "$(release_url "gpgui_x86_64.bin.tar.xz")")"
|
||||
gpgui_aarch64_hash="$(prefetch_hash "$(release_url "gpgui_aarch64.bin.tar.xz")")"
|
||||
binary_x86_64_hash="$(prefetch_hash "$(release_url "globalprotect-openconnect_${version}_x86_64.bin.tar.xz")")"
|
||||
binary_aarch64_hash="$(prefetch_hash "$(release_url "globalprotect-openconnect_${version}_aarch64.bin.tar.xz")")"
|
||||
|
||||
SOURCE_HASH="$source_hash" \
|
||||
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" \
|
||||
RELEASE_VERSION="$version" \
|
||||
perl -0pi -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|(releaseVersion = ")[^"]+(";)|$1 . $ENV{"RELEASE_VERSION"} . $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;
|
||||
s|(binaryHashes = \{\n\s*x86_64 = "[^"]+";\n\s*aarch64 = ")[^"]+(";)|$1 . $ENV{"BINARY_AARCH64_HASH"} . $2|e;
|
||||
' "$FLAKE_FILE"
|
||||
|
||||
grep -F "$source_hash" "$FLAKE_FILE" > /dev/null
|
||||
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
|
||||
|
||||
grep -F "releaseVersion = \"$version\";" "$FLAKE_FILE" > /dev/null
|
||||
|
||||
echo "Updated flake.nix hashes for v$version assets from $release_tag"
|
||||
Executable
+108
@@ -0,0 +1,108 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Usage: ./scripts/upload-release-assets.sh [--clobber] <tag> <file> [file...]
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
REPOSITORY="${RELEASE_REPOSITORY:-${GITHUB_REPOSITORY:-yuezk/GlobalProtect-openconnect}}"
|
||||
MAX_ATTEMPTS=8
|
||||
CLOBBER=false
|
||||
|
||||
if [[ "${1:-}" == "--clobber" ]]; then
|
||||
CLOBBER=true
|
||||
shift
|
||||
fi
|
||||
TAG="${1:-}"
|
||||
|
||||
if [[ -z "$TAG" || "$#" -lt 2 ]]; then
|
||||
echo "Usage: $0 [--clobber] <tag> <file> [file...]" >&2
|
||||
exit 2
|
||||
fi
|
||||
shift
|
||||
|
||||
if [[ -z "${GH_TOKEN:-}" ]]; then
|
||||
echo "GH_TOKEN is not configured" >&2
|
||||
exit 1
|
||||
fi
|
||||
API_HEADERS=(
|
||||
-H "Authorization: Bearer $GH_TOKEN"
|
||||
-H 'Accept: application/vnd.github+json'
|
||||
-H 'X-GitHub-Api-Version: 2022-11-28'
|
||||
)
|
||||
RELEASE_ID="$(curl --fail --silent --show-error \
|
||||
"${API_HEADERS[@]}" \
|
||||
"https://api.github.com/repos/$REPOSITORY/releases/tags/$TAG" | jq -r .id)"
|
||||
|
||||
file_digest() {
|
||||
if command -v sha256sum >/dev/null; then
|
||||
sha256sum "$1" | awk '{ print $1 }'
|
||||
else
|
||||
shasum -a 256 "$1" | awk '{ print $1 }'
|
||||
fi
|
||||
}
|
||||
|
||||
upload_asset() {
|
||||
local file=$1
|
||||
local asset
|
||||
local asset_id
|
||||
local assets_json
|
||||
local encoded_asset
|
||||
local local_digest
|
||||
local remote_digest
|
||||
local attempt=1
|
||||
local delay
|
||||
|
||||
if [[ ! -f "$file" ]]; then
|
||||
echo "Release asset does not exist: $file" >&2
|
||||
return 1
|
||||
fi
|
||||
asset="$(basename "$file")"
|
||||
encoded_asset="$(jq -rn --arg name "$asset" '$name | @uri')"
|
||||
local_digest="sha256:$(file_digest "$file")"
|
||||
|
||||
while (( attempt <= MAX_ATTEMPTS )); do
|
||||
assets_json="$(curl --fail --silent --show-error \
|
||||
"${API_HEADERS[@]}" \
|
||||
"https://api.github.com/repos/$REPOSITORY/releases/$RELEASE_ID/assets?per_page=100")"
|
||||
asset_id="$(jq -r --arg name "$asset" \
|
||||
'[.[] | select(.name == $name)] | first | .id // empty' <<<"$assets_json")"
|
||||
if [[ -n "$asset_id" ]]; then
|
||||
remote_digest="$(jq -r --arg name "$asset" \
|
||||
'.[] | select(.name == $name) | .digest // empty' <<<"$assets_json")"
|
||||
if [[ "$CLOBBER" == "false" && "$remote_digest" == "$local_digest" ]]; then
|
||||
echo "$asset is already uploaded with the expected digest"
|
||||
return 0
|
||||
fi
|
||||
if [[ "$CLOBBER" == "false" ]]; then
|
||||
echo "Refusing to replace immutable release asset: $asset" >&2
|
||||
return 1
|
||||
fi
|
||||
curl --fail --silent --show-error \
|
||||
"${API_HEADERS[@]}" \
|
||||
--request DELETE \
|
||||
"https://api.github.com/repos/$REPOSITORY/releases/assets/$asset_id"
|
||||
fi
|
||||
|
||||
if curl --fail --silent --show-error \
|
||||
"${API_HEADERS[@]}" \
|
||||
--request POST \
|
||||
-H 'Content-Type: application/octet-stream' \
|
||||
--data-binary "@$file" \
|
||||
"https://uploads.github.com/repos/$REPOSITORY/releases/$RELEASE_ID/assets?name=$encoded_asset" \
|
||||
>/dev/null; then
|
||||
return 0
|
||||
fi
|
||||
if (( attempt >= MAX_ATTEMPTS )); then
|
||||
echo "Failed to upload release asset after $attempt attempts: $asset" >&2
|
||||
return 1
|
||||
fi
|
||||
delay=$((attempt * 3))
|
||||
echo "GitHub upload failed; retrying in ${delay}s" >&2
|
||||
sleep "$delay"
|
||||
((attempt += 1))
|
||||
done
|
||||
}
|
||||
|
||||
for file in "$@"; do
|
||||
upload_asset "$file"
|
||||
done
|
||||
Executable
+129
@@ -0,0 +1,129 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
if [[ $# -ne 1 ]]; then
|
||||
echo "Usage: $0 <gpgui-repository>" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
GP_DIR="$(dirname "$SCRIPT_DIR")"
|
||||
GPGUI_DIR="$1"
|
||||
GPGUI_APP_DIR="$GPGUI_DIR/apps/desktop"
|
||||
|
||||
verify_same_file() {
|
||||
local source_file="$1"
|
||||
local packaged_file="$2"
|
||||
|
||||
if ! cmp --silent "$source_file" "$packaged_file"; then
|
||||
echo "Linux desktop asset is out of sync: $packaged_file" >&2
|
||||
echo "Expected it to match: $source_file" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
verify_contains() {
|
||||
local file="$1"
|
||||
local expected="$2"
|
||||
|
||||
if ! grep -Fqx "$expected" "$file"; then
|
||||
echo "Linux desktop asset is missing '$expected': $file" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
verify_absent() {
|
||||
local file="$1"
|
||||
|
||||
if [[ -e "$file" ]]; then
|
||||
echo "Obsolete Linux desktop asset is still present: $file" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
verify_same_file \
|
||||
"$GPGUI_APP_DIR/src-tauri/icons/32x32.png" \
|
||||
"$GP_DIR/packaging/files/usr/share/icons/hicolor/32x32/apps/gpgui.png"
|
||||
verify_same_file \
|
||||
"$GPGUI_APP_DIR/src-tauri/icons/128x128.png" \
|
||||
"$GP_DIR/packaging/files/usr/share/icons/hicolor/128x128/apps/gpgui.png"
|
||||
verify_same_file \
|
||||
"$GPGUI_APP_DIR/src-tauri/icons/[email protected]" \
|
||||
"$GP_DIR/packaging/files/usr/share/icons/hicolor/256x256/apps/gpgui.png"
|
||||
verify_same_file \
|
||||
"$GPGUI_APP_DIR/src-tauri/icons/icon.png" \
|
||||
"$GP_DIR/packaging/files/usr/share/icons/hicolor/256x256@2/apps/gpgui.png"
|
||||
verify_same_file \
|
||||
"$GPGUI_APP_DIR/src-tauri/icons/icon.svg" \
|
||||
"$GP_DIR/packaging/files/usr/share/icons/hicolor/scalable/apps/gpgui.svg"
|
||||
for icon in \
|
||||
gpgui-connected-symbolic.svg \
|
||||
gpgui-disconnected-symbolic.svg \
|
||||
gpgui-connecting-1-symbolic.svg \
|
||||
gpgui-connecting-2-symbolic.svg \
|
||||
gpgui-connecting-3-symbolic.svg \
|
||||
gpgui-connecting-4-symbolic.svg; do
|
||||
verify_same_file \
|
||||
"$GPGUI_APP_DIR/src-tauri/icons/tray/theme/$icon" \
|
||||
"$GP_DIR/packaging/files/usr/share/icons/hicolor/scalable/status/$icon"
|
||||
done
|
||||
verify_same_file \
|
||||
"$GPGUI_APP_DIR/src-tauri/icons/32x32.png" \
|
||||
"$GP_DIR/apps/gpauth/icons/32x32.png"
|
||||
verify_same_file \
|
||||
"$GPGUI_APP_DIR/src-tauri/icons/128x128.png" \
|
||||
"$GP_DIR/apps/gpauth/icons/128x128.png"
|
||||
verify_same_file \
|
||||
"$GPGUI_APP_DIR/src-tauri/icons/[email protected]" \
|
||||
"$GP_DIR/apps/gpauth/icons/[email protected]"
|
||||
verify_same_file \
|
||||
"$GPGUI_APP_DIR/src-tauri/icons/icon.png" \
|
||||
"$GP_DIR/apps/gpauth/icons/icon.png"
|
||||
verify_same_file \
|
||||
"$GPGUI_APP_DIR/src-tauri/icons/32x32.png" \
|
||||
"$GP_DIR/apps/gpgui-helper/src-tauri/icons/32x32.png"
|
||||
verify_same_file \
|
||||
"$GPGUI_APP_DIR/src-tauri/icons/128x128.png" \
|
||||
"$GP_DIR/apps/gpgui-helper/src-tauri/icons/128x128.png"
|
||||
verify_same_file \
|
||||
"$GPGUI_APP_DIR/src-tauri/icons/[email protected]" \
|
||||
"$GP_DIR/apps/gpgui-helper/src-tauri/icons/[email protected]"
|
||||
verify_same_file \
|
||||
"$GPGUI_APP_DIR/src-tauri/icons/icon.png" \
|
||||
"$GP_DIR/apps/gpgui-helper/src-tauri/icons/icon.png"
|
||||
verify_same_file \
|
||||
"$GPGUI_APP_DIR/src-tauri/icons/icon.svg" \
|
||||
"$GP_DIR/apps/gpgui-helper/src-tauri/icons/icon.svg"
|
||||
verify_same_file \
|
||||
"$GPGUI_APP_DIR/src-tauri/icons/icon.icns" \
|
||||
"$GP_DIR/apps/gpgui-helper/src-tauri/icons/icon.icns"
|
||||
verify_same_file \
|
||||
"$GPGUI_APP_DIR/src-tauri/icons/icon.ico" \
|
||||
"$GP_DIR/apps/gpgui-helper/src-tauri/icons/icon.ico"
|
||||
verify_same_file \
|
||||
"$GPGUI_APP_DIR/src-tauri/icons/icon-small.svg" \
|
||||
"$GP_DIR/apps/gpgui-helper/src/assets/icon-small.svg"
|
||||
verify_contains \
|
||||
"$GPGUI_APP_DIR/gpgui.desktop.in" \
|
||||
"Exec=/usr/bin/gpclient launch-gui %u"
|
||||
verify_contains \
|
||||
"$GPGUI_APP_DIR/gpgui.desktop.in" \
|
||||
"MimeType=x-scheme-handler/globalprotectcallback;"
|
||||
verify_contains \
|
||||
"$GP_DIR/packaging/files/usr/share/applications/gpgui.desktop" \
|
||||
"Exec=/usr/bin/gpclient launch-gui %u"
|
||||
verify_contains \
|
||||
"$GP_DIR/packaging/files/usr/share/applications/gpgui.desktop" \
|
||||
"MimeType=x-scheme-handler/globalprotectcallback;"
|
||||
verify_contains \
|
||||
"$GP_DIR/packaging/bsd/gpgui.desktop" \
|
||||
"Exec=/usr/local/bin/gpclient launch-gui %u"
|
||||
verify_contains \
|
||||
"$GP_DIR/packaging/bsd/gpgui.desktop" \
|
||||
"MimeType=x-scheme-handler/globalprotectcallback;"
|
||||
verify_absent "$GPGUI_APP_DIR/gpauth.desktop"
|
||||
verify_absent "$GP_DIR/packaging/files/usr/share/applications/gpauth.desktop"
|
||||
verify_absent "$GP_DIR/packaging/bsd/gpauth.desktop"
|
||||
|
||||
echo "Linux desktop and tray assets are synchronized"
|
||||
Reference in new issue
Block a user