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
+116
-231
@@ -40,8 +40,8 @@ on:
|
||||
- v*.*.*
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
group: ${{ github.workflow }}-${{ github.event_name == 'workflow_dispatch' && 'release' || github.ref }}
|
||||
cancel-in-progress: ${{ github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/') }}
|
||||
|
||||
jobs:
|
||||
test-gp:
|
||||
@@ -333,232 +333,88 @@ jobs:
|
||||
gpgui-source/*.bin.tar.xz
|
||||
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) }}
|
||||
runs-on: macos-26
|
||||
environment: macos-release
|
||||
name: build-gpgui (macOS, arm64)
|
||||
permissions:
|
||||
contents: read
|
||||
runs-on: ubuntu-latest
|
||||
name: trigger private macOS release
|
||||
outputs:
|
||||
archive_name: ${{ steps.release.outputs.archive_name }}
|
||||
run_id: ${{ steps.dispatch.outputs.run_id }}
|
||||
run_url: ${{ steps.dispatch.outputs.run_url }}
|
||||
steps:
|
||||
- name: Verify runner architecture
|
||||
run: test "$(uname -m)" = arm64
|
||||
- name: Dispatch private macOS release
|
||||
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
|
||||
with:
|
||||
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
|
||||
if [[ -z "${GH_TOKEN:-}" ]]; then
|
||||
echo "GPGUI_ACTIONS_TOKEN is not configured" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
archive_name="GPConnect_${artifact_version}_arm64.zip"
|
||||
{
|
||||
echo "MACOS_BUILD_NUMBER=$build_number"
|
||||
echo "MACOS_ARTIFACT_VERSION=$artifact_version"
|
||||
echo "SPARKLE_FEED_URL=$feed_url"
|
||||
echo "RELEASE_TAG=$release_tag"
|
||||
echo "UPDATE_CHANNEL=$channel"
|
||||
} >> "$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
|
||||
gp_ref_path="$(jq -rn --arg ref "$GP_REF" '$ref | @uri')"
|
||||
gpgui_ref_path="$(jq -rn --arg ref "$GPGUI_REF" '$ref | @uri')"
|
||||
gp_sha="$(GH_TOKEN="$PUBLIC_GH_TOKEN" gh api \
|
||||
"repos/yuezk/GlobalProtect-openconnect/commits/$gp_ref_path" --jq .sha)"
|
||||
gpgui_sha="$(gh api "repos/yuezk/gpgui/commits/$gpgui_ref_path" --jq .sha)"
|
||||
if [[ -z "$gp_sha" || -z "$gpgui_sha" ]]; then
|
||||
echo "Could not resolve release source refs" >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
if [[ "$UPDATE_CHANNEL" == "stable" ]]; then
|
||||
for variable in \
|
||||
APPLE_NOTARY_KEY_P8 \
|
||||
APPLE_NOTARY_KEY_ID \
|
||||
APPLE_NOTARY_ISSUER_ID; do
|
||||
if [[ -z "${!variable:-}" ]]; then
|
||||
echo "$variable is not configured" >&2
|
||||
exit 1
|
||||
|
||||
expected_title="macOS $CHANNEL $RELEASE_TAG ($REQUEST_ID)"
|
||||
jq -n \
|
||||
--arg request_id "$REQUEST_ID" \
|
||||
--arg channel "$CHANNEL" \
|
||||
--arg release_tag "$RELEASE_TAG" \
|
||||
--arg gp_ref "$gp_sha" \
|
||||
--arg gpgui_ref "$gpgui_sha" \
|
||||
'{
|
||||
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
|
||||
sleep 3
|
||||
done
|
||||
fi
|
||||
|
||||
keychain="$RUNNER_TEMP/gp-connect.keychain-db"
|
||||
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
|
||||
echo "Could not locate the dispatched private workflow run" >&2
|
||||
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:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -793,7 +649,6 @@ jobs:
|
||||
- build-gp
|
||||
- build-docker-image
|
||||
- build-gpgui
|
||||
- build-gpgui-macos
|
||||
- setup-bsd-matrix
|
||||
- build-gpgui-frontend
|
||||
- build-bsd
|
||||
@@ -803,7 +658,6 @@ jobs:
|
||||
env:
|
||||
NEEDS_JSON: ${{ toJson(needs) }}
|
||||
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/') }}
|
||||
run: |
|
||||
python3 - <<'PY'
|
||||
@@ -813,7 +667,6 @@ jobs:
|
||||
|
||||
needs = json.loads(os.environ["NEEDS_JSON"])
|
||||
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"
|
||||
failed = []
|
||||
|
||||
@@ -825,8 +678,6 @@ jobs:
|
||||
continue
|
||||
elif name in {"build-gpgui-frontend", "build-bsd"} and result == "skipped" and not bsd_matrix_enabled:
|
||||
continue
|
||||
elif name == "build-gpgui-macos" and result == "skipped" and not macos_build_enabled:
|
||||
continue
|
||||
elif result == "skipped":
|
||||
failed.append(f"{name}: {result}")
|
||||
|
||||
@@ -893,19 +744,53 @@ jobs:
|
||||
run: |
|
||||
cd gh-release/gp/scripts && ./gh-release.sh "$RELEASE_TAG"
|
||||
|
||||
publish-macos-appcast:
|
||||
if: ${{ always() && needs.gh-release.result == 'success' && needs.build-gpgui-macos.result == 'success' }}
|
||||
permissions:
|
||||
contents: write
|
||||
wait-gpgui-macos:
|
||||
if: ${{ always() && needs.trigger-gpgui-macos.result != 'skipped' }}
|
||||
needs:
|
||||
- gh-release
|
||||
- build-gpgui-macos
|
||||
uses: ./.github/workflows/publish-macos-appcast.yaml
|
||||
with:
|
||||
channel: ${{ github.event_name == 'workflow_dispatch' && 'snapshot' || 'stable' }}
|
||||
release_tag: ${{ github.event_name == 'workflow_dispatch' && 'snapshot' || github.ref_name }}
|
||||
archive_name: ${{ needs.build-gpgui-macos.outputs.archive_name }}
|
||||
secrets: inherit
|
||||
- trigger-gpgui-macos
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 130
|
||||
steps:
|
||||
- name: Wait for private macOS release
|
||||
env:
|
||||
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:
|
||||
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
|
||||
@@ -272,13 +272,6 @@ jobs:
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
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
|
||||
run: |
|
||||
shopt -s nullglob
|
||||
@@ -290,7 +283,6 @@ jobs:
|
||||
mv "$file" "${file%.apk}-aarch64.apk"
|
||||
done
|
||||
- name: Generate release asset checksums
|
||||
id: release-assets
|
||||
run: |
|
||||
cd gh-release/gp
|
||||
mkdir -p .build
|
||||
@@ -303,21 +295,20 @@ jobs:
|
||||
digest=$(sha256sum "$file" | cut -d ' ' -f 1)
|
||||
printf '%s %s\n' "$digest" "$(basename "$file")"
|
||||
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
|
||||
uses: actions/attest-build-provenance@v4
|
||||
with:
|
||||
subject-checksums: gh-release/gp/.build/release-assets.sha256
|
||||
- name: Update release
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
token: ${{ secrets.GH_PAT }}
|
||||
prerelease: ${{ contains(github.ref, 'snapshot') }}
|
||||
fail_on_unmatched_files: true
|
||||
tag_name: ${{ inputs.tag }}
|
||||
body_path: ${{ steps.release-notes.outputs.path }}
|
||||
files: ${{ steps.release-assets.outputs.files }}
|
||||
- name: Upload release assets
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GH_PAT }}
|
||||
run: |
|
||||
mapfile -t files < gh-release/gp/.build/release-assets.txt
|
||||
if [[ "${{ inputs.tag }}" == "snapshot" ]]; then
|
||||
for file in "${files[@]}"; do
|
||||
gh release upload snapshot "$file" --clobber \
|
||||
--repo yuezk/GlobalProtect-openconnect
|
||||
done
|
||||
else
|
||||
gh-release/gp/scripts/upload-release-assets.sh "${{ inputs.tag }}" "${files[@]}"
|
||||
fi
|
||||
+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