From 20809723dcf7e3f0764712d636aa0cda47298206 Mon Sep 17 00:00:00 2001 From: vansangpfiev Date: Mon, 28 Apr 2025 11:31:46 +0700 Subject: [PATCH] chore: workflows for tauri --- .github/workflows/jan-tauri-build-beta.yml | 86 +++++ .github/workflows/jan-tauri-build-nightly.yml | 150 +++++++++ .github/workflows/jan-tauri-build.yml | 91 ++++++ .../workflows/template-build-linux-x64.yml | 101 +----- .github/workflows/template-build-macos.yml | 174 +++------- .../workflows/template-build-windows-x64.yml | 157 +++------ .../template-tauri-build-linux-x64.yml | 241 ++++++++++++++ .../workflows/template-tauri-build-macos.yml | 261 +++++++++++++++ .../template-tauri-build-windows-x64.yml | 302 ++++++++++++++++++ Makefile | 3 + package.json | 3 +- 11 files changed, 1235 insertions(+), 334 deletions(-) create mode 100644 .github/workflows/jan-tauri-build-beta.yml create mode 100644 .github/workflows/jan-tauri-build-nightly.yml create mode 100644 .github/workflows/jan-tauri-build.yml create mode 100644 .github/workflows/template-tauri-build-linux-x64.yml create mode 100644 .github/workflows/template-tauri-build-macos.yml create mode 100644 .github/workflows/template-tauri-build-windows-x64.yml diff --git a/.github/workflows/jan-tauri-build-beta.yml b/.github/workflows/jan-tauri-build-beta.yml new file mode 100644 index 000000000..bbc21f7a1 --- /dev/null +++ b/.github/workflows/jan-tauri-build-beta.yml @@ -0,0 +1,86 @@ +name: Tauri Builder - Beta Build + +on: + push: + tags: ["v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+-beta"] + +jobs: + # Job create Update app version based on latest release tag with build number and save to output + get-update-version: + uses: ./.github/workflows/template-get-update-version.yml + + build-macos: + uses: ./.github/workflows/template-tauri-build-macos.yml + secrets: inherit + needs: [get-update-version] + with: + ref: ${{ github.ref }} + public_provider: github + new_version: ${{ needs.get-update-version.outputs.new_version }} + beta: true + nightly: false + cortex_api_port: "39271" + + build-windows-x64: + uses: ./.github/workflows/template-tauri-build-windows-x64.yml + secrets: inherit + needs: [get-update-version] + with: + ref: ${{ github.ref }} + public_provider: github + new_version: ${{ needs.get-update-version.outputs.new_version }} + beta: true + nightly: false + cortex_api_port: "39271" + + build-linux-x64: + uses: ./.github/workflows/template-tauri-build-linux-x64.yml + secrets: inherit + needs: [get-update-version] + with: + ref: ${{ github.ref }} + public_provider: github + new_version: ${{ needs.get-update-version.outputs.new_version }} + beta: true + nightly: false + cortex_api_port: "39271" + + sync-temp-to-latest: + needs: [build-macos, build-windows-x64, build-linux-x64] + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Getting the repo + uses: actions/checkout@v3 + - name: Sync temp to latest + run: | + # sync temp-beta to beta by copy files that are different or new + aws s3 sync "s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/temp-beta/" "s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/beta/" + env: + AWS_ACCESS_KEY_ID: ${{ secrets.DELTA_AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.DELTA_AWS_SECRET_ACCESS_KEY }} + AWS_DEFAULT_REGION: ${{ secrets.DELTA_AWS_REGION }} + AWS_EC2_METADATA_DISABLED: "true" + + noti-discord-and-update-url-readme: + needs: [build-macos, get-update-version, build-windows-x64, build-linux-x64, sync-temp-to-latest] + runs-on: ubuntu-latest + steps: + - name: Set version to environment variable + run: | + VERSION=${{ needs.get-update-version.outputs.new_version }} + VERSION="${VERSION#v}" + echo "VERSION=$VERSION" >> $GITHUB_ENV + + - name: Notify Discord + uses: Ilshidur/action-discord@master + with: + args: | + Jan-beta App version {{ VERSION }}, has been released, use the following links to download the app with faster speed or visit the Github release page for more information: + - Windows: https://delta.jan.ai/beta/jan-beta-win-x64-{{ VERSION }}.exe + - macOS Universal: https://delta.jan.ai/beta/jan-beta-mac-universal-{{ VERSION }}.dmg + - Linux Deb: https://delta.jan.ai/beta/jan-beta-linux-amd64-{{ VERSION }}.deb + - Linux AppImage: https://delta.jan.ai/beta/jan-beta-linux-x86_64-{{ VERSION }}.AppImage + env: + DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_JAN_BETA }} \ No newline at end of file diff --git a/.github/workflows/jan-tauri-build-nightly.yml b/.github/workflows/jan-tauri-build-nightly.yml new file mode 100644 index 000000000..09946c53f --- /dev/null +++ b/.github/workflows/jan-tauri-build-nightly.yml @@ -0,0 +1,150 @@ +name: Tauri Builder - Nightly / Manual + +on: + schedule: + - cron: '0 20 * * 1,2,3' # At 8 PM UTC on Monday, Tuesday, and Wednesday which is 3 AM UTC+7 Tuesday, Wednesday, and Thursday + workflow_dispatch: + inputs: + public_provider: + type: choice + description: 'Public Provider' + options: + - none + - aws-s3 + default: none + pull_request_review: + types: [submitted] + +jobs: + set-public-provider: + runs-on: ubuntu-latest + outputs: + public_provider: ${{ steps.set-public-provider.outputs.public_provider }} + ref: ${{ steps.set-public-provider.outputs.ref }} + steps: + - name: Set public provider + id: set-public-provider + run: | + if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then + echo "::set-output name=public_provider::${{ github.event.inputs.public_provider }}" + echo "::set-output name=ref::${{ github.ref }}" + else + if [ "${{ github.event_name }}" == "schedule" ]; then + echo "::set-output name=public_provider::aws-s3" + echo "::set-output name=ref::refs/heads/dev" + elif [ "${{ github.event_name }}" == "push" ]; then + echo "::set-output name=public_provider::aws-s3" + echo "::set-output name=ref::${{ github.ref }}" + elif [ "${{ github.event_name }}" == "pull_request_review" ]; then + echo "::set-output name=public_provider::none" + echo "::set-output name=ref::${{ github.ref }}" + else + echo "::set-output name=public_provider::none" + echo "::set-output name=ref::${{ github.ref }}" + fi + fi + # Job create Update app version based on latest release tag with build number and save to output + get-update-version: + uses: ./.github/workflows/template-get-update-version.yml + + build-macos: + uses: ./.github/workflows/template-tauri-build-macos.yml + needs: [get-update-version, set-public-provider] + secrets: inherit + with: + ref: ${{ needs.set-public-provider.outputs.ref }} + public_provider: ${{ needs.set-public-provider.outputs.public_provider }} + new_version: ${{ needs.get-update-version.outputs.new_version }} + nightly: true + beta: false + cortex_api_port: "39261" + + build-windows-x64: + uses: ./.github/workflows/template-tauri-build-windows-x64.yml + secrets: inherit + needs: [get-update-version, set-public-provider] + with: + ref: ${{ needs.set-public-provider.outputs.ref }} + public_provider: ${{ needs.set-public-provider.outputs.public_provider }} + new_version: ${{ needs.get-update-version.outputs.new_version }} + nightly: true + beta: false + cortex_api_port: "39261" + build-linux-x64: + uses: ./.github/workflows/template-tauri-build-linux-x64.yml + secrets: inherit + needs: [get-update-version, set-public-provider] + with: + ref: ${{ needs.set-public-provider.outputs.ref }} + public_provider: ${{ needs.set-public-provider.outputs.public_provider }} + new_version: ${{ needs.get-update-version.outputs.new_version }} + nightly: true + beta: false + cortex_api_port: "39261" + + sync-temp-to-latest: + needs: [set-public-provider, build-windows-x64, build-linux-x64, build-macos] + runs-on: ubuntu-latest + steps: + - name: Sync temp to latest + if: ${{ needs.set-public-provider.outputs.public_provider == 'aws-s3' }} + run: | + aws s3 sync s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/temp-nightly/ s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/nightly/ + env: + AWS_ACCESS_KEY_ID: ${{ secrets.DELTA_AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.DELTA_AWS_SECRET_ACCESS_KEY }} + AWS_DEFAULT_REGION: ${{ secrets.DELTA_AWS_REGION }} + AWS_EC2_METADATA_DISABLED: "true" + + noti-discord-nightly-and-update-url-readme: + needs: [build-macos, build-windows-x64, build-linux-x64, get-update-version, set-public-provider, sync-temp-to-latest] + secrets: inherit + if: github.event_name == 'schedule' + uses: ./.github/workflows/template-noti-discord-and-update-url-readme.yml + with: + ref: refs/heads/dev + build_reason: Nightly + push_to_branch: dev + new_version: ${{ needs.get-update-version.outputs.new_version }} + + noti-discord-pre-release-and-update-url-readme: + needs: [build-macos, build-windows-x64, build-linux-x64, get-update-version, set-public-provider, sync-temp-to-latest] + secrets: inherit + if: github.event_name == 'push' + uses: ./.github/workflows/template-noti-discord-and-update-url-readme.yml + with: + ref: refs/heads/dev + build_reason: Pre-release + push_to_branch: dev + new_version: ${{ needs.get-update-version.outputs.new_version }} + + noti-discord-manual-and-update-url-readme: + needs: [build-macos, build-windows-x64, build-linux-x64, get-update-version, set-public-provider, sync-temp-to-latest] + secrets: inherit + if: github.event_name == 'workflow_dispatch' && github.event.inputs.public_provider == 'aws-s3' + uses: ./.github/workflows/template-noti-discord-and-update-url-readme.yml + with: + ref: refs/heads/dev + build_reason: Manual + push_to_branch: dev + new_version: ${{ needs.get-update-version.outputs.new_version }} + + + comment-pr-build-url: + needs: [build-macos, build-windows-x64, build-linux-x64, get-update-version, set-public-provider, sync-temp-to-latest] + runs-on: ubuntu-latest + if: github.event_name == 'pull_request_review' + steps: + - name: Set up GitHub CLI + run: | + curl -sSL https://github.com/cli/cli/releases/download/v2.33.0/gh_2.33.0_linux_amd64.tar.gz | tar xz + sudo cp gh_2.33.0_linux_amd64/bin/gh /usr/local/bin/ + + - name: Comment build URL on PR + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + PR_URL=${{ github.event.pull_request.html_url }} + RUN_ID=${{ github.run_id }} + COMMENT="This is the build for this pull request. You can download it from the Artifacts section here: [Build URL](https://github.com/${{ github.repository }}/actions/runs/${RUN_ID})." + gh pr comment $PR_URL --body "$COMMENT" diff --git a/.github/workflows/jan-tauri-build.yml b/.github/workflows/jan-tauri-build.yml new file mode 100644 index 000000000..bc5460ffe --- /dev/null +++ b/.github/workflows/jan-tauri-build.yml @@ -0,0 +1,91 @@ +name: Electron Builder - Tag + +on: + push: + tags: ["v[0-9]+.[0-9]+.[0-9]+"] + +jobs: + # Job create Update app version based on latest release tag with build number and save to output + get-update-version: + uses: ./.github/workflows/template-get-update-version.yml + + create-draft-release: + runs-on: ubuntu-latest + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') + outputs: + upload_url: ${{ steps.create_release.outputs.upload_url }} + version: ${{ steps.get_version.outputs.version }} + permissions: + contents: write + steps: + - name: Extract tag name without v prefix + id: get_version + run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV && echo "::set-output name=version::${GITHUB_REF#refs/tags/v}" + env: + GITHUB_REF: ${{ github.ref }} + - name: Create Draft Release + id: create_release + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ github.ref_name }} + token: ${{ secrets.GITHUB_TOKEN }} + name: "${{ env.VERSION }}" + draft: true + prerelease: false + + build-macos: + uses: ./.github/workflows/template-tauri-build-macos.yml + secrets: inherit + needs: [get-update-version] + with: + ref: ${{ github.ref }} + public_provider: github + beta: false + nightly: false + new_version: ${{ needs.get-update-version.outputs.new_version }} + + build-windows-x64: + uses: ./.github/workflows/template-tauri-build-windows-x64.yml + secrets: inherit + needs: [get-update-version] + with: + ref: ${{ github.ref }} + public_provider: github + beta: false + nightly: false + new_version: ${{ needs.get-update-version.outputs.new_version }} + + build-linux-x64: + uses: ./.github/workflows/template-tauri-build-linux-x64.yml + secrets: inherit + needs: [get-update-version] + with: + ref: ${{ github.ref }} + public_provider: github + beta: false + nightly: false + new_version: ${{ needs.get-update-version.outputs.new_version }} + + update_release_draft: + needs: [build-macos, build-windows-x64, build-linux-x64] + permissions: + # write permission is required to create a github release + contents: write + # write permission is required for autolabeler + # otherwise, read permission is required at least + pull-requests: write + runs-on: ubuntu-latest + steps: + # (Optional) GitHub Enterprise requires GHE_HOST variable set + #- name: Set GHE_HOST + # run: | + # echo "GHE_HOST=${GITHUB_SERVER_URL##https:\/\/}" >> $GITHUB_ENV + + # Drafts your next Release notes as Pull Requests are merged into "master" + - uses: release-drafter/release-drafter@v5 + # (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml + # with: + # config-name: my-config.yml + # disable-autolabeler: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/template-build-linux-x64.yml b/.github/workflows/template-build-linux-x64.yml index 0afb47e69..58b566931 100644 --- a/.github/workflows/template-build-linux-x64.yml +++ b/.github/workflows/template-build-linux-x64.yml @@ -38,16 +38,10 @@ on: required: false DELTA_AWS_SECRET_ACCESS_KEY: required: false - TAURI_SIGNING_PRIVATE_KEY: - required: false - TAURI_SIGNING_PRIVATE_KEY_PASSWORD: - required: false - TAURI_SIGNING_PUBLIC_KEY: - required: false jobs: build-linux-x64: - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest environment: production permissions: contents: write @@ -57,20 +51,6 @@ jobs: with: ref: ${{ inputs.ref }} - - name: Free Disk Space Before Build - run: | - echo "Disk space before cleanup:" - df -h - sudo rm -rf /usr/local/.ghcup - sudo rm -rf /opt/hostedtoolcache/CodeQL - sudo rm -rf /usr/local/lib/android/sdk/ndk - sudo rm -rf /usr/share/dotnet - sudo rm -rf /opt/ghc - sudo rm -rf /usr/local/share/boost - sudo apt-get clean - echo "Disk space after cleanup:" - df -h - - name: Replace Icons for Beta Build if: inputs.beta == true && inputs.nightly != true shell: bash @@ -104,49 +84,25 @@ jobs: - name: Install jq uses: dcarbone/install-jq-action@v2.0.1 - - name: Install ctoml - run: | - cargo install ctoml - - - name: Install Tauri dependecies - run: | - sudo apt update - sudo apt install -y libglib2.0-dev libatk1.0-dev libpango1.0-dev libgtk-3-dev libsoup-3.0-dev libwebkit2gtk-4.1-dev librsvg2-dev - - name: Update app version base public_provider if: inputs.public_provider != 'github' run: | echo "Version: ${{ inputs.new_version }}" - # Update tauri.conf.json - jq --arg version "${{ inputs.new_version }}" '.version = $version | .bundle.createUpdaterArtifacts = true' ./src-tauri/tauri.conf.json > /tmp/tauri.conf.json - mv /tmp/tauri.conf.json ./src-tauri/tauri.conf.json - - chmod +x .github/scripts/rename-tauri-app.sh - .github/scripts/rename-tauri-app.sh ./src-tauri/tauri.conf.json nightly - - echo ./src-tauri/tauri.conf.json - - # Update Cargo.toml - ctoml ./src-tauri/Cargo.toml package.name "Jan-nightly" - ctoml ./src-tauri/Cargo.toml package.version "${{ inputs.new_version }}" - echo "------------------" - cat ./src-tauri/Cargo.toml - - # # Update the version in electron/package.json - # jq --arg version "${{ inputs.new_version }}" '.version = $version' electron/package.json > /tmp/package.json - # mv /tmp/package.json electron/package.json + # Update the version in electron/package.json + jq --arg version "${{ inputs.new_version }}" '.version = $version' electron/package.json > /tmp/package.json + mv /tmp/package.json electron/package.json jq --arg version "${{ inputs.new_version }}" '.version = $version' web/package.json > /tmp/package.json mv /tmp/package.json web/package.json - # jq '.build.publish = [{"provider": "generic", "url": "https://delta.jan.ai/nightly", "channel": "latest"}, {"provider": "s3", "acl": null, "bucket": "${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}", "region": "${{ secrets.DELTA_AWS_REGION}}", "path": "temp-nightly", "channel": "latest"}]' electron/package.json > /tmp/package.json - # mv /tmp/package.json electron/package.json - # cat electron/package.json - # chmod +x .github/scripts/rename-app.sh - # .github/scripts/rename-app.sh ./electron/package.json nightly - # chmod +x .github/scripts/rename-workspace.sh - # .github/scripts/rename-workspace.sh ./package.json nightly - # echo "------------------------" - # cat ./electron/package.json - # echo "------------------------" + jq '.build.publish = [{"provider": "generic", "url": "https://delta.jan.ai/nightly", "channel": "latest"}, {"provider": "s3", "acl": null, "bucket": "${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}", "region": "${{ secrets.DELTA_AWS_REGION}}", "path": "temp-nightly", "channel": "latest"}]' electron/package.json > /tmp/package.json + mv /tmp/package.json electron/package.json + cat electron/package.json + chmod +x .github/scripts/rename-app.sh + .github/scripts/rename-app.sh ./electron/package.json nightly + chmod +x .github/scripts/rename-workspace.sh + .github/scripts/rename-workspace.sh ./package.json nightly + echo "------------------------" + cat ./electron/package.json + echo "------------------------" - name: Change App Name for beta version if: inputs.beta == true @@ -174,20 +130,6 @@ jobs: env: VERSION_TAG: ${{ inputs.new_version }} - - name: Inject Tauri Signing Public Key - run: | - if [ -f "src-tauri/tauri.conf.json" ]; then - echo "Injecting Tauri public key into configuration..." - # Use jq to update the pubkey field in the tauri.conf.json file - jq --arg pubkey "$TAURI_SIGNING_PUBLIC_KEY" '.plugins.updater.pubkey = $pubkey' src-tauri/tauri.conf.json > /tmp/tauri.conf.json - mv /tmp/tauri.conf.json src-tauri/tauri.conf.json - echo "Tauri configuration updated successfully" - else - echo "tauri.conf.json not found" - fi - env: - TAURI_SIGNING_PUBLIC_KEY: ${{ secrets.TAURI_SIGNING_PUBLIC_KEY }} - - name: Build and publish app to aws s3 r2 or github artifactory if: inputs.public_provider != 'github' run: | @@ -206,10 +148,7 @@ jobs: AWS_MAX_ATTEMPTS: '5' POSTHOG_KEY: ${{ secrets.POSTHOG_KEY }} POSTHOG_HOST: ${{ secrets.POSTHOG_HOST }} - # CORTEX_API_PORT: ${{ inputs.cortex_api_port }} - TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} - TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} - TAURI_SIGNING_PUBLIC_KEY: ${{ secrets.TAURI_SIGNING_PUBLIC_KEY }} + CORTEX_API_PORT: ${{ inputs.cortex_api_port }} - name: Build and publish app to github if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && inputs.public_provider == 'github' && inputs.beta == false @@ -219,9 +158,6 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} POSTHOG_KEY: ${{ secrets.POSTHOG_KEY }} POSTHOG_HOST: ${{ secrets.POSTHOG_HOST }} - TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} - TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} - TAURI_SIGNING_PUBLIC_KEY: ${{ secrets.TAURI_SIGNING_PUBLIC_KEY }} - name: Build and publish app to github if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && inputs.public_provider == 'github' && inputs.beta == true @@ -235,20 +171,17 @@ jobs: AWS_MAX_ATTEMPTS: '5' POSTHOG_KEY: ${{ secrets.POSTHOG_KEY }} POSTHOG_HOST: ${{ secrets.POSTHOG_HOST }} - TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} - TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} - TAURI_SIGNING_PUBLIC_KEY: ${{ secrets.TAURI_SIGNING_PUBLIC_KEY }} - name: Upload Artifact .deb file if: inputs.public_provider != 'github' uses: actions/upload-artifact@v4 with: name: jan-linux-amd64-${{ inputs.new_version }}-deb - path: ./src-tauri/target/release/bundle/deb/*.deb + path: ./electron/dist/*.deb - name: Upload Artifact .AppImage file if: inputs.public_provider != 'github' uses: actions/upload-artifact@v4 with: name: jan-linux-amd64-${{ inputs.new_version }}-AppImage - path: ./src-tauri/target/release/bundle/appimage/*.AppImage \ No newline at end of file + path: ./electron/dist/*.AppImage \ No newline at end of file diff --git a/.github/workflows/template-build-macos.yml b/.github/workflows/template-build-macos.yml index 9c2d0b19b..a5e5cc724 100644 --- a/.github/workflows/template-build-macos.yml +++ b/.github/workflows/template-build-macos.yml @@ -48,12 +48,6 @@ on: required: false DEVELOPER_ID: required: false - TAURI_SIGNING_PRIVATE_KEY: - required: false - TAURI_SIGNING_PRIVATE_KEY_PASSWORD: - required: false - TAURI_SIGNING_PUBLIC_KEY: - required: false jobs: build-macos: @@ -99,50 +93,31 @@ jobs: - name: Install jq uses: dcarbone/install-jq-action@v2.0.1 - - name: Install ctoml - run: | - cargo install ctoml - - name: Update app version based on latest release tag with build number if: inputs.public_provider != 'github' run: | echo "Version: ${{ inputs.new_version }}" - # Update tauri.conf.json - jq --arg version "${{ inputs.new_version }}" '.version = $version | .bundle.createUpdaterArtifacts = true' ./src-tauri/tauri.conf.json > /tmp/tauri.conf.json - mv /tmp/tauri.conf.json ./src-tauri/tauri.conf.json - - chmod +x .github/scripts/rename-tauri-app.sh - .github/scripts/rename-tauri-app.sh ./src-tauri/tauri.conf.json nightly - - echo ./src-tauri/tauri.conf.json - - # Update Cargo.toml - ctoml ./src-tauri/Cargo.toml package.name "Jan-nightly" - ctoml ./src-tauri/Cargo.toml package.version "${{ inputs.new_version }}" - echo "------------------" - cat ./src-tauri/Cargo.toml - # Update the version in electron/package.json - # jq --arg version "${{ inputs.new_version }}" '.version = $version' electron/package.json > /tmp/package.json - # mv /tmp/package.json electron/package.json + jq --arg version "${{ inputs.new_version }}" '.version = $version' electron/package.json > /tmp/package.json + mv /tmp/package.json electron/package.json jq --arg version "${{ inputs.new_version }}" '.version = $version' web/package.json > /tmp/package.json mv /tmp/package.json web/package.json - # jq '.build.publish = [{"provider": "generic", "url": "https://delta.jan.ai/nightly", "channel": "latest"}, {"provider": "s3", "acl": null, "bucket": "${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}", "region": "${{ secrets.DELTA_AWS_REGION}}", "path": "temp-nightly", "channel": "latest"}]' electron/package.json > /tmp/package.json - # mv /tmp/package.json electron/package.json + jq '.build.publish = [{"provider": "generic", "url": "https://delta.jan.ai/nightly", "channel": "latest"}, {"provider": "s3", "acl": null, "bucket": "${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}", "region": "${{ secrets.DELTA_AWS_REGION}}", "path": "temp-nightly", "channel": "latest"}]' electron/package.json > /tmp/package.json + mv /tmp/package.json electron/package.json - # jq --arg teamid "${{ secrets.APPLE_TEAM_ID }}" '.build.mac.notarize.teamId = $teamid' electron/package.json > /tmp/package.json - # mv /tmp/package.json electron/package.json + jq --arg teamid "${{ secrets.APPLE_TEAM_ID }}" '.build.mac.notarize.teamId = $teamid' electron/package.json > /tmp/package.json + mv /tmp/package.json electron/package.json # cat electron/package.json - # chmod +x .github/scripts/rename-app.sh - # .github/scripts/rename-app.sh ./electron/package.json nightly - # chmod +x .github/scripts/rename-workspace.sh - # .github/scripts/rename-workspace.sh ./package.json nightly - # echo "------------------------" - # cat ./electron/package.json - # echo "------------------------" + chmod +x .github/scripts/rename-app.sh + .github/scripts/rename-app.sh ./electron/package.json nightly + chmod +x .github/scripts/rename-workspace.sh + .github/scripts/rename-workspace.sh ./package.json nightly + echo "------------------------" + cat ./electron/package.json + echo "------------------------" - name: Change App Name for beta version if: inputs.beta == true @@ -173,19 +148,11 @@ jobs: env: VERSION_TAG: ${{ inputs.new_version }} - # - name: Get Cer for code signing - # run: | - # echo "$CODE_SIGN_P12_BASE64" > /tmp/certificate-base64.txt - # openssl base64 -in /tmp/codesign.p12 -out /tmp/certificate-base64.txt - # shell: bash - # env: - # CODE_SIGN_P12_BASE64: ${{ secrets.CODE_SIGN_P12_BASE64 }} - - - name: Get key for notarize - run: base64 -d <<< "$NOTARIZE_P8_BASE64" > /tmp/notary-key.p8 + - name: Get Cer for code signing + run: base64 -d <<< "$CODE_SIGN_P12_BASE64" > /tmp/codesign.p12 shell: bash env: - NOTARIZE_P8_BASE64: ${{ secrets.NOTARIZE_P8_BASE64 }} + CODE_SIGN_P12_BASE64: ${{ secrets.CODE_SIGN_P12_BASE64 }} - uses: apple-actions/import-codesign-certs@v2 continue-on-error: true @@ -193,20 +160,6 @@ jobs: p12-file-base64: ${{ secrets.CODE_SIGN_P12_BASE64 }} p12-password: ${{ secrets.CODE_SIGN_P12_PASSWORD }} - - name: Inject Tauri Signing Public Key - run: | - if [ -f "src-tauri/tauri.conf.json" ]; then - echo "Injecting Tauri public key into configuration..." - # Use jq to update the pubkey field in the tauri.conf.json file - jq --arg pubkey "$TAURI_SIGNING_PUBLIC_KEY" '.plugins.updater.pubkey = $pubkey' src-tauri/tauri.conf.json > /tmp/tauri.conf.json - mv /tmp/tauri.conf.json src-tauri/tauri.conf.json - echo "Tauri configuration updated successfully" - else - echo "tauri.conf.json not found" - fi - env: - TAURI_SIGNING_PUBLIC_KEY: ${{ secrets.TAURI_SIGNING_PUBLIC_KEY }} - - name: Build and publish app to aws s3 r2 or github artifactory if: inputs.public_provider != 'github' run: | @@ -219,28 +172,21 @@ jobs: fi env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # CSC_LINK: '/tmp/codesign.p12' - # CSC_KEY_PASSWORD: ${{ secrets.CODE_SIGN_P12_PASSWORD }} - # CSC_IDENTITY_AUTO_DISCOVERY: 'true' - + CSC_LINK: '/tmp/codesign.p12' + CSC_KEY_PASSWORD: ${{ secrets.CODE_SIGN_P12_PASSWORD }} + CSC_IDENTITY_AUTO_DISCOVERY: 'true' + APPLE_ID: ${{ secrets.APPLE_ID }} + APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }} APP_PATH: '.' - # DEVELOPER_ID: ${{ secrets.DEVELOPER_ID }} - # AWS_ACCESS_KEY_ID: ${{ secrets.DELTA_AWS_ACCESS_KEY_ID }} - # AWS_SECRET_ACCESS_KEY: ${{ secrets.DELTA_AWS_SECRET_ACCESS_KEY }} - # AWS_DEFAULT_REGION: auto - # AWS_EC2_METADATA_DISABLED: 'true' - # AWS_MAX_ATTEMPTS: '5' + DEVELOPER_ID: ${{ secrets.DEVELOPER_ID }} + AWS_ACCESS_KEY_ID: ${{ secrets.DELTA_AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.DELTA_AWS_SECRET_ACCESS_KEY }} + AWS_DEFAULT_REGION: auto + AWS_EC2_METADATA_DISABLED: 'true' + AWS_MAX_ATTEMPTS: '5' POSTHOG_KEY: ${{ secrets.POSTHOG_KEY }} POSTHOG_HOST: ${{ secrets.POSTHOG_HOST }} - # CORTEX_API_PORT: ${{ inputs.cortex_api_port }} - APPLE_CERTIFICATE: ${{ secrets.CODE_SIGN_P12_BASE64 }} - APPLE_CERTIFICATE_PASSWORD: ${{ secrets.CODE_SIGN_P12_PASSWORD }} - APPLE_API_ISSUER: ${{ secrets.NOTARY_ISSUER }} - APPLE_API_KEY: ${{ secrets.NOTARY_KEY_ID }} - APPLE_API_KEY_PATH: /tmp/notary-key.p8 - TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} - TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} - TAURI_SIGNING_PUBLIC_KEY: ${{ secrets.TAURI_SIGNING_PUBLIC_KEY }} + CORTEX_API_PORT: ${{ inputs.cortex_api_port }} - name: Build and publish app to github if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && inputs.public_provider == 'github' && inputs.beta == false @@ -248,23 +194,15 @@ jobs: make build-and-publish env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # CSC_LINK: '/tmp/codesign.p12' - # CSC_KEY_PASSWORD: ${{ secrets.CODE_SIGN_P12_PASSWORD }} - # CSC_IDENTITY_AUTO_DISCOVERY: 'true' - # APPLE_ID: ${{ secrets.APPLE_ID }} - # APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }} + CSC_LINK: '/tmp/codesign.p12' + CSC_KEY_PASSWORD: ${{ secrets.CODE_SIGN_P12_PASSWORD }} + CSC_IDENTITY_AUTO_DISCOVERY: 'true' + APPLE_ID: ${{ secrets.APPLE_ID }} + APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }} APP_PATH: '.' - # DEVELOPER_ID: ${{ secrets.DEVELOPER_ID }} + DEVELOPER_ID: ${{ secrets.DEVELOPER_ID }} POSTHOG_KEY: ${{ secrets.POSTHOG_KEY }} POSTHOG_HOST: ${{ secrets.POSTHOG_HOST }} - APPLE_CERTIFICATE: ${{ secrets.CODE_SIGN_P12_BASE64 }} - APPLE_CERTIFICATE_PASSWORD: ${{ secrets.CODE_SIGN_P12_PASSWORD }} - APPLE_API_ISSUER: ${{ secrets.NOTARY_ISSUER }} - APPLE_API_KEY: ${{ secrets.NOTARY_KEY_ID }} - APPLE_API_KEY_PATH: /tmp/notary-key.p8 - TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} - TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} - TAURI_SIGNING_PUBLIC_KEY: ${{ secrets.TAURI_SIGNING_PUBLIC_KEY }} - name: Build and publish app to github if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && inputs.public_provider == 'github' && inputs.beta == true @@ -272,44 +210,24 @@ jobs: make build-and-publish env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # CSC_LINK: '/tmp/codesign.p12' - # CSC_KEY_PASSWORD: ${{ secrets.CODE_SIGN_P12_PASSWORD }} - # CSC_IDENTITY_AUTO_DISCOVERY: 'true' - # APPLE_ID: ${{ secrets.APPLE_ID }} - # APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }} + CSC_LINK: '/tmp/codesign.p12' + CSC_KEY_PASSWORD: ${{ secrets.CODE_SIGN_P12_PASSWORD }} + CSC_IDENTITY_AUTO_DISCOVERY: 'true' + APPLE_ID: ${{ secrets.APPLE_ID }} + APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }} APP_PATH: '.' - # DEVELOPER_ID: ${{ secrets.DEVELOPER_ID }} - # AWS_ACCESS_KEY_ID: ${{ secrets.DELTA_AWS_ACCESS_KEY_ID }} - # AWS_SECRET_ACCESS_KEY: ${{ secrets.DELTA_AWS_SECRET_ACCESS_KEY }} - # AWS_DEFAULT_REGION: auto - # AWS_EC2_METADATA_DISABLED: 'true' - # AWS_MAX_ATTEMPTS: '5' + DEVELOPER_ID: ${{ secrets.DEVELOPER_ID }} + AWS_ACCESS_KEY_ID: ${{ secrets.DELTA_AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.DELTA_AWS_SECRET_ACCESS_KEY }} + AWS_DEFAULT_REGION: auto + AWS_EC2_METADATA_DISABLED: 'true' + AWS_MAX_ATTEMPTS: '5' POSTHOG_KEY: ${{ secrets.POSTHOG_KEY }} POSTHOG_HOST: ${{ secrets.POSTHOG_HOST }} - APPLE_CERTIFICATE: ${{ secrets.CODE_SIGN_P12_BASE64 }} - APPLE_CERTIFICATE_PASSWORD: ${{ secrets.CODE_SIGN_P12_PASSWORD }} - APPLE_API_ISSUER: ${{ secrets.NOTARY_ISSUER }} - APPLE_API_KEY: ${{ secrets.NOTARY_KEY_ID }} - APPLE_API_KEY_PATH: /tmp/notary-key.p8 - name: Upload Artifact if: inputs.public_provider != 'github' uses: actions/upload-artifact@v4 with: name: jan-mac-universal-${{ inputs.new_version }} - path: | - ./src-tauri/target/release/bundle/dmg/*.dmg - - - name: zip Jan-nightly.app file - if: inputs.public_provider != 'github' - run: | - cd ./src-tauri/target/release/bundle/macos - zip -r jan-nightly.zip Jan-nightly.app - - - name: Upload Artifact - if: inputs.public_provider != 'github' - uses: actions/upload-artifact@v4 - with: - name: jan-mac-universal-${{ inputs.new_version }}-tar-gz - path: | - ./src-tauri/target/release/bundle/macos/jan-nightly.zip \ No newline at end of file + path: ./electron/dist/*.dmg \ No newline at end of file diff --git a/.github/workflows/template-build-windows-x64.yml b/.github/workflows/template-build-windows-x64.yml index 392b6d0db..9be028e15 100644 --- a/.github/workflows/template-build-windows-x64.yml +++ b/.github/workflows/template-build-windows-x64.yml @@ -5,20 +5,20 @@ on: ref: required: true type: string - default: "refs/heads/main" + default: 'refs/heads/main' public_provider: required: true type: string default: none - description: "none: build only, github: build and publish to github, aws s3: build and publish to aws s3" + description: 'none: build only, github: build and publish to github, aws s3: build and publish to aws s3' new_version: required: true type: string - default: "" + default: '' aws_s3_prefix: required: false type: string - default: "/latest/" + default: '/latest/' beta: required: false type: boolean @@ -48,12 +48,6 @@ on: required: false AZURE_CERT_NAME: required: false - TAURI_SIGNING_PRIVATE_KEY: - required: false - TAURI_SIGNING_PRIVATE_KEY_PASSWORD: - required: false - TAURI_SIGNING_PUBLIC_KEY: - required: false jobs: build-windows-x64: @@ -98,86 +92,37 @@ jobs: - name: Install jq uses: dcarbone/install-jq-action@v2.0.1 - - name: Install ctoml - run: | - cargo install ctoml - - name: Update app version base on tag if: inputs.public_provider != 'github' id: version_update shell: bash run: | echo "Version: ${{ inputs.new_version }}" - # Update tauri.conf.json - jq --arg version "${{ inputs.new_version }}" --arg template tauri.bundle.windows.nsis.template '.version = $version | .bundle.createUpdaterArtifacts = true | .bundle.windows.nsis.template = $template' ./src-tauri/tauri.conf.json > /tmp/tauri.conf.json - mv /tmp/tauri.conf.json ./src-tauri/tauri.conf.json - - chmod +x .github/scripts/rename-tauri-app.sh - .github/scripts/rename-tauri-app.sh ./src-tauri/tauri.conf.json nightly - - echo ./src-tauri/tauri.conf.json - - # Update Cargo.toml - ctoml ./src-tauri/Cargo.toml package.name "Jan-nightly" - ctoml ./src-tauri/Cargo.toml package.version "${{ inputs.new_version }}" - echo "------------------" - cat ./src-tauri/Cargo.toml - - # Update template - get_latest_tag() { - local retries=0 - local max_retries=3 - local tag - while [ $retries -lt $max_retries ]; do - tag=$(curl -s https://api.github.com/repos/menloresearch/jan/releases/latest | jq -r .tag_name) - if [ -n "$tag" ] && [ "$tag" != "null" ]; then - echo $tag - return - else - let retries++ - echo "Retrying... ($retries/$max_retries)" - sleep 2 - fi - done - echo "Failed to fetch latest tag after $max_retries attempts." - exit 1 - } - - LATEST_TAG=$(get_latest_tag) - jan_tag="${LATEST_TAG#v}.0" - echo $jan_tag - sed -i "s/jan_productname/Jan-nightly/g" ./src-tauri/tauri.bundle.windows.nsis.template - sed -i "s/jan_version/${{ inputs.new_version }}/g" ./src-tauri/tauri.bundle.windows.nsis.template - sed -i "s/jan_build/$jan_tag/g" ./src-tauri/tauri.bundle.windows.nsis.template - sed -i "s/jan_mainbinaryname/jan-nightly/g" ./src-tauri/tauri.bundle.windows.nsis.template - echo "------------------" - cat ./src-tauri/tauri.bundle.windows.nsis.template - # Update the version in electron/package.json - # jq --arg version "${{ inputs.new_version }}" '.version = $version' electron/package.json > /tmp/package.json - # mv /tmp/package.json electron/package.json + jq --arg version "${{ inputs.new_version }}" '.version = $version' electron/package.json > /tmp/package.json + mv /tmp/package.json electron/package.json jq --arg version "${{ inputs.new_version }}" '.version = $version' web/package.json > /tmp/package.json mv /tmp/package.json web/package.json - # jq '.build.publish = [{"provider": "generic", "url": "https://delta.jan.ai/nightly", "channel": "latest"}, {"provider": "s3", "acl": null, "bucket": "${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}", "region": "${{ secrets.DELTA_AWS_REGION}}", "path": "temp-nightly", "channel": "latest"}]' electron/package.json > /tmp/package.json - # mv /tmp/package.json electron/package.json + jq '.build.publish = [{"provider": "generic", "url": "https://delta.jan.ai/nightly", "channel": "latest"}, {"provider": "s3", "acl": null, "bucket": "${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}", "region": "${{ secrets.DELTA_AWS_REGION}}", "path": "temp-nightly", "channel": "latest"}]' electron/package.json > /tmp/package.json + mv /tmp/package.json electron/package.json - # jq '.build.win.sign = "./sign.js"' electron/package.json > /tmp/package.json - # mv /tmp/package.json electron/package.json - # cat electron/package.json + jq '.build.win.sign = "./sign.js"' electron/package.json > /tmp/package.json + mv /tmp/package.json electron/package.json + cat electron/package.json - # chmod +x .github/scripts/rename-app.sh - # .github/scripts/rename-app.sh ./electron/package.json nightly - # chmod +x .github/scripts/rename-workspace.sh - # .github/scripts/rename-workspace.sh ./package.json nightly - # chmod +x .github/scripts/rename-uninstaller.sh - # .github/scripts/rename-uninstaller.sh nightly - # echo "------------------------" - # cat ./electron/package.json - # echo "------------------------" - # cat ./package.json - # echo "------------------------" + chmod +x .github/scripts/rename-app.sh + .github/scripts/rename-app.sh ./electron/package.json nightly + chmod +x .github/scripts/rename-workspace.sh + .github/scripts/rename-workspace.sh ./package.json nightly + chmod +x .github/scripts/rename-uninstaller.sh + .github/scripts/rename-uninstaller.sh nightly + echo "------------------------" + cat ./electron/package.json + echo "------------------------" + cat ./package.json + echo "------------------------" - name: Change App Name for beta version if: inputs.beta == true @@ -203,13 +148,6 @@ jobs: if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && inputs.public_provider == 'github' shell: bash run: | - echo "Version: ${{ inputs.new_version }}" - # Update version in tauri.conf.json - jq --arg version "${{ inputs.new_version }}" '.version = $version' ./src-tauri/tauri.conf.json > /tmp/tauri.conf.json - mv /tmp/tauri.conf.json ./src-tauri/tauri.conf.json - jq --arg template tauri.bundle.windows.nsis '.bundle.windows.nsis.template = $template' ./src-tauri/tauri.conf.json > /tmp/tauri.conf.json - mv /tmp/tauri.conf.json ./src-tauri/tauri.conf.json - jq --arg version "${VERSION_TAG#v}" '.version = $version' electron/package.json > /tmp/package.json mv /tmp/package.json electron/package.json jq --arg version "${VERSION_TAG#v}" '.version = $version' web/package.json > /tmp/package.json @@ -221,22 +159,7 @@ jobs: - name: Install AzureSignTool run: | - dotnet tool install --global --version 6.0.0 AzureSignTool - - - name: Inject Tauri Signing Public Key - shell: bash - run: | - if [ -f "src-tauri/tauri.conf.json" ]; then - echo "Injecting Tauri public key into configuration..." - # Use jq to update the pubkey field in the tauri.conf.json file - jq --arg pubkey "$TAURI_SIGNING_PUBLIC_KEY" '.plugins.updater.pubkey = $pubkey' src-tauri/tauri.conf.json > /tmp/tauri.conf.json - mv /tmp/tauri.conf.json src-tauri/tauri.conf.json - echo "Tauri configuration updated successfully" - else - echo "tauri.conf.json not found" - fi - env: - TAURI_SIGNING_PUBLIC_KEY: ${{ secrets.TAURI_SIGNING_PUBLIC_KEY }} + dotnet tool install --global AzureSignTool - name: Build and publish app to aws s3 r2 or github artifactory shell: bash @@ -254,18 +177,15 @@ jobs: AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }} AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }} AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }} - AZURE_CERT_NAME: ${{ secrets.AZURE_CERT_NAME }} + AZURE_CERT_NAME: homebrewltd AWS_ACCESS_KEY_ID: ${{ secrets.DELTA_AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.DELTA_AWS_SECRET_ACCESS_KEY }} AWS_DEFAULT_REGION: auto - AWS_EC2_METADATA_DISABLED: "true" - AWS_MAX_ATTEMPTS: "5" + AWS_EC2_METADATA_DISABLED: 'true' + AWS_MAX_ATTEMPTS: '5' POSTHOG_KEY: ${{ secrets.POSTHOG_KEY }} POSTHOG_HOST: ${{ secrets.POSTHOG_HOST }} - # CORTEX_API_PORT: ${{ inputs.cortex_api_port }} - TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} - TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} - TAURI_SIGNING_PUBLIC_KEY: ${{ secrets.TAURI_SIGNING_PUBLIC_KEY }} + CORTEX_API_PORT: ${{ inputs.cortex_api_port }} - name: Build app and publish app to github if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && inputs.public_provider == 'github' && inputs.beta == false @@ -277,12 +197,9 @@ jobs: AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }} AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }} AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }} - AZURE_CERT_NAME: ${{ secrets.AZURE_CERT_NAME }} + AZURE_CERT_NAME: homebrewltd POSTHOG_KEY: ${{ secrets.POSTHOG_KEY }} POSTHOG_HOST: ${{ secrets.POSTHOG_HOST }} - TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} - TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} - TAURI_SIGNING_PUBLIC_KEY: ${{ secrets.TAURI_SIGNING_PUBLIC_KEY }} - name: Build app and publish app to github if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && inputs.public_provider == 'github' && inputs.beta == true @@ -293,22 +210,20 @@ jobs: AWS_ACCESS_KEY_ID: ${{ secrets.DELTA_AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.DELTA_AWS_SECRET_ACCESS_KEY }} AWS_DEFAULT_REGION: auto - AWS_EC2_METADATA_DISABLED: "true" - AWS_MAX_ATTEMPTS: "5" + AWS_EC2_METADATA_DISABLED: 'true' + AWS_MAX_ATTEMPTS: '5' AZURE_KEY_VAULT_URI: ${{ secrets.AZURE_KEY_VAULT_URI }} AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }} AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }} AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }} - AZURE_CERT_NAME: ${{ secrets.AZURE_CERT_NAME }} + # AZURE_CERT_NAME: ${{ secrets.AZURE_CERT_NAME }} + AZURE_CERT_NAME: homebrewltd POSTHOG_KEY: ${{ secrets.POSTHOG_KEY }} POSTHOG_HOST: ${{ secrets.POSTHOG_HOST }} - TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} - TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} - TAURI_SIGNING_PUBLIC_KEY: ${{ secrets.TAURI_SIGNING_PUBLIC_KEY }} - - name: Upload Signed Artifact + - name: Upload Artifact + if: inputs.public_provider != 'github' uses: actions/upload-artifact@v4 with: - name: jan-tauri-windows-${{ inputs.new_version }} - path: | - ./src-tauri/target/release/bundle/nsis/*.exe + name: jan-win-x64-${{ inputs.new_version }} + path: ./electron/dist/*.exe \ No newline at end of file diff --git a/.github/workflows/template-tauri-build-linux-x64.yml b/.github/workflows/template-tauri-build-linux-x64.yml new file mode 100644 index 000000000..997a9d67d --- /dev/null +++ b/.github/workflows/template-tauri-build-linux-x64.yml @@ -0,0 +1,241 @@ +name: tauri-build-linux-x64 +on: + workflow_call: + inputs: + ref: + required: true + type: string + default: 'refs/heads/main' + public_provider: + required: true + type: string + default: none + description: 'none: build only, github: build and publish to github, aws s3: build and publish to aws s3' + new_version: + required: true + type: string + default: '' + aws_s3_prefix: + required: false + type: string + default: '/latest/' + beta: + required: false + type: boolean + default: false + nightly: + required: false + type: boolean + default: false + cortex_api_port: + required: false + type: string + default: null + secrets: + DELTA_AWS_S3_BUCKET_NAME: + required: false + DELTA_AWS_ACCESS_KEY_ID: + required: false + DELTA_AWS_SECRET_ACCESS_KEY: + required: false + TAURI_SIGNING_PRIVATE_KEY: + required: false + TAURI_SIGNING_PRIVATE_KEY_PASSWORD: + required: false + TAURI_SIGNING_PUBLIC_KEY: + required: false + +jobs: + build-linux-x64: + runs-on: ubuntu-22.04 + environment: production + permissions: + contents: write + steps: + - name: Getting the repo + uses: actions/checkout@v3 + with: + ref: ${{ inputs.ref }} + + - name: Free Disk Space Before Build + run: | + echo "Disk space before cleanup:" + df -h + sudo rm -rf /usr/local/.ghcup + sudo rm -rf /opt/hostedtoolcache/CodeQL + sudo rm -rf /usr/local/lib/android/sdk/ndk + sudo rm -rf /usr/share/dotnet + sudo rm -rf /opt/ghc + sudo rm -rf /usr/local/share/boost + sudo apt-get clean + echo "Disk space after cleanup:" + df -h + + # - name: Replace Icons for Beta Build + # if: inputs.beta == true && inputs.nightly != true + # shell: bash + # run: | + # rm -rf electron/icons/* + + # cp electron/icons_dev/jan-beta-512x512.png electron/icons/512x512.png + # cp electron/icons_dev/jan-beta.ico electron/icons/icon.ico + # cp electron/icons_dev/jan-beta.png electron/icons/icon.png + # cp electron/icons_dev/jan-beta-tray@2x.png electron/icons/icon-tray@2x.png + # cp electron/icons_dev/jan-beta-tray.png electron/icons/icon-tray.png + + # - name: Replace Icons for Nightly Build + # if: inputs.nightly == true && inputs.beta != true + # shell: bash + # run: | + # rm -rf electron/icons/* + + # cp electron/icons_dev/jan-nightly-512x512.png electron/icons/512x512.png + # cp electron/icons_dev/jan-nightly.ico electron/icons/icon.ico + # cp electron/icons_dev/jan-nightly.png electron/icons/icon.png + # cp electron/icons_dev/jan-nightly-tray@2x.png electron/icons/icon-tray@2x.png + # cp electron/icons_dev/jan-nightly-tray.png electron/icons/icon-tray.png + + + - name: Installing node + uses: actions/setup-node@v1 + with: + node-version: 20 + + - name: Install jq + uses: dcarbone/install-jq-action@v2.0.1 + + - name: Install ctoml + run: | + cargo install ctoml + + - name: Install Tauri dependecies + run: | + sudo apt update + sudo apt install -y libglib2.0-dev libatk1.0-dev libpango1.0-dev libgtk-3-dev libsoup-3.0-dev libwebkit2gtk-4.1-dev librsvg2-dev + + - name: Update app version base public_provider + if: inputs.public_provider != 'github' + run: | + echo "Version: ${{ inputs.new_version }}" + # Update tauri.conf.json + jq --arg version "${{ inputs.new_version }}" '.version = $version | .bundle.createUpdaterArtifacts = true' ./src-tauri/tauri.conf.json > /tmp/tauri.conf.json + mv /tmp/tauri.conf.json ./src-tauri/tauri.conf.json + + chmod +x .github/scripts/rename-tauri-app.sh + .github/scripts/rename-tauri-app.sh ./src-tauri/tauri.conf.json nightly + + echo ./src-tauri/tauri.conf.json + + # Update Cargo.toml + ctoml ./src-tauri/Cargo.toml package.name "Jan-nightly" + ctoml ./src-tauri/Cargo.toml package.version "${{ inputs.new_version }}" + echo "------------------" + cat ./src-tauri/Cargo.toml + + chmod +x .github/scripts/rename-workspace.sh + .github/scripts/rename-workspace.sh ./package.json nightly + + - name: Change App Name for beta version + if: inputs.beta == true + shell: bash + run: | + chmod +x .github/scripts/rename-tauri-app.sh + .github/scripts/rename-tauri-app.sh ./src-tauri/tauri.conf.json beta + cat ./src-tauri/tauri.conf.json + echo "------------------" + ctoml ./src-tauri/Cargo.toml package.name "Jan-beta" + cat ./src-tauri/Cargo.toml + echo "------------------" + chmod +x .github/scripts/rename-workspace.sh + .github/scripts/rename-workspace.sh ./package.json beta + cat ./package.json + + - name: Update app version base on tag + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && inputs.public_provider == 'github' + run: | + jq --arg version "${VERSION_TAG#v}" '.version = $version | .bundle.createUpdaterArtifacts = true' ./src-tauri/tauri.conf.json > /tmp/tauri.conf.json + mv /tmp/tauri.conf.json ./src-tauri/tauri.conf.json + ctoml ./src-tauri/Cargo.toml package.version "${VERSION_TAG#v}" + jq --arg version "${VERSION_TAG#v}" '.version = $version' web/package.json > /tmp/package.json + mv /tmp/package.json web/package.json + env: + VERSION_TAG: ${{ inputs.new_version }} + + - name: Inject Tauri Signing Public Key + run: | + if [ -f "src-tauri/tauri.conf.json" ]; then + echo "Injecting Tauri public key into configuration..." + # Use jq to update the pubkey field in the tauri.conf.json file + jq --arg pubkey "$TAURI_SIGNING_PUBLIC_KEY" '.plugins.updater.pubkey = $pubkey' src-tauri/tauri.conf.json > /tmp/tauri.conf.json + mv /tmp/tauri.conf.json src-tauri/tauri.conf.json + echo "Tauri configuration updated successfully" + else + echo "tauri.conf.json not found" + fi + env: + TAURI_SIGNING_PUBLIC_KEY: ${{ secrets.TAURI_SIGNING_PUBLIC_KEY }} + + - name: Build and publish app to aws s3 r2 or github artifactory + if: inputs.public_provider != 'github' + run: | + # check public_provider is true or not + echo "public_provider is ${{ inputs.public_provider }}" + if [ "${{ inputs.public_provider }}" == "none" ]; then + make build-tauri + else + make build-and-publish + fi + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + AWS_ACCESS_KEY_ID: ${{ secrets.DELTA_AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.DELTA_AWS_SECRET_ACCESS_KEY }} + AWS_EC2_METADATA_DISABLED: 'true' + AWS_MAX_ATTEMPTS: '5' + POSTHOG_KEY: ${{ secrets.POSTHOG_KEY }} + POSTHOG_HOST: ${{ secrets.POSTHOG_HOST }} + # CORTEX_API_PORT: ${{ inputs.cortex_api_port }} + TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} + TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} + TAURI_SIGNING_PUBLIC_KEY: ${{ secrets.TAURI_SIGNING_PUBLIC_KEY }} + + - name: Build and publish app to github + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && inputs.public_provider == 'github' && inputs.beta == false + run: | + make build-and-publish + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + POSTHOG_KEY: ${{ secrets.POSTHOG_KEY }} + POSTHOG_HOST: ${{ secrets.POSTHOG_HOST }} + TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} + TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} + TAURI_SIGNING_PUBLIC_KEY: ${{ secrets.TAURI_SIGNING_PUBLIC_KEY }} + + - name: Build and publish app to github + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && inputs.public_provider == 'github' && inputs.beta == true + run: | + make build-and-publish + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + AWS_ACCESS_KEY_ID: ${{ secrets.DELTA_AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.DELTA_AWS_SECRET_ACCESS_KEY }} + AWS_EC2_METADATA_DISABLED: 'true' + AWS_MAX_ATTEMPTS: '5' + POSTHOG_KEY: ${{ secrets.POSTHOG_KEY }} + POSTHOG_HOST: ${{ secrets.POSTHOG_HOST }} + TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} + TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} + TAURI_SIGNING_PUBLIC_KEY: ${{ secrets.TAURI_SIGNING_PUBLIC_KEY }} + + - name: Upload Artifact .deb file + if: inputs.public_provider != 'github' + uses: actions/upload-artifact@v4 + with: + name: jan-linux-amd64-${{ inputs.new_version }}-deb + path: ./src-tauri/target/release/bundle/deb/*.deb + + - name: Upload Artifact .AppImage file + if: inputs.public_provider != 'github' + uses: actions/upload-artifact@v4 + with: + name: jan-linux-amd64-${{ inputs.new_version }}-AppImage + path: ./src-tauri/target/release/bundle/appimage/*.AppImage \ No newline at end of file diff --git a/.github/workflows/template-tauri-build-macos.yml b/.github/workflows/template-tauri-build-macos.yml new file mode 100644 index 000000000..e7d67c062 --- /dev/null +++ b/.github/workflows/template-tauri-build-macos.yml @@ -0,0 +1,261 @@ +name: tauri-build-macos +on: + workflow_call: + inputs: + ref: + required: true + type: string + default: 'refs/heads/main' + public_provider: + required: true + type: string + default: none + description: 'none: build only, github: build and publish to github, aws s3: build and publish to aws s3' + new_version: + required: true + type: string + default: '' + aws_s3_prefix: + required: false + type: string + default: '/latest/' + beta: + required: false + type: boolean + default: false + nightly: + required: false + type: boolean + default: false + cortex_api_port: + required: false + type: string + default: null + secrets: + DELTA_AWS_S3_BUCKET_NAME: + required: false + DELTA_AWS_ACCESS_KEY_ID: + required: false + DELTA_AWS_SECRET_ACCESS_KEY: + required: false + CODE_SIGN_P12_BASE64: + required: false + CODE_SIGN_P12_PASSWORD: + required: false + APPLE_ID: + required: false + APPLE_APP_SPECIFIC_PASSWORD: + required: false + DEVELOPER_ID: + required: false + TAURI_SIGNING_PRIVATE_KEY: + required: false + TAURI_SIGNING_PRIVATE_KEY_PASSWORD: + required: false + TAURI_SIGNING_PUBLIC_KEY: + required: false + +jobs: + build-macos: + runs-on: macos-latest + environment: production + permissions: + contents: write + steps: + - name: Getting the repo + uses: actions/checkout@v3 + with: + ref: ${{ inputs.ref }} + + # - name: Replace Icons for Beta Build + # if: inputs.beta == true && inputs.nightly != true + # shell: bash + # run: | + # rm -rf electron/icons/* + + # cp electron/icons_dev/jan-beta-512x512.png electron/icons/512x512.png + # cp electron/icons_dev/jan-beta.ico electron/icons/icon.ico + # cp electron/icons_dev/jan-beta.png electron/icons/icon.png + # cp electron/icons_dev/jan-beta-tray@2x.png electron/icons/icon-tray@2x.png + # cp electron/icons_dev/jan-beta-tray.png electron/icons/icon-tray.png + + # - name: Replace Icons for Nightly Build + # if: inputs.nightly == true && inputs.beta != true + # shell: bash + # run: | + # rm -rf electron/icons/* + + # cp electron/icons_dev/jan-nightly-512x512.png electron/icons/512x512.png + # cp electron/icons_dev/jan-nightly.ico electron/icons/icon.ico + # cp electron/icons_dev/jan-nightly.png electron/icons/icon.png + # cp electron/icons_dev/jan-nightly-tray@2x.png electron/icons/icon-tray@2x.png + # cp electron/icons_dev/jan-nightly-tray.png electron/icons/icon-tray.png + + - name: Installing node + uses: actions/setup-node@v1 + with: + node-version: 20 + + - name: Install jq + uses: dcarbone/install-jq-action@v2.0.1 + + - name: Install ctoml + run: | + cargo install ctoml + + - name: Update app version based on latest release tag with build number + if: inputs.public_provider != 'github' + run: | + echo "Version: ${{ inputs.new_version }}" + # Update tauri.conf.json + jq --arg version "${{ inputs.new_version }}" '.version = $version | .bundle.createUpdaterArtifacts = true' ./src-tauri/tauri.conf.json > /tmp/tauri.conf.json + mv /tmp/tauri.conf.json ./src-tauri/tauri.conf.json + + chmod +x .github/scripts/rename-tauri-app.sh + .github/scripts/rename-tauri-app.sh ./src-tauri/tauri.conf.json nightly + echo ./src-tauri/tauri.conf.json + + # Update Cargo.toml + ctoml ./src-tauri/Cargo.toml package.name "Jan-nightly" + ctoml ./src-tauri/Cargo.toml package.version "${{ inputs.new_version }}" + echo "------------------" + cat ./src-tauri/Cargo.toml + + jq --arg version "${{ inputs.new_version }}" '.version = $version' web/package.json > /tmp/package.json + mv /tmp/package.json web/package.json + + chmod +x .github/scripts/rename-workspace.sh + .github/scripts/rename-workspace.sh ./package.json nightly + cat ./package.json + + - name: Change App Name for beta version + if: inputs.beta == true + shell: bash + run: | + chmod +x .github/scripts/rename-tauri-app.sh + .github/scripts/rename-tauri-app.sh ./src-tauri/tauri.conf.json beta + cat ./src-tauri/tauri.conf.json + echo "------------------" + ctoml ./src-tauri/Cargo.toml package.name "Jan-beta" + cat ./src-tauri/Cargo.toml + echo "------------------" + chmod +x .github/scripts/rename-workspace.sh + .github/scripts/rename-workspace.sh ./package.json beta + cat ./package.json + + - name: Update app version base on tag + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && inputs.public_provider == 'github' + run: | + jq --arg version "${VERSION_TAG#v}" '.version = $version | .bundle.createUpdaterArtifacts = true' ./src-tauri/tauri.conf.json > /tmp/tauri.conf.json + mv /tmp/tauri.conf.json ./src-tauri/tauri.conf.json + ctoml ./src-tauri/Cargo.toml package.version "${VERSION_TAG#v}" + jq --arg version "${VERSION_TAG#v}" '.version = $version' web/package.json > /tmp/package.json + mv /tmp/package.json web/package.json + env: + VERSION_TAG: ${{ inputs.new_version }} + + - name: Get key for notarize + run: base64 -d <<< "$NOTARIZE_P8_BASE64" > /tmp/notary-key.p8 + shell: bash + env: + NOTARIZE_P8_BASE64: ${{ secrets.NOTARIZE_P8_BASE64 }} + + - uses: apple-actions/import-codesign-certs@v2 + continue-on-error: true + with: + p12-file-base64: ${{ secrets.CODE_SIGN_P12_BASE64 }} + p12-password: ${{ secrets.CODE_SIGN_P12_PASSWORD }} + + - name: Inject Tauri Signing Public Key + run: | + if [ -f "src-tauri/tauri.conf.json" ]; then + echo "Injecting Tauri public key into configuration..." + # Use jq to update the pubkey field in the tauri.conf.json file + jq --arg pubkey "$TAURI_SIGNING_PUBLIC_KEY" '.plugins.updater.pubkey = $pubkey' src-tauri/tauri.conf.json > /tmp/tauri.conf.json + mv /tmp/tauri.conf.json src-tauri/tauri.conf.json + echo "Tauri configuration updated successfully" + else + echo "tauri.conf.json not found" + fi + env: + TAURI_SIGNING_PUBLIC_KEY: ${{ secrets.TAURI_SIGNING_PUBLIC_KEY }} + + - name: Build and publish app to aws s3 r2 or github artifactory + if: inputs.public_provider != 'github' + run: | + # check public_provider is true or not + echo "public_provider is ${{ inputs.public_provider }}" + if [ "${{ inputs.public_provider }}" == "none" ]; then + make build-tauri + else + make build-and-publish + fi + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + APP_PATH: '.' + POSTHOG_KEY: ${{ secrets.POSTHOG_KEY }} + POSTHOG_HOST: ${{ secrets.POSTHOG_HOST }} + # CORTEX_API_PORT: ${{ inputs.cortex_api_port }} + APPLE_CERTIFICATE: ${{ secrets.CODE_SIGN_P12_BASE64 }} + APPLE_CERTIFICATE_PASSWORD: ${{ secrets.CODE_SIGN_P12_PASSWORD }} + APPLE_API_ISSUER: ${{ secrets.NOTARY_ISSUER }} + APPLE_API_KEY: ${{ secrets.NOTARY_KEY_ID }} + APPLE_API_KEY_PATH: /tmp/notary-key.p8 + TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} + TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} + TAURI_SIGNING_PUBLIC_KEY: ${{ secrets.TAURI_SIGNING_PUBLIC_KEY }} + + - name: Build and publish app to github + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && inputs.public_provider == 'github' && inputs.beta == false + run: | + make build-and-publish + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + APP_PATH: '.' + POSTHOG_KEY: ${{ secrets.POSTHOG_KEY }} + POSTHOG_HOST: ${{ secrets.POSTHOG_HOST }} + APPLE_CERTIFICATE: ${{ secrets.CODE_SIGN_P12_BASE64 }} + APPLE_CERTIFICATE_PASSWORD: ${{ secrets.CODE_SIGN_P12_PASSWORD }} + APPLE_API_ISSUER: ${{ secrets.NOTARY_ISSUER }} + APPLE_API_KEY: ${{ secrets.NOTARY_KEY_ID }} + APPLE_API_KEY_PATH: /tmp/notary-key.p8 + TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} + TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} + TAURI_SIGNING_PUBLIC_KEY: ${{ secrets.TAURI_SIGNING_PUBLIC_KEY }} + + - name: Build and publish app to github + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && inputs.public_provider == 'github' && inputs.beta == true + run: | + make build-and-publish + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + APP_PATH: '.' + POSTHOG_KEY: ${{ secrets.POSTHOG_KEY }} + POSTHOG_HOST: ${{ secrets.POSTHOG_HOST }} + APPLE_CERTIFICATE: ${{ secrets.CODE_SIGN_P12_BASE64 }} + APPLE_CERTIFICATE_PASSWORD: ${{ secrets.CODE_SIGN_P12_PASSWORD }} + APPLE_API_ISSUER: ${{ secrets.NOTARY_ISSUER }} + APPLE_API_KEY: ${{ secrets.NOTARY_KEY_ID }} + APPLE_API_KEY_PATH: /tmp/notary-key.p8 + + - name: Upload Artifact + if: inputs.public_provider != 'github' + uses: actions/upload-artifact@v4 + with: + name: jan-mac-universal-${{ inputs.new_version }} + path: | + ./src-tauri/target/release/bundle/dmg/*.dmg + + - name: zip Jan-nightly.app file + if: inputs.public_provider != 'github' + run: | + cd ./src-tauri/target/release/bundle/macos + zip -r jan-nightly.zip Jan-nightly.app + + - name: Upload Artifact + if: inputs.public_provider != 'github' + uses: actions/upload-artifact@v4 + with: + name: jan-mac-universal-${{ inputs.new_version }}-tar-gz + path: | + ./src-tauri/target/release/bundle/macos/jan-nightly.zip \ No newline at end of file diff --git a/.github/workflows/template-tauri-build-windows-x64.yml b/.github/workflows/template-tauri-build-windows-x64.yml new file mode 100644 index 000000000..367d30ab7 --- /dev/null +++ b/.github/workflows/template-tauri-build-windows-x64.yml @@ -0,0 +1,302 @@ +name: tauri-build-windows-x64 +on: + workflow_call: + inputs: + ref: + required: true + type: string + default: "refs/heads/main" + public_provider: + required: true + type: string + default: none + description: "none: build only, github: build and publish to github, aws s3: build and publish to aws s3" + new_version: + required: true + type: string + default: "" + aws_s3_prefix: + required: false + type: string + default: "/latest/" + beta: + required: false + type: boolean + default: false + nightly: + required: false + type: boolean + default: false + cortex_api_port: + required: false + type: string + default: null + secrets: + DELTA_AWS_S3_BUCKET_NAME: + required: false + DELTA_AWS_ACCESS_KEY_ID: + required: false + DELTA_AWS_SECRET_ACCESS_KEY: + required: false + AZURE_KEY_VAULT_URI: + required: false + AZURE_CLIENT_ID: + required: false + AZURE_TENANT_ID: + required: false + AZURE_CLIENT_SECRET: + required: false + AZURE_CERT_NAME: + required: false + TAURI_SIGNING_PRIVATE_KEY: + required: false + TAURI_SIGNING_PRIVATE_KEY_PASSWORD: + required: false + TAURI_SIGNING_PUBLIC_KEY: + required: false + +jobs: + build-windows-x64: + runs-on: windows-latest + permissions: + contents: write + steps: + - name: Getting the repo + uses: actions/checkout@v3 + with: + ref: ${{ inputs.ref }} + + # - name: Replace Icons for Beta Build + # if: inputs.beta == true && inputs.nightly != true + # shell: bash + # run: | + # rm -rf electron/icons/* + + # cp electron/icons_dev/jan-beta-512x512.png electron/icons/512x512.png + # cp electron/icons_dev/jan-beta.ico electron/icons/icon.ico + # cp electron/icons_dev/jan-beta.png electron/icons/icon.png + # cp electron/icons_dev/jan-beta-tray@2x.png electron/icons/icon-tray@2x.png + # cp electron/icons_dev/jan-beta-tray.png electron/icons/icon-tray.png + + # - name: Replace Icons for Nightly Build + # if: inputs.nightly == true && inputs.beta != true + # shell: bash + # run: | + # rm -rf electron/icons/* + + # cp electron/icons_dev/jan-nightly-512x512.png electron/icons/512x512.png + # cp electron/icons_dev/jan-nightly.ico electron/icons/icon.ico + # cp electron/icons_dev/jan-nightly.png electron/icons/icon.png + # cp electron/icons_dev/jan-nightly-tray@2x.png electron/icons/icon-tray@2x.png + # cp electron/icons_dev/jan-nightly-tray.png electron/icons/icon-tray.png + + - name: Installing node + uses: actions/setup-node@v1 + with: + node-version: 20 + + - name: Install jq + uses: dcarbone/install-jq-action@v2.0.1 + + - name: Install ctoml + run: | + cargo install ctoml + + - name: Update app version base on tag + if: inputs.public_provider != 'github' + id: version_update + shell: bash + run: | + echo "Version: ${{ inputs.new_version }}" + # Update tauri.conf.json + jq --arg version "${{ inputs.new_version }}" --arg template tauri.bundle.windows.nsis.template '.version = $version | .bundle.createUpdaterArtifacts = true | .bundle.windows.nsis.template = $template' ./src-tauri/tauri.conf.json > /tmp/tauri.conf.json + mv /tmp/tauri.conf.json ./src-tauri/tauri.conf.json + + chmod +x .github/scripts/rename-tauri-app.sh + .github/scripts/rename-tauri-app.sh ./src-tauri/tauri.conf.json nightly + echo ./src-tauri/tauri.conf.json + + # Update Cargo.toml + ctoml ./src-tauri/Cargo.toml package.name "Jan-nightly" + ctoml ./src-tauri/Cargo.toml package.version "${{ inputs.new_version }}" + echo "------------------" + cat ./src-tauri/Cargo.toml + + # Update template + get_latest_tag() { + local retries=0 + local max_retries=3 + local tag + while [ $retries -lt $max_retries ]; do + tag=$(curl -s https://api.github.com/repos/menloresearch/jan/releases/latest | jq -r .tag_name) + if [ -n "$tag" ] && [ "$tag" != "null" ]; then + echo $tag + return + else + let retries++ + echo "Retrying... ($retries/$max_retries)" + sleep 2 + fi + done + echo "Failed to fetch latest tag after $max_retries attempts." + exit 1 + } + + LATEST_TAG=$(get_latest_tag) + jan_tag="${LATEST_TAG#v}.0" + echo $jan_tag + sed -i "s/jan_productname/Jan-nightly/g" ./src-tauri/tauri.bundle.windows.nsis.template + sed -i "s/jan_version/${{ inputs.new_version }}/g" ./src-tauri/tauri.bundle.windows.nsis.template + sed -i "s/jan_build/$jan_tag/g" ./src-tauri/tauri.bundle.windows.nsis.template + sed -i "s/jan_mainbinaryname/jan-nightly/g" ./src-tauri/tauri.bundle.windows.nsis.template + echo "------------------" + cat ./src-tauri/tauri.bundle.windows.nsis.template + + jq --arg version "${{ inputs.new_version }}" '.version = $version' web/package.json > /tmp/package.json + mv /tmp/package.json web/package.json + + chmod +x .github/scripts/rename-workspace.sh + .github/scripts/rename-workspace.sh ./package.json nightly + chmod +x .github/scripts/rename-uninstaller.sh + .github/scripts/rename-uninstaller.sh nightly + echo "------------------------" + cat ./package.json + echo "------------------------" + + - name: Change App Name for beta version + if: inputs.beta == true + shell: bash + run: | + chmod +x .github/scripts/rename-tauri-app.sh + .github/scripts/rename-tauri-app.sh ./src-tauri/tauri.conf.json beta + cat ./src-tauri/tauri.conf.json + echo "------------------" + ctoml ./src-tauri/Cargo.toml package.name "Jan-beta" + cat ./src-tauri/Cargo.toml + echo "------------------" + chmod +x .github/scripts/rename-workspace.sh + .github/scripts/rename-workspace.sh ./package.json beta + chmod +x .github/scripts/rename-uninstaller.sh + .github/scripts/rename-uninstaller.sh beta + echo "------------------------" + cat ./package.json + echo "------------------------" + cat ./electron/scripts/uninstaller.nsh + + - name: Update app version base on tag + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && inputs.public_provider == 'github' + shell: bash + run: | + echo "Version: ${{ inputs.new_version }}" + # Update tauri.conf.json + jq --arg version "${VERSION_TAG#v}" --arg template tauri.bundle.windows.nsis.template '.version = $version | .bundle.createUpdaterArtifacts = true | .bundle.windows.nsis.template = $template' ./src-tauri/tauri.conf.json > /tmp/tauri.conf.json + mv /tmp/tauri.conf.json ./src-tauri/tauri.conf.json + + ctoml ./src-tauri/Cargo.toml package.version "${VERSION_TAG#v}" + + jan_tag="${VERSION_TAG#v}.0" + sed -i "s/jan_productname/Jan-beta/g" ./src-tauri/tauri.bundle.windows.nsis.template + sed -i "s/jan_version/${VERSION_TAG#v}/g" ./src-tauri/tauri.bundle.windows.nsis.template + sed -i "s/jan_build/$jan_tag/g" ./src-tauri/tauri.bundle.windows.nsis.template + sed -i "s/jan_mainbinaryname/jan-beta/g" ./src-tauri/tauri.bundle.windows.nsis.template + echo "------------------" + cat ./src-tauri/tauri.bundle.windows.nsis.template + + jq --arg version "${VERSION_TAG#v}" '.version = $version' web/package.json > /tmp/package.json + mv /tmp/package.json web/package.json + env: + VERSION_TAG: ${{ inputs.new_version }} + + - name: Install AzureSignTool + run: | + dotnet tool install --global --version 6.0.0 AzureSignTool + + - name: Inject Tauri Signing Public Key + shell: bash + run: | + if [ -f "src-tauri/tauri.conf.json" ]; then + echo "Injecting Tauri public key into configuration..." + # Use jq to update the pubkey field in the tauri.conf.json file + jq --arg pubkey "$TAURI_SIGNING_PUBLIC_KEY" '.plugins.updater.pubkey = $pubkey' src-tauri/tauri.conf.json > /tmp/tauri.conf.json + mv /tmp/tauri.conf.json src-tauri/tauri.conf.json + echo "Tauri configuration updated successfully" + else + echo "tauri.conf.json not found" + fi + env: + TAURI_SIGNING_PUBLIC_KEY: ${{ secrets.TAURI_SIGNING_PUBLIC_KEY }} + + - name: Build and publish app to aws s3 r2 or github artifactory + shell: bash + if: inputs.public_provider != 'github' + run: | + # check public_provider is true or not + echo "public_provider is ${{ inputs.public_provider }}" + if [ "${{ inputs.public_provider }}" == "none" ]; then + make build-tauri + else + make build-and-publish + fi + env: + AZURE_KEY_VAULT_URI: ${{ secrets.AZURE_KEY_VAULT_URI }} + AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }} + AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }} + AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }} + AZURE_CERT_NAME: ${{ secrets.AZURE_CERT_NAME }} + AWS_ACCESS_KEY_ID: ${{ secrets.DELTA_AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.DELTA_AWS_SECRET_ACCESS_KEY }} + AWS_DEFAULT_REGION: auto + AWS_EC2_METADATA_DISABLED: "true" + AWS_MAX_ATTEMPTS: "5" + POSTHOG_KEY: ${{ secrets.POSTHOG_KEY }} + POSTHOG_HOST: ${{ secrets.POSTHOG_HOST }} + # CORTEX_API_PORT: ${{ inputs.cortex_api_port }} + TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} + TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} + TAURI_SIGNING_PUBLIC_KEY: ${{ secrets.TAURI_SIGNING_PUBLIC_KEY }} + + - name: Build app and publish app to github + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && inputs.public_provider == 'github' && inputs.beta == false + run: | + make build-and-publish + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + AZURE_KEY_VAULT_URI: ${{ secrets.AZURE_KEY_VAULT_URI }} + AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }} + AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }} + AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }} + AZURE_CERT_NAME: ${{ secrets.AZURE_CERT_NAME }} + POSTHOG_KEY: ${{ secrets.POSTHOG_KEY }} + POSTHOG_HOST: ${{ secrets.POSTHOG_HOST }} + TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} + TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} + TAURI_SIGNING_PUBLIC_KEY: ${{ secrets.TAURI_SIGNING_PUBLIC_KEY }} + + - name: Build app and publish app to github + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && inputs.public_provider == 'github' && inputs.beta == true + run: | + make build-and-publish + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + AWS_ACCESS_KEY_ID: ${{ secrets.DELTA_AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.DELTA_AWS_SECRET_ACCESS_KEY }} + AWS_DEFAULT_REGION: auto + AWS_EC2_METADATA_DISABLED: "true" + AWS_MAX_ATTEMPTS: "5" + AZURE_KEY_VAULT_URI: ${{ secrets.AZURE_KEY_VAULT_URI }} + AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }} + AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }} + AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }} + AZURE_CERT_NAME: ${{ secrets.AZURE_CERT_NAME }} + POSTHOG_KEY: ${{ secrets.POSTHOG_KEY }} + POSTHOG_HOST: ${{ secrets.POSTHOG_HOST }} + TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} + TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} + TAURI_SIGNING_PUBLIC_KEY: ${{ secrets.TAURI_SIGNING_PUBLIC_KEY }} + + - name: Upload Signed Artifact + uses: actions/upload-artifact@v4 + with: + name: jan-tauri-windows-${{ inputs.new_version }} + path: | + ./src-tauri/target/release/bundle/nsis/*.exe diff --git a/Makefile b/Makefile index 1f8b4f4ba..4e3133f2d 100644 --- a/Makefile +++ b/Makefile @@ -119,6 +119,9 @@ build-and-publish: check-file-counts build: check-file-counts yarn build +build-tauri: check-file-counts + yarn build-tauri + clean: ifeq ($(OS),Windows_NT) -powershell -Command "Get-ChildItem -Path . -Include node_modules, .next, dist, build, out, .turbo, .yarn -Recurse -Directory | Remove-Item -Recurse -Force" diff --git a/package.json b/package.json index c443bf4b0..7a04fbc4d 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "build:electron:test": "yarn workspace jan build:test", "build:extensions": "rimraf ./pre-install/*.tgz || true && yarn workspace @janhq/core build && cd extensions && yarn install && yarn workspaces foreach -Apt run build:publish", "build:test": "yarn copy:assets && yarn workspace @janhq/web build && cpx \"web/out/**\" \"electron/renderer/\" && yarn workspace jan build:test", - "build": "yarn build:web && yarn build:tauri", + "build": "yarn build:web && yarn build:electron", + "build-tauri": "yarn build:web && yarn build:tauri", "build:publish": "yarn copy:assets && yarn build:web && yarn workspace jan build:publish", "dev:joi": "yarn workspace @janhq/joi install && yarn workspace @janhq/joi dev", "build:joi": "yarn workspace @janhq/joi build",