build and release files, then do apple sign and notorize after #21
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Hava binary release | |
on: | |
push: | |
tags: | |
- '*' | |
permissions: | |
contents: write | |
jobs: | |
goreleaser: | |
runs-on: macos-latest | |
steps: | |
- | |
name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- | |
name: Set up Go | |
uses: actions/setup-go@v4 | |
- | |
name: Build Release | |
uses: goreleaser/goreleaser-action@v4 | |
with: | |
# either 'goreleaser' (default) or 'goreleaser-pro' | |
distribution: goreleaser | |
version: ${{ env.GITHUB_REF_NAME }} | |
args: release --clean | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- | |
name: Apple certificate, provisioning profile, sign binary, notorize | |
env: | |
BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }} | |
P12_PASSWORD: ${{ secrets.P12_PASSWORD }} | |
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }} | |
AC_USERNAME: ${{ secrets.APPLE_USERNAME }} | |
AC_PASSWORD: ${{ secrets.APPLE_PASSWORD }} | |
AC_TEAMID: ${{ secrets.AC_TEAMID }} | |
MACOS_CERTIFICATE_NAME: ${{ secrets.MACOS_CERTIFICATE_NAME }} | |
DIST_FILE_UNIVERSAL: dist/hava_darwin_all/hava | |
run: | | |
# create variables | |
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12 | |
PP_PATH=$RUNNER_TEMP/build_pp.mobileprovision | |
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db | |
# import certificate and provisioning profile from secrets | |
echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode -o $CERTIFICATE_PATH | |
echo -n "$BUILD_PROVISION_PROFILE_BASE64" | base64 --decode -o $PP_PATH | |
# create temporary keychain | |
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH | |
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH | |
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH | |
# import certificate to keychain | |
security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH | |
security list-keychain -d user -s $KEYCHAIN_PATH | |
security find-identity -v | |
echo "List Files" | |
ls -lh ./dist/ | |
# Sign binaries | |
echo "Signing binaries" | |
codesign --force -s "$MACOS_CERTIFICATE_NAME" -v "./${DIST_FILE_UNIVERSAL}" --options=runtime --timestamp | |
# Notarize | |
# Store the notarization credentials so that we can prevent a UI password dialog from blocking the CI | |
echo "Create keychain profile" | |
xcrun notarytool store-credentials "notarytool-profile" --apple-id "$AC_USERNAME" --team-id "$AC_TEAMID" --password "$AC_PASSWORD" | |
# We can't notarize an app bundle directly, but we need to compress it as an archive. | |
# Therefore, we create a zip file containing our app bundle, so that we can send it to the | |
# notarization service | |
# Notarize insider binary | |
echo "Creating temp notarization archive for insider build" | |
ditto -c -k --keepParent "./${DIST_FILE_UNIVERSAL}" "./${DIST_FILE_UNIVERSAL}--macos-x64--${{ github.sha }}.zip" | |
# Here we send the notarization request to the Apple's Notarization service, waiting for the result. | |
# This typically takes a few seconds inside a CI environment, but it might take more depending on the App | |
# characteristics. Visit the Notarization docs for more information and strategies on how to optimize it if | |
# you're curious | |
echo "Notarize insider app" | |
xcrun notarytool submit "./${DIST_FILE_UNIVERSAL}--macos-x64--${{ github.sha }}.zip" --keychain-profile "notarytool-profile" --wait | |
# Delete build keychain | |
security delete-keychain $KEYCHAIN_PATH | |