mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-18 22:16:18 -05:00
ci: delegate macOS releases to gpgui
This commit is contained in:
5 files changed
+231
-525
No files matched your search
+29
-22
@@ -135,16 +135,19 @@ upload_file() {
|
||||
release_snapshot() {
|
||||
mapfile -t files < <(release_assets)
|
||||
local existing_assets
|
||||
local includes_macos=false
|
||||
local is_current
|
||||
local asset
|
||||
local file
|
||||
for file in "${files[@]}"; do
|
||||
if [[ "$(basename "$file")" == GPConnect_*_arm64.* ]]; then
|
||||
includes_macos=true
|
||||
break
|
||||
fi
|
||||
done
|
||||
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 first so a transient cleanup failure cannot leave the snapshot
|
||||
@@ -153,7 +156,7 @@ release_snapshot() {
|
||||
|
||||
if ! existing_assets="$(release_asset_names)"; then
|
||||
echo "::warning::Could not list stale snapshot assets for cleanup" >&2
|
||||
return 0
|
||||
existing_assets=""
|
||||
fi
|
||||
while IFS= read -r asset; do
|
||||
if [[ -z "$asset" || "$asset" == "appcast.xml" ]]; then
|
||||
@@ -171,33 +174,37 @@ release_snapshot() {
|
||||
continue
|
||||
fi
|
||||
|
||||
if [[ "$includes_macos" == "false" && \
|
||||
"$asset" == GPConnect_*_arm64.* ]]; then
|
||||
# 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
|
||||
|
||||
Executable
+73
@@ -0,0 +1,73 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Usage: ./scripts/upload-release-assets.sh <tag> <file> [file...]
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
REPOSITORY="${GITHUB_REPOSITORY:-yuezk/GlobalProtect-openconnect}"
|
||||
TAG="${1:-}"
|
||||
MAX_ATTEMPTS=8
|
||||
|
||||
if [[ -z "$TAG" || "$#" -lt 2 ]]; then
|
||||
echo "Usage: $0 <tag> <file> [file...]" >&2
|
||||
exit 2
|
||||
fi
|
||||
shift
|
||||
|
||||
file_digest() {
|
||||
if command -v sha256sum >/dev/null; then
|
||||
sha256sum "$1" | awk '{ print $1 }'
|
||||
else
|
||||
shasum -a 256 "$1" | awk '{ print $1 }'
|
||||
fi
|
||||
}
|
||||
|
||||
upload_immutable() {
|
||||
local file=$1
|
||||
local asset
|
||||
local assets_json
|
||||
local local_digest
|
||||
local remote_digest
|
||||
local remote_exists
|
||||
local attempt=1
|
||||
local delay
|
||||
|
||||
if [[ ! -f "$file" ]]; then
|
||||
echo "Release asset does not exist: $file" >&2
|
||||
return 1
|
||||
fi
|
||||
asset="$(basename "$file")"
|
||||
local_digest="sha256:$(file_digest "$file")"
|
||||
|
||||
while (( attempt <= MAX_ATTEMPTS )); do
|
||||
assets_json="$(gh release view "$TAG" --repo "$REPOSITORY" --json assets)"
|
||||
remote_exists="$(jq -r --arg name "$asset" \
|
||||
'[.assets[] | select(.name == $name)] | length' <<<"$assets_json")"
|
||||
if [[ "$remote_exists" != "0" ]]; 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
|
||||
echo "Refusing to replace immutable release asset: $asset" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
if gh release upload "$TAG" "$file" --repo "$REPOSITORY"; 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_immutable "$file"
|
||||
done
|
||||
Reference in new issue
Block a user