From 703f535444ac6e6dfa46470262c7bfd375f868d4 Mon Sep 17 00:00:00 2001 From: phm07 <22707808+phm07@users.noreply.github.com> Date: Thu, 25 Apr 2024 13:43:56 +0200 Subject: [PATCH] ci: replace gon with rcodesign, switch to ubuntu runner (#738) This PR replaces the unmaintained `mitchellh/gon` with [`rcodesign`](https://gregoryszorc.com/docs/apple-codesign/stable), which makes the CI pipeline able to run on Linux. This should make the build and release process faster. The Apple Developer ID and password are not used anymore (this was not clear before). Also, the Apple code signing certificate has been moved to a secret. Closes #676 --------- Co-authored-by: Jonas L --- .github/secrets/hcloud_cli.p12.gpg | Bin 3337 -> 0 bytes .github/workflows/build.yml | 2 +- .github/workflows/release.yml | 22 +++++++++++---------- .goreleaser.yml | 11 ++++++++++- script/decrypt_secrets.sh | 15 --------------- script/gon.sh | 30 ----------------------------- 6 files changed, 23 insertions(+), 57 deletions(-) delete mode 100644 .github/secrets/hcloud_cli.p12.gpg delete mode 100755 script/decrypt_secrets.sh delete mode 100755 script/gon.sh diff --git a/.github/secrets/hcloud_cli.p12.gpg b/.github/secrets/hcloud_cli.p12.gpg deleted file mode 100644 index 6706e17b0ad7c5e82c46132959016cb021a9f6a4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3337 zcmV+k4fgVk4Fm}T0&IXstusm3DCg4a0Y&C$C`)2EQ)zx2s9HQ)qsV0wDp8rt2p-rNjR$4l8;P_Nga)sKS41Zl<^ zSh{&+_bS`IxM)Jor(W>Y4L%0wE*}&yu3GsK)i3j3RlTl!eehKWv>BpiG7GEI*VZxA z{yExC{$0~erLfS++}+j!`yAJRaRo~7k>bcH~FDyhCo|h^V?FXr@tJ3GW(-Q1hN5+1EiTbYZ=-DtM>+BLj&zjgY~a0=uJ}%2 zS|Gz3aWCKo4?=AHBKdcW?nrwX##1+8roWX;MDt7gz$_5D(<;e-RDbXI@3sp(wI zZXP2VCU+gookOBlqwTYTZ7$x>Qj&X*Hb)QU&_^+#BR{nEA)m63B95&R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^NU+g1Ya@2q~YK{TBVQ2ebhQKwDQ3(|zzvHc+5k#nC%eCTvkx#C; zALi(}d(^~H2%K!CrdxY&>l)Ei*Z+R~*OZj&Qpkon9DeHlVE8AVeKn^Y+sO$?4n3gp z(M9&L(tHYY2ldXo;&Al7vpX@jJ$x8ikO485lK!C0ac4ryowN_=O)7SNzvB;*eg`U- zt)>=BZS<%5g86$Y=j5sQI{DW3Y= certificate.p12 - name: Run GoReleaser uses: goreleaser/goreleaser-action@v5 @@ -39,6 +39,8 @@ jobs: args: release --clean --skip=validate env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - HC_APPLE_DEVELOPER_USER: ${{ secrets.HC_APPLE_DEVELOPER_USER }} - HC_APPLE_DEVELOPER_PASSWORD: ${{ secrets.HC_APPLE_DEVELOPER_PASSWORD }} - HC_APPLE_IDENTITY: ${{ secrets.HC_APPLE_IDENTITY }} + APPLE_CERTIFICATE_P12_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_P12_PASSWORD }} + + - name: Delete Apple certificate + if: always() + run: rm -f certificate.p12 diff --git a/.goreleaser.yml b/.goreleaser.yml index 6a700432..8fcaf8f4 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -41,7 +41,16 @@ builds: - arm64 hooks: post: - - cmd: bash script/gon.sh "{{ .Path }}" + - cmd: > + {{- if index .Env "APPLE_CERTIFICATE_P12_PASSWORD" -}} + rcodesign sign + --p12-file certificate.p12 + --p12-password "{{ .Env.APPLE_CERTIFICATE_P12_PASSWORD }}" + --code-signature-flags runtime + "{{ .Path }}" + {{- else -}} + echo "skipping rcodesign sign hook!" + {{- end -}} output: true snapshot: diff --git a/script/decrypt_secrets.sh b/script/decrypt_secrets.sh deleted file mode 100755 index 0f1f61b5..00000000 --- a/script/decrypt_secrets.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -gpg --quiet --batch --yes --decrypt --passphrase="$SECRETS_PASSWORD" --output ./.github/secrets/hcloud_cli.p12 ./.github/secrets/hcloud_cli.p12.gpg - -security create-keychain -p "" build.keychain -# Use long timeout for keychain to avoid issues where codesign fails because the keychain is locked -# before it was used. Default timeout is 300s -security set-keychain-settings -u -t 3600 ~/Library/Keychains/build.keychain -security import ./.github/secrets/hcloud_cli.p12 -t agg -k ~/Library/Keychains/build.keychain -P "$CERT_PASSWORD" -A - -security list-keychains -s ~/Library/Keychains/build.keychain -security default-keychain -s ~/Library/Keychains/build.keychain -security unlock-keychain -p "" ~/Library/Keychains/build.keychain - -security set-key-partition-list -S apple-tool:,apple: -s -k "" ~/Library/Keychains/build.keychain diff --git a/script/gon.sh b/script/gon.sh deleted file mode 100755 index 751a79ba..00000000 --- a/script/gon.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env bash - -set -eu -o posix - -# Only sign on releasing -if [[ "${GITHUB_REF_TYPE:-}" != "tag" ]]; then - exit 0 -fi - -BINARY_PATH="$1" - -GON_CONFIG="gon_$RANDOM.json" -cleanup() { - rm -f "$GON_CONFIG" -} -trap cleanup EXIT - -printf '{ - "source": ["%s"], - "bundle_id": "cloud.hetzner.cli", - "apple_id": { - "username": "integrations@hetzner-cloud.de", - "password": "@env:HC_APPLE_DEVELOPER_PASSWORD" - }, - "sign": { - "application_identity": "Developer ID Application: Hetzner Cloud GmbH (4PM38G6W5R)" - } -}' "$BINARY_PATH" > "$GON_CONFIG" - -gon -log-level=debug "$GON_CONFIG"