Compare commits

..
Author SHA1 Message Date
Kevin Yue 812965f020 fix: align GUI dependency pruning across packages 2026-08-05 15:41:08 +08:00
Kevin Yue 5c3b7d118a fix: correct RPM dependencies and upgrade cleanup 2026-08-05 15:41:08 +08:00
Kevin Yue 4fdcb15629 chore: sync browser launcher lockfile version 2026-08-05 15:41:07 +08:00
Kevin Yue 88f4623f52 Merge remote-tracking branch 'origin/main' into fix/vpn-client-fixes 2026-08-05 14:26:15 +08:00
Ronald Hötschl 0c2d4830b5 Remove GUI dependencies from apk when GUI components are disabled (#638) 2026-08-05 14:23:36 +08:00
Kevin Yue 3d2dfe4be0 Merge remote-tracking branch 'origin/main' into fix/vpn-client-fixes 2026-08-05 13:53:45 +08:00
github-actions[bot] 3c49eab0c8 chore: update flake hashes for v2.6.5 (#640) 2026-08-05 12:23:53 +08:00
Kevin Yue 13ec7dfc37 Merge pull request #639 from yuezk/release/2.6.5
chore: merge 2.6.5 release
2026-08-05 12:13:22 +08:00
Kevin Yue e98fd7894a ci: build FreeBSD package on 14.4 2026-08-05 11:11:46 +08:00
Kevin Yue 6f860d3dff fix: avoid reformatting VPN progress messages 2026-08-05 10:27:19 +08:00
Kevin Yue 5902bee5ff chore: prepare 2.6.5 release 2026-08-05 10:16:07 +08:00
Kevin Yue 8c831b1fc2 fix: preserve lock files owned by another process 2026-08-05 10:08:23 +08:00
Kevin Yue 912bf3046d ci: allow explicit release repository 2026-08-01 01:00:53 +08:00
Kevin Yue 4a12de6156 ci: upload release assets with curl 2026-08-01 00:44:05 +08:00
Kevin Yue b0b8e5ec32 ci: upload release assets through the REST API 2026-08-01 00:19:54 +08:00
Kevin Yue cfe8430cae ci: delegate macOS releases to gpgui 2026-07-31 23:41:52 +08:00
13 changed files with 361 additions and 555 deletions

No files matched your search

+116 -231
View File
@@ -40,8 +40,8 @@ on:
- v*.*.* - v*.*.*
concurrency: concurrency:
group: ${{ github.workflow }}-${{ github.ref }} group: ${{ github.workflow }}-${{ github.event_name == 'workflow_dispatch' && 'release' || github.ref }}
cancel-in-progress: true cancel-in-progress: ${{ github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/') }}
jobs: jobs:
test-gp: test-gp:
@@ -333,232 +333,88 @@ jobs:
gpgui-source/*.bin.tar.xz gpgui-source/*.bin.tar.xz
gpgui-source/*.bin.tar.xz.sha256 gpgui-source/*.bin.tar.xz.sha256
build-gpgui-macos: trigger-gpgui-macos:
if: ${{ startsWith(github.ref, 'refs/tags/') || (github.event_name == 'workflow_dispatch' && inputs.build_macos) }} if: ${{ startsWith(github.ref, 'refs/tags/') || (github.event_name == 'workflow_dispatch' && inputs.build_macos) }}
runs-on: macos-26 permissions:
environment: macos-release contents: read
name: build-gpgui (macOS, arm64) runs-on: ubuntu-latest
name: trigger private macOS release
outputs: outputs:
archive_name: ${{ steps.release.outputs.archive_name }} run_id: ${{ steps.dispatch.outputs.run_id }}
run_url: ${{ steps.dispatch.outputs.run_url }}
steps: steps:
- name: Verify runner architecture - name: Dispatch private macOS release
run: test "$(uname -m)" = arm64 id: dispatch
env:
GH_TOKEN: ${{ secrets.GPGUI_ACTIONS_TOKEN }}
PUBLIC_GH_TOKEN: ${{ github.token }}
CHANNEL: ${{ github.event_name == 'workflow_dispatch' && 'snapshot' || 'stable' }}
RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && 'snapshot' || github.ref_name }}
GP_REF: ${{ github.event_name == 'workflow_dispatch' && inputs.gp_branch || github.ref_name }}
GPGUI_REF: ${{ github.event_name == 'workflow_dispatch' && inputs.gpgui_branch || github.ref_name }}
REQUEST_ID: ${{ github.run_id }}.${{ github.run_attempt }}.macos
run: |
set -euo pipefail
- uses: pnpm/action-setup@v5 if [[ -z "${GH_TOKEN:-}" ]]; then
with: echo "GPGUI_ACTIONS_TOKEN is not configured" >&2
version: 9.15.1
- name: Prepare workspace
run: rm -rf gpgui-source && mkdir gpgui-source
- name: Checkout GlobalProtect-openconnect
uses: actions/checkout@v6
with:
token: ${{ secrets.GH_PAT }}
repository: yuezk/GlobalProtect-openconnect
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.gp_branch || github.ref }}
path: gpgui-source/gp
submodules: recursive
- name: Checkout gpgui
uses: actions/checkout@v6
with:
token: ${{ secrets.GH_PAT }}
repository: yuezk/gpgui
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.gpgui_branch || github.ref_name }}
path: gpgui-source/gpgui
- uses: actions/setup-node@v6
with:
node-version: 22
cache: pnpm
cache-dependency-path: gpgui-source/gpgui/app/pnpm-lock.yaml
- name: Validate release versions
id: release
run: |
set -euo pipefail
gp_version="$(sed -n 's/^version = "\([^"]*\)"/\1/p' gpgui-source/gp/Cargo.toml | head -1)"
gpgui_version="$(sed -n 's/^version = "\([^"]*\)"/\1/p' gpgui-source/gpgui/Cargo.toml | head -1)"
if [[ -z "$gp_version" || "$gp_version" != "$gpgui_version" ]]; then
echo "gp and gpgui versions must match: gp=$gp_version, gpgui=$gpgui_version" >&2
exit 1
fi
build_number="${{ github.run_number }}.${{ github.run_attempt }}"
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
channel="snapshot"
release_tag="snapshot"
artifact_version="$gpgui_version-snapshot.$build_number"
feed_url="https://github.com/${{ github.repository }}/releases/download/snapshot/appcast.xml"
else
channel="stable"
release_tag="${{ github.ref_name }}"
artifact_version="$gpgui_version"
feed_url="https://github.com/${{ github.repository }}/releases/latest/download/appcast.xml"
if [[ "$release_tag" != "v$gpgui_version" ]]; then
echo "Release tag $release_tag does not match gpgui version $gpgui_version" >&2
exit 1 exit 1
fi fi
fi
archive_name="GPConnect_${artifact_version}_arm64.zip" gp_ref_path="$(jq -rn --arg ref "$GP_REF" '$ref | @uri')"
{ gpgui_ref_path="$(jq -rn --arg ref "$GPGUI_REF" '$ref | @uri')"
echo "MACOS_BUILD_NUMBER=$build_number" gp_sha="$(GH_TOKEN="$PUBLIC_GH_TOKEN" gh api \
echo "MACOS_ARTIFACT_VERSION=$artifact_version" "repos/yuezk/GlobalProtect-openconnect/commits/$gp_ref_path" --jq .sha)"
echo "SPARKLE_FEED_URL=$feed_url" gpgui_sha="$(gh api "repos/yuezk/gpgui/commits/$gpgui_ref_path" --jq .sha)"
echo "RELEASE_TAG=$release_tag" if [[ -z "$gp_sha" || -z "$gpgui_sha" ]]; then
echo "UPDATE_CHANNEL=$channel" echo "Could not resolve release source refs" >&2
} >> "$GITHUB_ENV"
echo "archive_name=$archive_name" >> "$GITHUB_OUTPUT"
- name: Install build dependencies
run: |
brew install \
autoconf \
automake \
create-dmg \
dylibbundler \
gettext \
gmp \
gnutls \
libidn2 \
libtool \
libtasn1 \
libunistring \
lz4 \
nettle \
openssl@3 \
p11-kit \
pkgconf
- name: Import signing identity
env:
MACOS_CERTIFICATE_P12: ${{ secrets.MACOS_CERTIFICATE_P12 }}
MACOS_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PASSWORD }}
APPLE_NOTARY_KEY_P8: ${{ secrets.APPLE_NOTARY_KEY_P8 }}
APPLE_NOTARY_KEY_ID: ${{ secrets.APPLE_NOTARY_KEY_ID }}
APPLE_NOTARY_ISSUER_ID: ${{ secrets.APPLE_NOTARY_ISSUER_ID }}
run: |
set -euo pipefail
for variable in \
MACOS_CERTIFICATE_P12 \
MACOS_CERTIFICATE_PASSWORD; do
if [[ -z "${!variable:-}" ]]; then
echo "$variable is not configured" >&2
exit 1 exit 1
fi fi
done
if [[ "$UPDATE_CHANNEL" == "stable" ]]; then expected_title="macOS $CHANNEL $RELEASE_TAG ($REQUEST_ID)"
for variable in \ jq -n \
APPLE_NOTARY_KEY_P8 \ --arg request_id "$REQUEST_ID" \
APPLE_NOTARY_KEY_ID \ --arg channel "$CHANNEL" \
APPLE_NOTARY_ISSUER_ID; do --arg release_tag "$RELEASE_TAG" \
if [[ -z "${!variable:-}" ]]; then --arg gp_ref "$gp_sha" \
echo "$variable is not configured" >&2 --arg gpgui_ref "$gpgui_sha" \
exit 1 '{
ref: "main",
inputs: {
request_id: $request_id,
channel: $channel,
release_tag: $release_tag,
gp_ref: $gp_ref,
gpgui_ref: $gpgui_ref
}
}' | gh api --method POST \
repos/yuezk/gpgui/actions/workflows/release-macos.yaml/dispatches \
--input -
run_id=""
run_url=""
for _ in {1..40}; do
runs="$(gh api \
'repos/yuezk/gpgui/actions/workflows/release-macos.yaml/runs?event=workflow_dispatch&per_page=50')"
run_id="$(jq -r --arg title "$expected_title" \
'[.workflow_runs[] | select(.display_title == $title)] | first | .id // empty' \
<<<"$runs")"
run_url="$(jq -r --arg title "$expected_title" \
'[.workflow_runs[] | select(.display_title == $title)] | first | .html_url // empty' \
<<<"$runs")"
if [[ -n "$run_id" ]]; then
{
echo "run_id=$run_id"
echo "run_url=$run_url"
} >> "$GITHUB_OUTPUT"
echo "Triggered private workflow: $run_url"
exit 0
fi fi
sleep 3
done done
fi
keychain="$RUNNER_TEMP/gp-connect.keychain-db" echo "Could not locate the dispatched private workflow run" >&2
keychain_password="$(openssl rand -hex 24)"
certificate="$RUNNER_TEMP/signing-identity.p12"
printf '%s' "$MACOS_CERTIFICATE_P12" | base64 -D > "$certificate"
chmod 600 "$certificate"
security create-keychain -p "$keychain_password" "$keychain"
security set-keychain-settings -lut 21600 "$keychain"
security unlock-keychain -p "$keychain_password" "$keychain"
security import "$certificate" -k "$keychain" \
-P "$MACOS_CERTIFICATE_PASSWORD" -A -t cert -f pkcs12
security set-key-partition-list -S apple-tool:,apple: \
-s -k "$keychain_password" "$keychain"
security list-keychains -d user -s "$keychain" login.keychain-db
if [[ "$UPDATE_CHANNEL" == "stable" ]]; then
identity="$(security find-identity -v -p codesigning "$keychain" \
| sed -n 's/.*"\(Developer ID Application:.*\)"/\1/p' | head -1)"
else
identity="$(security find-identity -v -p codesigning "$keychain" \
| sed -n \
-e 's/.*"\(Developer ID Application:.*\)"/\1/p' \
-e 's/.*"\(Apple Development:.*\)"/\1/p' \
| head -1)"
fi
if [[ -z "$identity" ]]; then
echo "A compatible Apple code-signing identity was not found" >&2
exit 1 exit 1
fi
{
echo "CI_KEYCHAIN=$keychain"
echo "MACOS_SIGN_IDENTITY=$identity"
} >> "$GITHUB_ENV"
if [[ "$UPDATE_CHANNEL" == "stable" ]]; then
notary_key="$RUNNER_TEMP/AuthKey.p8"
notary_profile="gp-connect-ci"
printf '%s' "$APPLE_NOTARY_KEY_P8" > "$notary_key"
chmod 600 "$notary_key"
xcrun notarytool store-credentials "$notary_profile" \
--key "$notary_key" \
--key-id "$APPLE_NOTARY_KEY_ID" \
--issuer "$APPLE_NOTARY_ISSUER_ID" \
--keychain "$keychain"
{
echo "APPLE_NOTARY_PROFILE=$notary_profile"
echo "APPLE_NOTARY_KEYCHAIN=$keychain"
} >> "$GITHUB_ENV"
fi
- name: Build macOS release artifacts
env:
SPARKLE_PUBLIC_KEY: ${{ vars.SPARKLE_PUBLIC_KEY }}
run: |
set -euo pipefail
cd gpgui-source/gpgui
if [[ "$UPDATE_CHANNEL" == "stable" ]]; then
build_mode="release"
else
build_mode="development"
export SPARKLE_CREATE_UPDATE_ARCHIVE=1
fi
./scripts/build-macos.sh dmg "$build_mode"
- name: Prepare release assets
run: |
set -euo pipefail
artifact_dir="gpgui-source/artifacts"
mkdir -p "$artifact_dir"
dmg_name="GPConnect_${MACOS_ARTIFACT_VERSION}_arm64.dmg"
archive_name="GPConnect_${MACOS_ARTIFACT_VERSION}_arm64.zip"
mv "gpgui-source/gpgui/target/release/bundle/dmg/GP Connect.dmg" \
"$artifact_dir/$dmg_name"
mv "gpgui-source/gpgui/target/release/bundle/sparkle/$archive_name" \
"$artifact_dir/$archive_name"
for file in "$artifact_dir"/*; do
shasum -a 256 "$file" > "$file.sha256"
done
- name: Upload macOS artifacts
uses: actions/upload-artifact@v7
with:
name: artifact-gpgui-macos-arm64
if-no-files-found: error
path: gpgui-source/artifacts/*
- name: Remove signing keychain
if: ${{ always() }}
run: |
if [[ -n "${CI_KEYCHAIN:-}" && -f "$CI_KEYCHAIN" ]]; then
security delete-keychain "$CI_KEYCHAIN"
fi
setup-bsd-matrix: setup-bsd-matrix:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@@ -793,7 +649,6 @@ jobs:
- build-gp - build-gp
- build-docker-image - build-docker-image
- build-gpgui - build-gpgui
- build-gpgui-macos
- setup-bsd-matrix - setup-bsd-matrix
- build-gpgui-frontend - build-gpgui-frontend
- build-bsd - build-bsd
@@ -803,7 +658,6 @@ jobs:
env: env:
NEEDS_JSON: ${{ toJson(needs) }} NEEDS_JSON: ${{ toJson(needs) }}
BSD_MATRIX_ENABLED: ${{ needs.setup-bsd-matrix.outputs.enabled }} BSD_MATRIX_ENABLED: ${{ needs.setup-bsd-matrix.outputs.enabled }}
MACOS_BUILD_ENABLED: ${{ startsWith(github.ref, 'refs/tags/') || inputs.build_macos }}
IS_TAG: ${{ startsWith(github.ref, 'refs/tags/') }} IS_TAG: ${{ startsWith(github.ref, 'refs/tags/') }}
run: | run: |
python3 - <<'PY' python3 - <<'PY'
@@ -813,7 +667,6 @@ jobs:
needs = json.loads(os.environ["NEEDS_JSON"]) needs = json.loads(os.environ["NEEDS_JSON"])
bsd_matrix_enabled = os.environ["BSD_MATRIX_ENABLED"] == "true" bsd_matrix_enabled = os.environ["BSD_MATRIX_ENABLED"] == "true"
macos_build_enabled = os.environ["MACOS_BUILD_ENABLED"] == "true"
is_tag = os.environ["IS_TAG"] == "true" is_tag = os.environ["IS_TAG"] == "true"
failed = [] failed = []
@@ -825,8 +678,6 @@ jobs:
continue continue
elif name in {"build-gpgui-frontend", "build-bsd"} and result == "skipped" and not bsd_matrix_enabled: elif name in {"build-gpgui-frontend", "build-bsd"} and result == "skipped" and not bsd_matrix_enabled:
continue continue
elif name == "build-gpgui-macos" and result == "skipped" and not macos_build_enabled:
continue
elif result == "skipped": elif result == "skipped":
failed.append(f"{name}: {result}") failed.append(f"{name}: {result}")
@@ -893,19 +744,53 @@ jobs:
run: | run: |
cd gh-release/gp/scripts && ./gh-release.sh "$RELEASE_TAG" cd gh-release/gp/scripts && ./gh-release.sh "$RELEASE_TAG"
publish-macos-appcast: wait-gpgui-macos:
if: ${{ always() && needs.gh-release.result == 'success' && needs.build-gpgui-macos.result == 'success' }} if: ${{ always() && needs.trigger-gpgui-macos.result != 'skipped' }}
permissions:
contents: write
needs: needs:
- gh-release - gh-release
- build-gpgui-macos - trigger-gpgui-macos
uses: ./.github/workflows/publish-macos-appcast.yaml runs-on: ubuntu-latest
with: timeout-minutes: 130
channel: ${{ github.event_name == 'workflow_dispatch' && 'snapshot' || 'stable' }} steps:
release_tag: ${{ github.event_name == 'workflow_dispatch' && 'snapshot' || github.ref_name }} - name: Wait for private macOS release
archive_name: ${{ needs.build-gpgui-macos.outputs.archive_name }} env:
secrets: inherit GH_TOKEN: ${{ secrets.GPGUI_ACTIONS_TOKEN }}
PUBLIC_RELEASE_RESULT: ${{ needs.gh-release.result }}
PRIVATE_RUN_ID: ${{ needs.trigger-gpgui-macos.outputs.run_id }}
PRIVATE_RUN_URL: ${{ needs.trigger-gpgui-macos.outputs.run_url }}
run: |
set -euo pipefail
if [[ -z "$PRIVATE_RUN_ID" ]]; then
echo "The private macOS workflow was not started" >&2
exit 1
fi
if [[ "$PUBLIC_RELEASE_RESULT" != "success" ]]; then
gh api --method POST \
"repos/yuezk/gpgui/actions/runs/$PRIVATE_RUN_ID/cancel" >/dev/null || true
echo "The public release failed; cancelled $PRIVATE_RUN_URL" >&2
exit 1
fi
for _ in $(seq 1 480); do
run="$(gh api "repos/yuezk/gpgui/actions/runs/$PRIVATE_RUN_ID")"
status="$(jq -r '.status' <<<"$run")"
conclusion="$(jq -r '.conclusion // ""' <<<"$run")"
if [[ "$status" == "completed" ]]; then
echo "Private macOS workflow completed: $PRIVATE_RUN_URL"
if [[ "$conclusion" != "success" ]]; then
echo "Private macOS workflow concluded with: $conclusion" >&2
exit 1
fi
exit 0
fi
sleep 15
done
gh api --method POST \
"repos/yuezk/gpgui/actions/runs/$PRIVATE_RUN_ID/cancel" >/dev/null || true
echo "Private macOS workflow timed out: $PRIVATE_RUN_URL" >&2
exit 1
publish-docker-image: publish-docker-image:
needs: needs:
@@ -1,250 +0,0 @@
name: Publish macOS appcast
on:
workflow_call:
inputs:
channel:
required: true
type: string
release_tag:
required: true
type: string
archive_name:
required: false
type: string
default: ''
workflow_dispatch:
inputs:
channel:
description: Update channel
required: true
type: choice
options:
- stable
- snapshot
release_tag:
description: Release containing the macOS update archive
required: true
type: string
archive_name:
description: Exact ZIP asset name; leave empty when the release has one macOS update archive
required: false
type: string
concurrency:
group: macos-appcast-${{ inputs.channel }}
cancel-in-progress: false
jobs:
publish:
runs-on: macos-15
environment: macos-release
permissions:
contents: write
env:
REPOSITORY: ${{ github.repository }}
RELEASE_TAG: ${{ inputs.release_tag }}
CHANNEL: ${{ inputs.channel }}
REQUESTED_ARCHIVE: ${{ inputs.archive_name }}
SPARKLE_VERSION: 2.9.2
SPARKLE_ARCHIVE_SHA256: b83e37436774556ed055e0244b297ef2c790e0737393bf65bf495fcbba6eed65
steps:
- name: Validate inputs
env:
SPARKLE_PRIVATE_KEY: ${{ secrets.SPARKLE_PRIVATE_KEY }}
run: |
set -euo pipefail
if [[ "$CHANNEL" != "stable" && "$CHANNEL" != "snapshot" ]]; then
echo "channel must be stable or snapshot" >&2
exit 1
fi
if [[ "$CHANNEL" == "snapshot" && "$RELEASE_TAG" != "snapshot" ]]; then
echo "The snapshot channel must publish to the snapshot release" >&2
exit 1
fi
if [[ "$CHANNEL" == "stable" && "$RELEASE_TAG" == "snapshot" ]]; then
echo "The stable channel cannot publish to the snapshot release" >&2
exit 1
fi
if [[ -z "$SPARKLE_PRIVATE_KEY" ]]; then
echo "SPARKLE_PRIVATE_KEY is not configured" >&2
exit 1
fi
- name: Prepare Sparkle tools
run: |
set -euo pipefail
archive="$RUNNER_TEMP/Sparkle.zip"
curl --fail --location --silent --show-error \
"https://github.com/sparkle-project/Sparkle/releases/download/$SPARKLE_VERSION/Sparkle-for-Swift-Package-Manager.zip" \
--output "$archive"
echo "$SPARKLE_ARCHIVE_SHA256 $archive" | shasum -a 256 --check
ditto -x -k "$archive" "$RUNNER_TEMP/sparkle"
test -x "$RUNNER_TEMP/sparkle/bin/generate_appcast"
- name: Download update archive
id: archive
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
mkdir -p "$RUNNER_TEMP/updates"
archive_name="$REQUESTED_ARCHIVE"
if [[ -z "$archive_name" ]]; then
archives="$(gh release view "$RELEASE_TAG" --repo "$REPOSITORY" --json assets \
--jq '.assets[].name | select(test("^GPConnect_[0-9A-Za-z._-]+_arm64\\.zip$"))')"
archive_count="$(printf '%s\n' "$archives" | sed '/^$/d' | wc -l | tr -d ' ')"
if [[ "$archive_count" != "1" ]]; then
echo "Expected one macOS update archive on $RELEASE_TAG, found $archive_count" >&2
printf '%s\n' "$archives" >&2
exit 1
fi
archive_name="$archives"
fi
if [[ ! "$archive_name" =~ ^GPConnect_[0-9A-Za-z._-]+_arm64\.zip$ ]]; then
echo "Invalid macOS update archive name: $archive_name" >&2
exit 1
fi
gh release download "$RELEASE_TAG" --repo "$REPOSITORY" \
--pattern "$archive_name" --dir "$RUNNER_TEMP/updates"
echo "name=$archive_name" >> "$GITHUB_OUTPUT"
echo "path=$RUNNER_TEMP/updates/$archive_name" >> "$GITHUB_OUTPUT"
- name: Verify update archive
id: bundle
env:
ARCHIVE_PATH: ${{ steps.archive.outputs.path }}
run: |
set -euo pipefail
extract_dir="$RUNNER_TEMP/extracted"
ditto -x -k "$ARCHIVE_PATH" "$extract_dir"
app="$extract_dir/GP Connect.app"
test -d "$app"
codesign --verify --deep --strict --verbose=2 "$app"
signing_info="$(codesign -d --verbose=4 "$app" 2>&1)"
if [[ "$CHANNEL" == "stable" ]]; then
xcrun stapler validate "$app"
grep -q '^Authority=Developer ID Application:' <<<"$signing_info"
grep -q '^CodeDirectory .*flags=.*runtime' <<<"$signing_info"
else
grep -E -q '^Authority=(Apple Development|Developer ID Application):' \
<<<"$signing_info"
fi
team_identifier="$(sed -n 's/^TeamIdentifier=//p' <<<"$signing_info")"
if [[ -z "$team_identifier" || "$team_identifier" == "not set" ]]; then
echo "Signed application has no Team Identifier" >&2
exit 1
fi
identifier="$(sed -n 's/^Identifier=//p' <<<"$signing_info")"
if [[ "$identifier" != "com.yuezk.gpgui" ]]; then
echo "Unexpected bundle identifier: $identifier" >&2
exit 1
fi
file "$app/Contents/MacOS/gpgui" | grep -q 'arm64'
feed_url="$(plutil -extract SUFeedURL raw "$app/Contents/Info.plist")"
expected_feed="https://github.com/$REPOSITORY/releases/latest/download/appcast.xml"
if [[ "$CHANNEL" == "snapshot" ]]; then
expected_feed="https://github.com/$REPOSITORY/releases/download/snapshot/appcast.xml"
fi
if [[ "$feed_url" != "$expected_feed" ]]; then
echo "Unexpected Sparkle feed URL: $feed_url" >&2
exit 1
fi
bundle_version="$(plutil -extract CFBundleVersion raw "$app/Contents/Info.plist")"
short_version="$(plutil -extract CFBundleShortVersionString raw "$app/Contents/Info.plist")"
if [[ ! "$bundle_version" =~ ^[0-9]+(\.[0-9]+){0,2}$ ]]; then
echo "Invalid bundle version: $bundle_version" >&2
exit 1
fi
echo "version=$bundle_version" >> "$GITHUB_OUTPUT"
echo "short_version=$short_version" >> "$GITHUB_OUTPUT"
- name: Prepare release notes
env:
ARCHIVE_NAME: ${{ steps.archive.outputs.name }}
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
notes="$RUNNER_TEMP/updates/${ARCHIVE_NAME%.zip}.md"
gh release view "$RELEASE_TAG" --repo "$REPOSITORY" --json body --jq '.body // ""' > "$notes"
if [[ ! -s "$notes" ]]; then
printf 'GP Connect %s\n' '${{ steps.bundle.outputs.short_version }}' > "$notes"
fi
- name: Generate appcast
env:
ARCHIVE_NAME: ${{ steps.archive.outputs.name }}
SPARKLE_PRIVATE_KEY: ${{ secrets.SPARKLE_PRIVATE_KEY }}
run: |
set -euo pipefail
embedded_public_key="$(plutil -extract SUPublicEDKey raw \
"$RUNNER_TEMP/extracted/GP Connect.app/Contents/Info.plist")"
derived_public_key="$(swift -e '
import Foundation
import CryptoKit
let encoded = ProcessInfo.processInfo.environment["SPARKLE_PRIVATE_KEY"]!
.trimmingCharacters(in: .whitespacesAndNewlines)
let privateKey = try Curve25519.Signing.PrivateKey(
rawRepresentation: Data(base64Encoded: encoded)!)
print(privateKey.publicKey.rawRepresentation.base64EncodedString())
')"
if [[ "$derived_public_key" != "$embedded_public_key" ]]; then
echo "Sparkle private key does not match the public key embedded in the application" >&2
exit 1
fi
download_prefix="https://github.com/$REPOSITORY/releases/download/$RELEASE_TAG/"
printf '%s' "$SPARKLE_PRIVATE_KEY" | \
"$RUNNER_TEMP/sparkle/bin/generate_appcast" \
--download-url-prefix "$download_prefix" \
--maximum-deltas 0 \
--embed-release-notes \
--ed-key-file - \
"$RUNNER_TEMP/updates"
appcast="$RUNNER_TEMP/updates/appcast.xml"
test -s "$appcast"
grep -Fq "sparkle:version>${{ steps.bundle.outputs.version }}<" "$appcast"
grep -Fq "sparkle:shortVersionString>${{ steps.bundle.outputs.short_version }}<" "$appcast"
grep -Fq "url=\"$download_prefix$ARCHIVE_NAME\"" "$appcast"
grep -q 'sparkle:edSignature=' "$appcast"
- name: Publish appcast
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
gh release upload "$RELEASE_TAG" "$RUNNER_TEMP/updates/appcast.xml" \
--repo "$REPOSITORY" --clobber
- name: Verify published appcast
run: |
set -euo pipefail
if [[ "$CHANNEL" == "stable" ]]; then
feed_url="https://github.com/$REPOSITORY/releases/latest/download/appcast.xml"
else
feed_url="https://github.com/$REPOSITORY/releases/download/$RELEASE_TAG/appcast.xml"
fi
for _ in 1 2 3 4 5 6 7 8 9 10; do
published_appcast="$(curl --fail --location --silent --show-error "$feed_url" || true)"
if grep -Fq "sparkle:version>${{ steps.bundle.outputs.version }}<" <<<"$published_appcast"; then
exit 0
fi
sleep 3
done
echo "Published appcast did not become available at $feed_url" >&2
exit 1
+13 -22
View File
@@ -272,13 +272,6 @@ jobs:
uses: actions/download-artifact@v8 uses: actions/download-artifact@v8
with: with:
path: gh-release path: gh-release
- name: Generate release notes
id: release-notes
run: |
cd gh-release/gp
mkdir -p .build
scripts/release-notes.sh "${{ inputs.tag }}" > .build/release-notes.md
echo "path=$GITHUB_WORKSPACE/gh-release/gp/.build/release-notes.md" >> "$GITHUB_OUTPUT"
- name: Rename APK artifacts - name: Rename APK artifacts
run: | run: |
shopt -s nullglob shopt -s nullglob
@@ -290,7 +283,6 @@ jobs:
mv "$file" "${file%.apk}-aarch64.apk" mv "$file" "${file%.apk}-aarch64.apk"
done done
- name: Generate release asset checksums - name: Generate release asset checksums
id: release-assets
run: | run: |
cd gh-release/gp cd gh-release/gp
mkdir -p .build mkdir -p .build
@@ -303,21 +295,20 @@ jobs:
digest=$(sha256sum "$file" | cut -d ' ' -f 1) digest=$(sha256sum "$file" | cut -d ' ' -f 1)
printf '%s %s\n' "$digest" "$(basename "$file")" printf '%s %s\n' "$digest" "$(basename "$file")"
done < .build/release-assets.txt > .build/release-assets.sha256 done < .build/release-assets.txt > .build/release-assets.sha256
{
echo 'files<<EOF'
cat .build/release-assets.txt
echo EOF
} >> "$GITHUB_OUTPUT"
- name: Attest release assets - name: Attest release assets
uses: actions/attest-build-provenance@v4 uses: actions/attest-build-provenance@v4
with: with:
subject-checksums: gh-release/gp/.build/release-assets.sha256 subject-checksums: gh-release/gp/.build/release-assets.sha256
- name: Update release - name: Upload release assets
uses: softprops/action-gh-release@v1 env:
with: GH_TOKEN: ${{ secrets.GH_PAT }}
token: ${{ secrets.GH_PAT }} run: |
prerelease: ${{ contains(github.ref, 'snapshot') }} mapfile -t files < gh-release/gp/.build/release-assets.txt
fail_on_unmatched_files: true if [[ "${{ inputs.tag }}" == "snapshot" ]]; then
tag_name: ${{ inputs.tag }} for file in "${files[@]}"; do
body_path: ${{ steps.release-notes.outputs.path }} gh release upload snapshot "$file" --clobber \
files: ${{ steps.release-assets.outputs.files }} --repo yuezk/GlobalProtect-openconnect
done
else
gh-release/gp/scripts/upload-release-assets.sh "${{ inputs.tag }}" "${files[@]}"
fi
Generated
+9 -9
View File
@@ -214,7 +214,7 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
[[package]] [[package]]
name = "auth" name = "auth"
version = "2.6.4" version = "2.6.5"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"block2", "block2",
@@ -415,7 +415,7 @@ dependencies = [
[[package]] [[package]]
name = "browser-launcher" name = "browser-launcher"
version = "2.6.4" version = "2.6.5"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"log", "log",
@@ -710,7 +710,7 @@ dependencies = [
[[package]] [[package]]
name = "common" name = "common"
version = "2.6.4" version = "2.6.5"
[[package]] [[package]]
name = "compile-time" name = "compile-time"
@@ -1832,7 +1832,7 @@ dependencies = [
[[package]] [[package]]
name = "gpapi" name = "gpapi"
version = "2.6.4" version = "2.6.5"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"base64 0.22.1", "base64 0.22.1",
@@ -1880,7 +1880,7 @@ dependencies = [
[[package]] [[package]]
name = "gpauth" name = "gpauth"
version = "2.6.4" version = "2.6.5"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"auth", "auth",
@@ -1899,7 +1899,7 @@ dependencies = [
[[package]] [[package]]
name = "gpclient" name = "gpclient"
version = "2.6.4" version = "2.6.5"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"askama", "askama",
@@ -1928,7 +1928,7 @@ dependencies = [
[[package]] [[package]]
name = "gpgui-helper" name = "gpgui-helper"
version = "2.6.4" version = "2.6.5"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"clap", "clap",
@@ -1949,7 +1949,7 @@ dependencies = [
[[package]] [[package]]
name = "gpservice" name = "gpservice"
version = "2.6.4" version = "2.6.5"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"axum", "axum",
@@ -3294,7 +3294,7 @@ dependencies = [
[[package]] [[package]]
name = "openconnect" name = "openconnect"
version = "2.6.4" version = "2.6.5"
dependencies = [ dependencies = [
"autotools", "autotools",
"cc", "cc",
+1 -1
View File
@@ -11,7 +11,7 @@ members = [
[workspace.package] [workspace.package]
rust-version = "1.89" rust-version = "1.89"
version = "2.6.4" version = "2.6.5"
authors = ["Kevin Yue <[email protected]>"] authors = ["Kevin Yue <[email protected]>"]
homepage = "https://github.com/yuezk/GlobalProtect-openconnect" homepage = "https://github.com/yuezk/GlobalProtect-openconnect"
edition = "2024" edition = "2024"
+16 -4
View File
@@ -320,18 +320,19 @@ init-debian: clean-debian tarball
sed -i "s/@RUST_VERSION@/$(RUST_VERSION)/g" .build/deb/$(PKG)/debian/control sed -i "s/@RUST_VERSION@/$(RUST_VERSION)/g" .build/deb/$(PKG)/debian/control
# Remove the GUI dependencies if BUILD_GUI_HELPER is set to 0 # Remove the GUI dependencies if neither GUI component is included
if [ $(BUILD_GUI_HELPER) -eq 0 ]; then \ if [ $(INCLUDE_GUI) -eq 0 ] && [ $(BUILD_GUI_HELPER) -eq 0 ]; then \
sed -i "/libsecret-1-0/d" .build/deb/$(PKG)/debian/control; \ sed -i "/libsecret-1-0/d" .build/deb/$(PKG)/debian/control; \
sed -i "/libayatana-appindicator3-1/d" .build/deb/$(PKG)/debian/control; \ sed -i "/libayatana-appindicator3-1/d" .build/deb/$(PKG)/debian/control; \
sed -i "/gnome-keyring/d" .build/deb/$(PKG)/debian/control; \ sed -i "/gnome-keyring/d" .build/deb/$(PKG)/debian/control; \
fi fi
# Remove the WebKitGTK build dependency only if neither gpauth webview auth nor gpgui-helper needs it # Remove WebKitGTK only if no included component needs it
if [ $(BUILD_GUI_HELPER) -eq 0 ] && [ $(BUILD_WEBVIEW_AUTH) -eq 0 ]; then \ if [ $(INCLUDE_GUI) -eq 0 ] && [ $(BUILD_GUI_HELPER) -eq 0 ] && [ $(BUILD_WEBVIEW_AUTH) -eq 0 ]; then \
sed -i "/libwebkit2gtk-4.1-dev/d" .build/deb/$(PKG)/debian/control; \ sed -i "/libwebkit2gtk-4.1-dev/d" .build/deb/$(PKG)/debian/control; \
fi fi
sed -i "s/@INCLUDE_GUI@/$(INCLUDE_GUI)/g" .build/deb/$(PKG)/debian/rules
sed -i "s/@BUILD_GUI_HELPER@/$(BUILD_GUI_HELPER)/g" .build/deb/$(PKG)/debian/rules sed -i "s/@BUILD_GUI_HELPER@/$(BUILD_GUI_HELPER)/g" .build/deb/$(PKG)/debian/rules
sed -i "s/@BUILD_WEBVIEW_AUTH@/$(BUILD_WEBVIEW_AUTH)/g" .build/deb/$(PKG)/debian/rules sed -i "s/@BUILD_WEBVIEW_AUTH@/$(BUILD_WEBVIEW_AUTH)/g" .build/deb/$(PKG)/debian/rules
sed -i "s/@RUST_VERSION@/$(RUST_VERSION)/g" .build/deb/$(PKG)/debian/rules sed -i "s/@RUST_VERSION@/$(RUST_VERSION)/g" .build/deb/$(PKG)/debian/rules
@@ -433,6 +434,17 @@ init-apk: clean-apk tarball
checksum=$$(sha512sum .build/apk/${PKG}.tar.gz | cut -d' ' -f1); \ checksum=$$(sha512sum .build/apk/${PKG}.tar.gz | cut -d' ' -f1); \
sed -i "s/@SHA512@/$$checksum/g" .build/apk/APKBUILD sed -i "s/@SHA512@/$$checksum/g" .build/apk/APKBUILD
# Remove the GUI dependencies if neither GUI component is included
if [ $(INCLUDE_GUI) -eq 0 ] && [ $(BUILD_GUI_HELPER) -eq 0 ]; then \
sed -i "/^\tlibayatana-appindicator$$/d" .build/apk/APKBUILD; \
sed -i "/^\tlibsecret$$/d" .build/apk/APKBUILD; \
fi
# Remove WebKitGTK only if no included component needs it
if [ $(INCLUDE_GUI) -eq 0 ] && [ $(BUILD_GUI_HELPER) -eq 0 ] && [ $(BUILD_WEBVIEW_AUTH) -eq 0 ]; then \
sed -i "/^\twebkit2gtk-4.1$$/d" .build/apk/APKBUILD; \
fi
apk: init-apk apk: init-apk
cd .build/apk && abuild -r -P "$(CURDIR)/.build/apk/packages" cd .build/apk && abuild -r -P "$(CURDIR)/.build/apk/packages"
+7
View File
@@ -1,5 +1,12 @@
# Changelog # Changelog
## 2.6.5
### Fixed
- Fixed duplicate tray icons caused by both Tauri configuration and application code creating a tray icon (fix [#464](https://github.com/yuezk/GlobalProtect-openconnect/issues/464)).
- Fixed a potential crash when VPN progress messages contain printf-style format specifiers.
## 2.6.4 ## 2.6.4
### Fixed ### Fixed
+47 -2
View File
@@ -29,8 +29,15 @@ impl LockFile {
} }
pub fn unlock(&self) -> anyhow::Result<()> { pub fn unlock(&self) -> anyhow::Result<()> {
std::fs::remove_file(&self.path)?; match std::fs::read_to_string(&self.path) {
Ok(()) Ok(content) if LockInfo::parse(&content).is_ok_and(|info| info.pid == self.pid) => {
std::fs::remove_file(&self.path)?;
Ok(())
}
Ok(_) => Ok(()),
Err(err) if err.kind() == std::io::ErrorKind::NotFound => Ok(()),
Err(err) => Err(err.into()),
}
} }
pub async fn check_health(&self) -> bool { pub async fn check_health(&self) -> bool {
@@ -142,4 +149,42 @@ mod tests {
PathBuf::from("/var/run/gpservice-dev-123/gpservice.lock") PathBuf::from("/var/run/gpservice-dev-123/gpservice.lock")
); );
} }
#[test]
fn unlock_removes_lock_owned_by_process() {
let temp = tempfile::tempdir().unwrap();
let path = temp.path().join("gpservice.lock");
let lock = LockFile::new(&path, 1234);
lock.lock("8080").unwrap();
lock.unlock().unwrap();
assert!(!path.exists());
}
#[test]
fn unlock_preserves_lock_owned_by_another_process() {
let temp = tempfile::tempdir().unwrap();
let path = temp.path().join("gpservice.lock");
let owner = LockFile::new(&path, 1234);
let other = LockFile::new(&path, 5678);
owner.lock("8080").unwrap();
other.unlock().unwrap();
assert_eq!(std::fs::read_to_string(path).unwrap(), "1234:8080");
}
#[test]
fn unlock_ignores_missing_or_malformed_lock() {
let temp = tempfile::tempdir().unwrap();
let path = temp.path().join("gpservice.lock");
let lock = LockFile::new(&path, 1234);
lock.unlock().unwrap();
std::fs::write(&path, "not-a-lock").unwrap();
lock.unlock().unwrap();
assert_eq!(std::fs::read_to_string(path).unwrap(), "not-a-lock");
}
} }
+6 -6
View File
@@ -26,7 +26,7 @@
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml); cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
pname = "globalprotect-openconnect"; pname = "globalprotect-openconnect";
version = cargoToml.workspace.package.version; version = cargoToml.workspace.package.version;
releaseTag = "snapshot"; releaseTag = "v2.6.5";
toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
@@ -37,14 +37,14 @@
src = pkgs.fetchzip { src = pkgs.fetchzip {
url = "https://github.com/yuezk/GlobalProtect-openconnect/releases/download/${releaseTag}/globalprotect-openconnect-${version}.tar.gz"; url = "https://github.com/yuezk/GlobalProtect-openconnect/releases/download/${releaseTag}/globalprotect-openconnect-${version}.tar.gz";
hash = "sha256-0+kwFPmq2F9jN8DIM2OHL/jOu+yDH4DXtB5/8XA3U70="; hash = "sha256-T4jze6/25YTsfuQdcuDfz3kX/ooDB1T0hnWsEBu4xMQ=";
}; };
cpu = pkgs.stdenv.hostPlatform.parsed.cpu.name; cpu = pkgs.stdenv.hostPlatform.parsed.cpu.name;
gpguiHashes = { gpguiHashes = {
x86_64 = "sha256-kMwQ31AYVdrpP52/Gh0Vtq6MTd4iBvweSqtm0rdswmY="; x86_64 = "sha256-wPLsH/b/ZSo2pA/kU1HUGiQ98k8xSihyxGyf5o6tvyU=";
aarch64 = "sha256-GeuAGlIZ2jXJaYJG/wSwrHlZwNtEHRM/SbdN6qKCbmc="; aarch64 = "sha256-WFyPhGD9fLAVYGeMSrMcZhSdfM99uVmWPrH68O+4BfE=";
}; };
gpgui = pkgs.fetchzip { gpgui = pkgs.fetchzip {
@@ -53,8 +53,8 @@
}; };
binaryHashes = { binaryHashes = {
x86_64 = "sha256-Q49FvGUX6BQtZV/oieEPI+K8p1MZaxZZ3/7aKdbgG8I="; x86_64 = "sha256-spaKxruu15ro5lir14nAfy8MPXNQhaoCXcG4PDZ9lfM=";
aarch64 = "sha256-XoJXH2qngOswIGiqvpeziYBhQF8WUP63EFFdY8N8PtM="; aarch64 = "sha256-iu/zE4B4gjk1I5PQY0m/59ZoJ/k5focT0CxYYlJi7+A=";
}; };
binaryPackage = pkgs.fetchzip { binaryPackage = pkgs.fetchzip {
+1
View File
@@ -1,5 +1,6 @@
#!/usr/bin/make -f #!/usr/bin/make -f
export INCLUDE_GUI = @INCLUDE_GUI@
export BUILD_GUI_HELPER = @BUILD_GUI_HELPER@ export BUILD_GUI_HELPER = @BUILD_GUI_HELPER@
export BUILD_WEBVIEW_AUTH = @BUILD_WEBVIEW_AUTH@ export BUILD_WEBVIEW_AUTH = @BUILD_WEBVIEW_AUTH@
export DISABLE_RUST_TOOLCHAIN = 0 export DISABLE_RUST_TOOLCHAIN = 0
@@ -28,16 +28,16 @@ BuildRequires: wget
BuildRequires: file BuildRequires: file
BuildRequires: perl BuildRequires: perl
%if 0%{?suse_version} BuildRequires: pkgconfig(webkit2gtk-4.1)
BuildRequires: webkit2gtk3-devel BuildRequires: (pkgconfig(appindicator3-0.1) or pkgconfig(ayatana-appindicator3-0.1))
%else
BuildRequires: webkit2gtk4.1-devel
%endif
BuildRequires: (libappindicator-gtk3-devel or libappindicator3-1)
BuildRequires: (librsvg2-devel or librsvg-devel) BuildRequires: (librsvg2-devel or librsvg-devel)
Requires: (libappindicator-gtk3 or libayatana-appindicator) %if 0%{?suse_version}
Requires: (libappindicator3-1 or libayatana-appindicator3-1)
%else
Requires: (libappindicator-gtk3 or libayatana-appindicator-gtk3)
%endif
Conflicts: globalprotect-openconnect-snapshot Conflicts: globalprotect-openconnect-snapshot
%global debug_package %{nil} %global debug_package %{nil}
@@ -49,8 +49,8 @@ A GUI for GlobalProtect VPN, based on OpenConnect, supports the SSO authenticati
%setup %setup
%postun %postun
rm -f %{_bindir}/gpgui
if [ "$1" -eq 0 ]; then if [ "$1" -eq 0 ]; then
rm -f %{_bindir}/gpgui
rm -f \ rm -f \
/var/lib/gpclient/scripts/vpnc-script \ /var/lib/gpclient/scripts/vpnc-script \
/var/lib/gpclient/scripts/vpnc-script.metadata || /var/lib/gpclient/scripts/vpnc-script.metadata ||
+29 -22
View File
@@ -135,16 +135,19 @@ upload_file() {
release_snapshot() { release_snapshot() {
mapfile -t files < <(release_assets) mapfile -t files < <(release_assets)
local existing_assets local existing_assets
local includes_macos=false
local is_current local is_current
local asset local asset
local file local file
for file in "${files[@]}"; do local snapshot_commit
if [[ "$(basename "$file")" == GPConnect_*_arm64.* ]]; then
includes_macos=true snapshot_commit="$(git -C "$SCRIPT_DIR/.." rev-parse HEAD)"
break if ! gh -R "$REPO" release view "$TAG" >/dev/null 2>&1; then
fi gh -R "$REPO" release create "$TAG" \
done --prerelease \
--target "$snapshot_commit" \
--title "Snapshot" \
--notes "Rolling snapshot release from trusted CI builds."
fi
echo "Uploading new assets..." echo "Uploading new assets..."
# Upload first so a transient cleanup failure cannot leave the snapshot # Upload first so a transient cleanup failure cannot leave the snapshot
@@ -153,7 +156,7 @@ release_snapshot() {
if ! existing_assets="$(release_asset_names)"; then if ! existing_assets="$(release_asset_names)"; then
echo "::warning::Could not list stale snapshot assets for cleanup" >&2 echo "::warning::Could not list stale snapshot assets for cleanup" >&2
return 0 existing_assets=""
fi fi
while IFS= read -r asset; do while IFS= read -r asset; do
if [[ -z "$asset" || "$asset" == "appcast.xml" ]]; then if [[ -z "$asset" || "$asset" == "appcast.xml" ]]; then
@@ -171,33 +174,37 @@ release_snapshot() {
continue continue
fi fi
if [[ "$includes_macos" == "false" && \ # The appcast publisher removes expired macOS snapshots after the new feed
"$asset" == GPConnect_*_arm64.* ]]; then # is live. Removing them here would temporarily break the current feed.
if [[ "$asset" == GPConnect_*_arm64.* ]]; then
continue continue
fi fi
if ! delete_release_asset "$asset"; then if ! delete_release_asset "$asset"; then
echo "::warning::Could not remove stale snapshot asset: $asset" >&2 echo "::warning::Could not remove stale snapshot asset: $asset" >&2
fi fi
done <<<"$existing_assets" 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() { release_tag() {
echo "Removing existing release..."
gh -R "$REPO" release delete "$TAG" --yes --cleanup-tag || true
echo "Creating release..."
local release_notes_file local release_notes_file
release_notes_file="$(mktemp)" if ! gh -R "$REPO" release view "$TAG" >/dev/null 2>&1; then
"$SCRIPT_DIR/release-notes.sh" "$TAG" > "$release_notes_file" 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 # Upload source tarballs, GUI components, and BSD packages. Other Linux
# packages are built in `release.yml` from the standalone source tarball. # packages are built in `release.yml` from the standalone source tarball.
gh -R "$REPO" release create "$TAG" \ gh -R "$REPO" release create "$TAG" \
--title "$TAG" \ --title "$TAG" \
--notes-file "$release_notes_file" --notes-file "$release_notes_file"
fi
mapfile -t files < <(release_assets) mapfile -t files < <(release_assets)
upload_files "${files[@]}" GITHUB_REPOSITORY="$REPO" "$SCRIPT_DIR/upload-release-assets.sh" "$TAG" "${files[@]}"
} }
if [[ $TAG == *"snapshot" ]]; then if [[ $TAG == *"snapshot" ]]; then
+108
View File
@@ -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