From 556db1290dec9aa40887705fa5d236c0a12f27c2 Mon Sep 17 00:00:00 2001 From: Nikita Galaiko Date: Wed, 12 Jul 2023 16:06:10 +0200 Subject: [PATCH] nightly builds --- .env.development | 1 + .env.nightly | 4 ++++ .env.production | 1 + .github/workflows/nightly.yaml | 13 +++++++++++++ .github/workflows/publish.yaml | 29 ++++++++++++++++++++++++++--- scripts/release.sh | 18 ++++++++++++++++-- src-tauri/tauri.conf.nightly.json | 27 +++++++++++++++++++++++++++ src-tauri/tauri.conf.release.json | 5 ----- src/hooks.client.ts | 3 ++- 9 files changed, 90 insertions(+), 11 deletions(-) create mode 100644 .env.nightly create mode 100644 .github/workflows/nightly.yaml create mode 100644 src-tauri/tauri.conf.nightly.json diff --git a/.env.development b/.env.development index aee189674..cf824a0b5 100644 --- a/.env.development +++ b/.env.development @@ -1,3 +1,4 @@ PUBLIC_API_BASE_URL=https://test.app.gitbutler.com/ PUBLIC_POSTHOG_API_KEY=phc_t7VDC9pQELnYep9IiDTxrq2HLseY5wyT7pn0EpHM7rr PUBLIC_CHAIN_API=https://data-test.gitbutler.com/chain/ +PUBLIC_SENTRY_ENVIRONMENT=development diff --git a/.env.nightly b/.env.nightly new file mode 100644 index 000000000..d241983e1 --- /dev/null +++ b/.env.nightly @@ -0,0 +1,4 @@ +PUBLIC_API_BASE_URL=https://app.gitbutler.com/ +PUBLIC_POSTHOG_API_KEY=phc_yJx46mXv6kA5KTuM2eEQ6IwNTgl5YW3feKV5gi7mfGG +PUBLIC_CHAIN_API=https://data.gitbutler.com/chain/ +PUBLIC_SENTRY_ENVIRONMENT=nightly diff --git a/.env.production b/.env.production index 36489f78d..7a0e59831 100644 --- a/.env.production +++ b/.env.production @@ -1,3 +1,4 @@ PUBLIC_API_BASE_URL=https://app.gitbutler.com/ PUBLIC_POSTHOG_API_KEY=phc_yJx46mXv6kA5KTuM2eEQ6IwNTgl5YW3feKV5gi7mfGG PUBLIC_CHAIN_API=https://data.gitbutler.com/chain/ +PUBLIC_SENTRY_ENVIRONMENT=production diff --git a/.github/workflows/nightly.yaml b/.github/workflows/nightly.yaml new file mode 100644 index 000000000..27f867672 --- /dev/null +++ b/.github/workflows/nightly.yaml @@ -0,0 +1,13 @@ +name: "Nightly build" + +on: + workflow_dispatch: {} + schedule: + # every day at 3am + - cron: '0 3 * * *' + +jobs: + noop: + runs-on: ubuntu-latest + steps: + run: echo "Success!" diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 533ba5b38..e6e626f0b 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -1,7 +1,19 @@ name: "Publish" on: + workflow_run: + workflows: ["Nightly build"] + types: + - completed + workflow_dispatch: inputs: + channel: + type: choice + required: true + description: channel + options: + - release + - nightly bump: type: choice required: true @@ -67,9 +79,19 @@ jobs: with: workspaces: src-tauri + - name: Set release channel = 'nightly' + if: ${{ !!github.event.workflow_run }} + run: | + echo "channel=nightly" >> $GITHUB_ENV + + - name: Use input release channel + if: ${{ !!github.event.workflow_dispatch }} + run: | + echo "channel=${{ github.event.inputs.channel }}" >> $GITHUB_ENV + - name: Set env variable with version run: | - CURRENT_VERSION="$(curl --silent "https://app.gitbutler.com/releases" | jq -r '.version')" + CURRENT_VERSION="$(curl --silent "https://app.gitbutler.com/releases/${{ env.channel }}" | jq -r '.version')" NEXT_VERSION=$(./scripts/next.sh "${CURRENT_VERSION}" "${{ github.event.inputs.bump }}") echo "version=$NEXT_VERSION" >> $GITHUB_ENV @@ -77,6 +99,7 @@ jobs: run: | ./scripts/release.sh \ --sign \ + --channel "${{ env.channel }}" \ --dist "./release" \ --version "${{ env.version }}" \ --tauri-private-key "${{ secrets.TAURI_PRIVATE_KEY }}" \ @@ -95,7 +118,7 @@ jobs: aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY}} aws_bucket: "releases.gitbutler.com" source_dir: "release/" - destination_dir: "releases/${{ env.version }}-${{ github.run_number }}" + destination_dir: "releases/${{ env.channel }}/${{ env.version }}-${{ github.run_number }}" # tell our server to update with the version number - name: Tell our server to update @@ -105,4 +128,4 @@ jobs: --request POST \ --header 'Content-Type: application/json' \ --header 'X-Auth-Token: ${{ secrets.BOT_AUTH_TOKEN }}' \ - --data '{"version":"${{ env.version }}-${{ github.run_number }}","sha":"${{ github.sha }}"}' + --data '{"channel":"${{ env.channel }}","version":"${{ env.version }}-${{ github.run_number }}","sha":"${{ github.sha }}"}' diff --git a/scripts/release.sh b/scripts/release.sh index 361484e2e..bdacfce6b 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -6,6 +6,7 @@ set -o pipefail PWD="$(dirname $(readlink -f -- $0))" +CHANNEL="" DO_SIGN="false" DO_BUNDLE_UPDATE="false" TAURI_PRIVATE_KEY="" @@ -33,6 +34,7 @@ function help() { echo " --apple-id the apple id to use for signing." 1>&$to echo " --apple-password the password for the apple id." 1>&$to echo " --sign if set, will sign the app." 1>&$to + echo " --channel the channel to use for the release (release | nightly)." 1>&$to echo " --help display this message." 1>&$to } @@ -137,6 +139,11 @@ while [[ $# -gt 0 ]]; do DO_SIGN="true" shift ;; + --channel) + CHANNEL="$2" + shift + shift + ;; *) error "unknown flag $1" ;; @@ -148,6 +155,10 @@ done [ -z "$TAURI_PRIVATE_KEY" ] && error "--tauri-private-key is not set" [ -z "$TAURI_KEY_PASSWORD" ] && error "--tauri-key-password is not set" +if [ "$CHANNEL" != "release" ] && [ "$CHANNEL" != "nightly" ]; then + error "--channel must be either 'release' or 'nightly'" +fi + export TAURI_PRIVATE_KEY="$TAURI_PRIVATE_KEY" export TAURI_KEY_PASSWORD="$TAURI_KEY_PASSWORD" @@ -166,6 +177,7 @@ if [ "$DO_SIGN" = "true" ]; then fi info "building:" +info " channel: $CHANNEL" info " version: $VERSION" info " os: $OS" info " arch: $ARCH" @@ -174,13 +186,15 @@ info " dist: $DIST" TMP_DIR="$(mktemp -d)" trap "rm -rf '$TMP_DIR'" exit +CONFIG_PATH=$(readlink -f "$PWD/../src-tauri/tauri.conf.$CHANNEL.json") + # update the version in the tauri release config -jq '.package.version="'"$VERSION"'"' "$PWD/../src-tauri/tauri.conf.release.json" >"$TMP_DIR/tauri.conf.json" +jq '.package.version="'"$VERSION"'"' "$CONFIG_PATH" >"$TMP_DIR/tauri.conf.json" # build the app with release config SENTRY_RELEASE="$VERSION" tauri build --config "$TMP_DIR/tauri.conf.json" -BUNDLE_DIR="$PWD/../src-tauri/target/release/bundle" +BUNDLE_DIR=$(readlink -f "$PWD/../src-tauri/target/release/bundle") MACOS_DMG="$(find "$BUNDLE_DIR/dmg" -depth 1 -type f -name "*.dmg")" MACOS_UPDATER="$(find "$BUNDLE_DIR/macos" -depth 1 -type f -name "*.tar.gz")" MACOS_UPDATER_SIG="$(find "$BUNDLE_DIR/macos" -depth 1 -type f -name "*.tar.gz.sig")" diff --git a/src-tauri/tauri.conf.nightly.json b/src-tauri/tauri.conf.nightly.json new file mode 100644 index 000000000..063ba57cb --- /dev/null +++ b/src-tauri/tauri.conf.nightly.json @@ -0,0 +1,27 @@ +{ + "package": { + "productName": "GitButler Nightly" + }, + "tauri": { + "bundle": { + "identifier": "com.gitbutler.app.nightly" + }, + "security": { + "csp": { + "default-src": "'self'", + "img-src": "'self' asset: https://asset.localhost", + "connect-src": "'self' https://eu.posthog.com https://app.gitbutler.com https://o4504644069687296.ingest.sentry.io ws://localhost:7703", + "script-src": "'self' https://eu.posthog.com", + "style-src": "'self' 'unsafe-inline'" + } + }, + "updater": { + "active": true, + "dialog": true, + "endpoints": [ + "https://app.gitbutler.com/releases/nightly/{{target}}-{{arch}}/{{current_version}}" + ], + "pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDYwNTc2RDhBM0U0MjM4RUIKUldUck9FSStpbTFYWUE5UkJ3eXhuekZOL2V2RnpKaFUxbGJRNzBMVmF5V0gzV1JvN3hRblJMRDIK" + } + } +} diff --git a/src-tauri/tauri.conf.release.json b/src-tauri/tauri.conf.release.json index ae85c2f2c..91ecc21a0 100644 --- a/src-tauri/tauri.conf.release.json +++ b/src-tauri/tauri.conf.release.json @@ -6,11 +6,6 @@ "bundle": { "identifier": "com.gitbutler.app" }, - "allowlist": { - "shell": { - "open": true - } - }, "security": { "csp": { "default-src": "'self'", diff --git a/src/hooks.client.ts b/src/hooks.client.ts index bb8d04f45..d4c8ff0b4 100644 --- a/src/hooks.client.ts +++ b/src/hooks.client.ts @@ -1,11 +1,12 @@ import { handleErrorWithSentry, init } from '@sentry/sveltekit'; import type { NavigationEvent } from '@sveltejs/kit'; import { dev } from '$app/environment'; +import { PUBLIC_SENTRY_ENVIRONMENT } from '$env/static/public'; init({ enabled: !dev, dsn: 'https://9d407634d26b4d30b6a42d57a136d255@o4504644069687296.ingest.sentry.io/4504649768108032', - environment: dev ? 'development' : 'production', + environment: PUBLIC_SENTRY_ENVIRONMENT, tracesSampleRate: 1.0 });