github.com/mutagen-io/mutagen@v0.18.0-rc1/scripts/ci/build.sh (about) 1 #!/bin/bash 2 3 # Exit immediately on failure. 4 set -e 5 6 # Determine the operating system. 7 MUTAGEN_OS_NAME="$(go env GOOS)" 8 9 # Perform a build that's appropriate for the platform. 10 if [[ "${MUTAGEN_OS_NAME}" == "darwin" ]]; then 11 # Check if code signing is possible. If so, then set up the keychain and 12 # certificates that we'll need and perform a signed build. If not, then just 13 # perform a normal build. 14 if [[ ! -z "${MACOS_CODESIGN_IDENTITY}" ]]; then 15 # Compute the path and password for a temporary keychain where we'll import 16 # the macOS code signing certificate and private key. 17 MUTAGEN_KEYCHAIN_PATH="${RUNNER_TEMP}/mutagen.keychain-db" 18 MUTAGEN_KEYCHAIN_PASSWORD="$(dd if=/dev/random bs=1024 count=1 2>/dev/null | openssl dgst -sha256)" 19 20 # Store the previous default keychain. 21 PREVIOUS_DEFAULT_KEYCHAIN="$(security default-keychain | xargs)" 22 23 # Create the temporary keychain, set it to be the default keychain, set it 24 # to automatically re-lock (just in case removal fails), and unlock it. 25 security create-keychain -p "${MUTAGEN_KEYCHAIN_PASSWORD}" "${MUTAGEN_KEYCHAIN_PATH}" 26 security default-keychain -s "${MUTAGEN_KEYCHAIN_PATH}" 27 security set-keychain-settings -lut 3600 "${MUTAGEN_KEYCHAIN_PATH}" 28 security unlock-keychain -p "${MUTAGEN_KEYCHAIN_PASSWORD}" "${MUTAGEN_KEYCHAIN_PATH}" 29 30 # Import the macOS code signing certificate and private key and allow access 31 # from the codesign utility. 32 MUTAGEN_CERTIFICATE_AND_KEY_PATH="${RUNNER_TEMP}/certificate_and_key.p12" 33 echo -n "${MACOS_CODESIGN_CERTIFICATE_AND_KEY}" | base64 --decode --output "${MUTAGEN_CERTIFICATE_AND_KEY_PATH}" 34 security import "${MUTAGEN_CERTIFICATE_AND_KEY_PATH}" -k "${MUTAGEN_KEYCHAIN_PATH}" -P "${MACOS_CODESIGN_CERTIFICATE_AND_KEY_PASSWORD}" -T "/usr/bin/codesign" 35 rm "${MUTAGEN_CERTIFICATE_AND_KEY_PATH}" 36 security set-key-partition-list -S apple-tool:,apple: -s -k "${MUTAGEN_KEYCHAIN_PASSWORD}" "${MUTAGEN_KEYCHAIN_PATH}" > /dev/null 37 38 # Perform a full release build with code signing. We enable 39 # SSPL-licensed extensions by default. 40 go run scripts/build.go --mode=release --sspl --macos-codesign-identity="${MACOS_CODESIGN_IDENTITY}" 41 42 # Reset the default keychain and remove the temporary keychain. 43 security default-keychain -s "${PREVIOUS_DEFAULT_KEYCHAIN}" 44 security delete-keychain "${MUTAGEN_KEYCHAIN_PATH}" 45 else 46 # Perform a full release build without code signing. We enable 47 # SSPL-licensed extensions by default. 48 go run scripts/build.go --mode=release --sspl 49 fi 50 51 # Determine the Mutagen version. 52 MUTAGEN_VERSION="$(build/mutagen version)" 53 54 # Convert the windows/386 bundle to zip format. 55 tar xzf "build/release/mutagen_windows_386_v${MUTAGEN_VERSION}.tar.gz" 56 zip "build/release/mutagen_windows_386_v${MUTAGEN_VERSION}.zip" mutagen.exe mutagen-agents.tar.gz 57 rm mutagen.exe mutagen-agents.tar.gz 58 59 # Convert the windows/amd64 bundle to zip format. 60 tar xzf "build/release/mutagen_windows_amd64_v${MUTAGEN_VERSION}.tar.gz" 61 zip "build/release/mutagen_windows_amd64_v${MUTAGEN_VERSION}.zip" mutagen.exe mutagen-agents.tar.gz 62 rm mutagen.exe mutagen-agents.tar.gz 63 64 # Convert the windows/arm bundle to zip format. 65 tar xzf "build/release/mutagen_windows_arm_v${MUTAGEN_VERSION}.tar.gz" 66 zip "build/release/mutagen_windows_arm_v${MUTAGEN_VERSION}.zip" mutagen.exe mutagen-agents.tar.gz 67 rm mutagen.exe mutagen-agents.tar.gz 68 69 # Convert the windows/arm64 bundle to zip format. 70 tar xzf "build/release/mutagen_windows_arm64_v${MUTAGEN_VERSION}.tar.gz" 71 zip "build/release/mutagen_windows_arm64_v${MUTAGEN_VERSION}.zip" mutagen.exe mutagen-agents.tar.gz 72 rm mutagen.exe mutagen-agents.tar.gz 73 else 74 # Perform a slim build. We enable SSPL-licensed extensions by default. 75 go run scripts/build.go --mode=slim --sspl 76 fi 77 78 # Ensure that the sidecar entry point builds, both with and without SSPL code. 79 # We only need this command to build on Linux, but it's best to keep it 80 # maintained in a portable fashion. 81 go build -tags mutagensidecar,mutagensspl ./cmd/mutagen-sidecar 82 go build -tags mutagensidecar ./cmd/mutagen-sidecar 83 84 # Build tools, both with and without SSPL code, to ensure that they are 85 # maintained as core packages evolve. 86 go build -tags mutagensspl ./tools/scan_bench 87 go build -tags mutagensspl ./tools/watch_demo 88 go build ./tools/scan_bench 89 go build ./tools/watch_demo