diff --git a/.github/scripts/electron-checksum.py b/.github/scripts/electron-checksum.py new file mode 100644 index 000000000..fba4ff609 --- /dev/null +++ b/.github/scripts/electron-checksum.py @@ -0,0 +1,28 @@ +import hashlib +import base64 +import sys + +def hash_file(file_path): + # Create a SHA-512 hash object + sha512 = hashlib.sha512() + + # Read and update the hash object with the content of the file + with open(file_path, 'rb') as f: + while True: + data = f.read(1024 * 1024) # Read in 1 MB chunks + if not data: + break + sha512.update(data) + + # Obtain the hash result and encode it in base64 + hash_base64 = base64.b64encode(sha512.digest()).decode('utf-8') + return hash_base64 + +if __name__ == "__main__": + if len(sys.argv) < 2: + print("Usage: python3 script.py ") + sys.exit(1) + + file_path = sys.argv[1] + hash_base64_output = hash_file(file_path) + print(hash_base64_output) diff --git a/.github/scripts/icon-beta.png b/.github/scripts/icon-beta.png new file mode 100644 index 000000000..4b715494d Binary files /dev/null and b/.github/scripts/icon-beta.png differ diff --git a/.github/scripts/icon-nightly.png b/.github/scripts/icon-nightly.png new file mode 100644 index 000000000..23f532947 Binary files /dev/null and b/.github/scripts/icon-nightly.png differ diff --git a/.github/workflows/jan-electron-build-nightly.yml b/.github/workflows/jan-electron-build-nightly.yml index 8429b82de..006b8c426 100644 --- a/.github/workflows/jan-electron-build-nightly.yml +++ b/.github/workflows/jan-electron-build-nightly.yml @@ -55,8 +55,7 @@ jobs: 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 + channel: nightly cortex_api_port: "39261" build-windows-x64: @@ -67,8 +66,7 @@ jobs: 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 + channel: nightly cortex_api_port: "39261" build-linux-x64: uses: ./.github/workflows/template-tauri-build-linux-x64.yml @@ -78,17 +76,55 @@ jobs: 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 + channel: nightly cortex_api_port: "39261" sync-temp-to-latest: - needs: [set-public-provider, build-windows-x64, build-linux-x64, build-macos] + needs: [get-update-version, set-public-provider, build-windows-x64, build-linux-x64, build-macos] runs-on: ubuntu-latest steps: + - name: Getting the repo + uses: actions/checkout@v3 + - name: Install jq + uses: dcarbone/install-jq-action@v2.0.1 + - name: create latest.json file + run: | + + VERSION=${{ needs.get-update-version.outputs.new_version }} + PUB_DATE=$(date -u +"%Y-%m-%dT%H:%M:%S.%3NZ") + LINUX_SIGNATURE="${{ needs.build-linux-x64.outputs.APPIMAGE_SIG }}" + LINUX_URL="https://delta.jan.ai/nightly/${{ needs.build-linux-x64.outputs.APPIMAGE_FILE_NAME }}" + WINDOWS_SIGNATURE="${{ needs.build-windows-x64.outputs.WIN_SIG }}" + WINDOWS_URL="https://delta.jan.ai/nightly/${{ needs.build-windows-x64.outputs.FILE_NAME }}" + DARWIN_SIGNATURE="${{ needs.build-macos.outputs.MAC_UNIVERSAL_SIG }}" + DARWIN_URL="https://delta.jan.ai/nightly/Jan-nightly_${{ needs.get-update-version.outputs.new_version }}.app.tar.gz" + + jq --arg version "$VERSION" \ + --arg pub_date "$PUB_DATE" \ + --arg linux_signature "$LINUX_SIGNATURE" \ + --arg linux_url "$LINUX_URL" \ + --arg windows_signature "$WINDOWS_SIGNATURE" \ + --arg windows_url "$WINDOWS_URL" \ + --arg darwin_arm_signature "$DARWIN_SIGNATURE" \ + --arg darwin_arm_url "$DARWIN_URL" \ + --arg darwin_amd_signature "$DARWIN_SIGNATURE" \ + --arg darwin_amd_url "$DARWIN_URL" \ + '.version = $version + | .pub_date = $pub_date + | .platforms["linux-x86_64"].signature = $linux_signature + | .platforms["linux-x86_64"].url = $linux_url + | .platforms["windows-x86_64"].signature = $windows_signature + | .platforms["windows-x86_64"].url = $windows_url + | .platforms["darwin-aarch64"].signature = $darwin_arm_signature + | .platforms["darwin-aarch64"].url = $darwin_arm_url + | .platforms["darwin-x86_64"].signature = $darwin_amd_signature + | .platforms["darwin-x86_64"].url = $darwin_amd_url' \ + src-tauri/latest.json.template > latest.json + cat latest.json - name: Sync temp to latest if: ${{ needs.set-public-provider.outputs.public_provider == 'aws-s3' }} run: | + aws s3 cp ./latest.json s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/temp-nightly/latest.json 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 }} diff --git a/.github/workflows/jan-tauri-build-beta.yml b/.github/workflows/jan-tauri-build-beta.yml index bbc21f7a1..1f4239381 100644 --- a/.github/workflows/jan-tauri-build-beta.yml +++ b/.github/workflows/jan-tauri-build-beta.yml @@ -17,8 +17,7 @@ jobs: ref: ${{ github.ref }} public_provider: github new_version: ${{ needs.get-update-version.outputs.new_version }} - beta: true - nightly: false + channel: beta cortex_api_port: "39271" build-windows-x64: @@ -29,8 +28,7 @@ jobs: ref: ${{ github.ref }} public_provider: github new_version: ${{ needs.get-update-version.outputs.new_version }} - beta: true - nightly: false + channel: beta cortex_api_port: "39271" build-linux-x64: @@ -41,21 +39,56 @@ jobs: ref: ${{ github.ref }} public_provider: github new_version: ${{ needs.get-update-version.outputs.new_version }} - beta: true - nightly: false + channel: beta cortex_api_port: "39271" sync-temp-to-latest: - needs: [build-macos, build-windows-x64, build-linux-x64] + needs: [get-update-version, 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: create latest.json file + run: | + + VERSION=${{ needs.get-update-version.outputs.new_version }} + PUB_DATE=$(date -u +"%Y-%m-%dT%H:%M:%S.%3NZ") + LINUX_SIGNATURE="${{ needs.build-linux-x64.outputs.APPIMAGE_SIG }}" + LINUX_URL="https://delta.jan.ai/beta/${{ needs.build-linux-x64.outputs.APPIMAGE_FILE_NAME }}" + WINDOWS_SIGNATURE="${{ needs.build-windows-x64.outputs.WIN_SIG }}" + WINDOWS_URL="https://delta.jan.ai/beta/${{ needs.build-windows-x64.outputs.FILE_NAME }}" + DARWIN_SIGNATURE="${{ needs.build-macos.outputs.MAC_UNIVERSAL_SIG }}" + DARWIN_URL="https://delta.jan.ai/beta/Jan-beta_${{ needs.get-update-version.outputs.new_version }}.app.tar.gz" + + jq --arg version "$VERSION" \ + --arg pub_date "$PUB_DATE" \ + --arg linux_signature "$LINUX_SIGNATURE" \ + --arg linux_url "$LINUX_URL" \ + --arg windows_signature "$WINDOWS_SIGNATURE" \ + --arg windows_url "$WINDOWS_URL" \ + --arg darwin_arm_signature "$DARWIN_SIGNATURE" \ + --arg darwin_arm_url "$DARWIN_URL" \ + --arg darwin_amd_signature "$DARWIN_SIGNATURE" \ + --arg darwin_amd_url "$DARWIN_URL" \ + '.version = $version + | .pub_date = $pub_date + | .platforms["linux-x86_64"].signature = $linux_signature + | .platforms["linux-x86_64"].url = $linux_url + | .platforms["windows-x86_64"].signature = $windows_signature + | .platforms["windows-x86_64"].url = $windows_url + | .platforms["darwin-aarch64"].signature = $darwin_arm_signature + | .platforms["darwin-aarch64"].url = $darwin_arm_url + | .platforms["darwin-x86_64"].signature = $darwin_amd_signature + | .platforms["darwin-x86_64"].url = $darwin_amd_url' \ + src-tauri/latest.json.template > latest.json + cat latest.json - name: Sync temp to latest run: | # sync temp-beta to beta by copy files that are different or new + aws s3 cp ./latest.json s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/temp-beta/latest.json 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 }} @@ -78,9 +111,9 @@ jobs: 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 + - Windows: https://delta.jan.ai/beta/Jan-beta_{{ VERSION }}_x64-setup.exe + - macOS Universal: https://delta.jan.ai/beta/Jan-beta_{{ VERSION }}_universal.dmg + - Linux Deb: https://delta.jan.ai/beta/Jan-beta_{{ VERSION }}_amd64.deb + - Linux AppImage: https://delta.jan.ai/beta/Jan-beta_{{ VERSION }}_amd64.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 index 09946c53f..ba21e89f1 100644 --- a/.github/workflows/jan-tauri-build-nightly.yml +++ b/.github/workflows/jan-tauri-build-nightly.yml @@ -55,8 +55,7 @@ jobs: 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 + channel: nightly cortex_api_port: "39261" build-windows-x64: @@ -67,8 +66,7 @@ jobs: 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 + channel: nightly cortex_api_port: "39261" build-linux-x64: uses: ./.github/workflows/template-tauri-build-linux-x64.yml @@ -78,17 +76,55 @@ jobs: 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 + channel: nightly cortex_api_port: "39261" sync-temp-to-latest: - needs: [set-public-provider, build-windows-x64, build-linux-x64, build-macos] + needs: [get-update-version, set-public-provider, build-windows-x64, build-linux-x64, build-macos] runs-on: ubuntu-latest steps: + - name: Getting the repo + uses: actions/checkout@v3 + - name: Install jq + uses: dcarbone/install-jq-action@v2.0.1 + - name: create latest.json file + run: | + + VERSION=${{ needs.get-update-version.outputs.new_version }} + PUB_DATE=$(date -u +"%Y-%m-%dT%H:%M:%S.%3NZ") + LINUX_SIGNATURE="${{ needs.build-linux-x64.outputs.APPIMAGE_SIG }}" + LINUX_URL="https://delta.jan.ai/nightly/${{ needs.build-linux-x64.outputs.APPIMAGE_FILE_NAME }}" + WINDOWS_SIGNATURE="${{ needs.build-windows-x64.outputs.WIN_SIG }}" + WINDOWS_URL="https://delta.jan.ai/nightly/${{ needs.build-windows-x64.outputs.FILE_NAME }}" + DARWIN_SIGNATURE="${{ needs.build-macos.outputs.MAC_UNIVERSAL_SIG }}" + DARWIN_URL="https://delta.jan.ai/nightly/Jan-nightly_${{ needs.get-update-version.outputs.new_version }}.app.tar.gz" + + jq --arg version "$VERSION" \ + --arg pub_date "$PUB_DATE" \ + --arg linux_signature "$LINUX_SIGNATURE" \ + --arg linux_url "$LINUX_URL" \ + --arg windows_signature "$WINDOWS_SIGNATURE" \ + --arg windows_url "$WINDOWS_URL" \ + --arg darwin_arm_signature "$DARWIN_SIGNATURE" \ + --arg darwin_arm_url "$DARWIN_URL" \ + --arg darwin_amd_signature "$DARWIN_SIGNATURE" \ + --arg darwin_amd_url "$DARWIN_URL" \ + '.version = $version + | .pub_date = $pub_date + | .platforms["linux-x86_64"].signature = $linux_signature + | .platforms["linux-x86_64"].url = $linux_url + | .platforms["windows-x86_64"].signature = $windows_signature + | .platforms["windows-x86_64"].url = $windows_url + | .platforms["darwin-aarch64"].signature = $darwin_arm_signature + | .platforms["darwin-aarch64"].url = $darwin_arm_url + | .platforms["darwin-x86_64"].signature = $darwin_amd_signature + | .platforms["darwin-x86_64"].url = $darwin_amd_url' \ + src-tauri/latest.json.template > latest.json + cat latest.json - name: Sync temp to latest if: ${{ needs.set-public-provider.outputs.public_provider == 'aws-s3' }} run: | + aws s3 cp ./latest.json s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/temp-nightly/latest.json 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 }} diff --git a/.github/workflows/jan-tauri-build.yml b/.github/workflows/jan-tauri-build.yml index bc5460ffe..50236776b 100644 --- a/.github/workflows/jan-tauri-build.yml +++ b/.github/workflows/jan-tauri-build.yml @@ -40,8 +40,7 @@ jobs: with: ref: ${{ github.ref }} public_provider: github - beta: false - nightly: false + channel: stable new_version: ${{ needs.get-update-version.outputs.new_version }} build-windows-x64: @@ -51,8 +50,7 @@ jobs: with: ref: ${{ github.ref }} public_provider: github - beta: false - nightly: false + channel: stable new_version: ${{ needs.get-update-version.outputs.new_version }} build-linux-x64: @@ -62,10 +60,63 @@ jobs: with: ref: ${{ github.ref }} public_provider: github - beta: false - nightly: false + channel: stable new_version: ${{ needs.get-update-version.outputs.new_version }} + sync-temp-to-latest: + needs: [get-update-version, 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: create latest.json file + run: | + + VERSION=${{ needs.get-update-version.outputs.new_version }} + PUB_DATE=$(date -u +"%Y-%m-%dT%H:%M:%S.%3NZ") + LINUX_SIGNATURE="${{ needs.build-linux-x64.outputs.APPIMAGE_SIG }}" + LINUX_URL="https://github.com/menloresearch/jan/releases/download/v${{ needs.get-update-version.outputs.new_version }}/${{ needs.build-linux-x64.outputs.APPIMAGE_FILE_NAME }}" + WINDOWS_SIGNATURE="${{ needs.build-windows-x64.outputs.WIN_SIG }}" + WINDOWS_URL="https://github.com/menloresearch/jan/releases/download/v${{ needs.get-update-version.outputs.new_version }}/${{ needs.build-windows-x64.outputs.FILE_NAME }}" + DARWIN_SIGNATURE="${{ needs.build-macos.outputs.MAC_UNIVERSAL_SIG }}" + DARWIN_URL="https://github.com/menloresearch/jan/releases/download/v${{ needs.get-update-version.outputs.new_version }}/${{ needs.build-macos.outputs.TAR_NAME }}" + + jq --arg version "$VERSION" \ + --arg pub_date "$PUB_DATE" \ + --arg linux_signature "$LINUX_SIGNATURE" \ + --arg linux_url "$LINUX_URL" \ + --arg windows_signature "$WINDOWS_SIGNATURE" \ + --arg windows_url "$WINDOWS_URL" \ + --arg darwin_arm_signature "$DARWIN_SIGNATURE" \ + --arg darwin_arm_url "$DARWIN_URL" \ + --arg darwin_amd_signature "$DARWIN_SIGNATURE" \ + --arg darwin_amd_url "$DARWIN_URL" \ + '.version = $version + | .pub_date = $pub_date + | .platforms["linux-x86_64"].signature = $linux_signature + | .platforms["linux-x86_64"].url = $linux_url + | .platforms["windows-x86_64"].signature = $windows_signature + | .platforms["windows-x86_64"].url = $windows_url + | .platforms["darwin-aarch64"].signature = $darwin_arm_signature + | .platforms["darwin-aarch64"].url = $darwin_arm_url + | .platforms["darwin-x86_64"].signature = $darwin_amd_signature + | .platforms["darwin-x86_64"].url = $darwin_amd_url' \ + src-tauri/latest.json.template > latest.json + cat latest.json + - name: Sync temp to latest + run: | + # sync temp-beta to beta by copy files that are different or new + aws s3 cp ./latest.json s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/temp-beta/latest.json + 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" + update_release_draft: needs: [build-macos, build-windows-x64, build-linux-x64] permissions: diff --git a/.github/workflows/template-noti-discord-and-update-url-readme.yml b/.github/workflows/template-noti-discord-and-update-url-readme.yml index 282e0aa76..eaaee7e50 100644 --- a/.github/workflows/template-noti-discord-and-update-url-readme.yml +++ b/.github/workflows/template-noti-discord-and-update-url-readme.yml @@ -47,10 +47,10 @@ jobs: with: args: | Jan App ${{ inputs.build_reason }} build artifact version {{ VERSION }}: - - Windows: https://delta.jan.ai/nightly/jan-nightly-win-x64-{{ VERSION }}.exe - - macOS Universal: https://delta.jan.ai/nightly/jan-nightly-mac-universal-{{ VERSION }}.dmg - - Linux Deb: https://delta.jan.ai/nightly/jan-nightly-linux-amd64-{{ VERSION }}.deb - - Linux AppImage: https://delta.jan.ai/nightly/jan-nightly-linux-x86_64-{{ VERSION }}.AppImage + - Windows: https://delta.jan.ai/nightly/Jan-nightly_{{ VERSION }}_x64-setup.exe + - macOS Universal: https://delta.jan.ai/nightly/Jan-nightly_{{ VERSION }}_universal.dmg + - Linux Deb: https://delta.jan.ai/nightly/Jan-nightly_{{ VERSION }}_amd64.deb + - Linux AppImage: https://delta.jan.ai/nightly/Jan-nightly_{{ VERSION }}_amd64.AppImage - Github action run: https://github.com/menloresearch/jan/actions/runs/{{ GITHUB_RUN_ID }} env: DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} diff --git a/.github/workflows/template-tauri-build-linux-x64.yml b/.github/workflows/template-tauri-build-linux-x64.yml index 27ac6f6ff..309401ad9 100644 --- a/.github/workflows/template-tauri-build-linux-x64.yml +++ b/.github/workflows/template-tauri-build-linux-x64.yml @@ -15,22 +15,19 @@ on: 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 + default: "" + upload_url: + required: false + type: string + default: '' + channel: + required: true + type: string + default: 'nightly' + description: 'The channel to use for this job' secrets: DELTA_AWS_S3_BUCKET_NAME: required: false @@ -44,10 +41,20 @@ on: required: false TAURI_SIGNING_PUBLIC_KEY: required: false - + outputs: + DEB_SIG: + value: ${{ jobs.build-linux-x64.outputs.DEB_SIG }} + APPIMAGE_SIG: + value: ${{ jobs.build-linux-x64.outputs.APPIMAGE_SIG }} + APPIMAGE_FILE_NAME: + value: ${{ jobs.build-linux-x64.outputs.APPIMAGE_FILE_NAME }} jobs: build-linux-x64: runs-on: ubuntu-22.04 + outputs: + DEB_SIG: ${{ steps.packageinfo.outputs.DEB_SIG }} + APPIMAGE_SIG: ${{ steps.packageinfo.outputs.APPIMAGE_SIG }} + APPIMAGE_FILE_NAME: ${{ steps.packageinfo.outputs.APPIMAGE_FILE_NAME }} environment: production permissions: contents: write @@ -71,30 +78,11 @@ jobs: 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: Replace Icons for Beta Build + if: inputs.channel != 'stable' + shell: bash + run: | + cp .github/scripts/icon-${{ inputs.channel }}.png src-tauri/icons/icon.png - name: Installing node uses: actions/setup-node@v1 @@ -114,76 +102,41 @@ jobs: 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 + 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-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 + # Change app name for beta and nightly builds + if [ "${{ inputs.channel }}" != "stable" ]; then + jq '.plugins.updater.endpoints = ["https://delta.jan.ai/${{ inputs.channel }}/latest.json"]' ./src-tauri/tauri.conf.json > /tmp/tauri.conf.json + mv /tmp/tauri.conf.json ./src-tauri/tauri.conf.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 }} + chmod +x .github/scripts/rename-tauri-app.sh + .github/scripts/rename-tauri-app.sh ./src-tauri/tauri.conf.json ${{ inputs.channel }} - - 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" + cat ./src-tauri/tauri.conf.json + + # Update Cargo.toml + ctoml ./src-tauri/Cargo.toml package.name "Jan-${{ inputs.channel }}" + echo "------------------" + cat ./src-tauri/Cargo.toml + + chmod +x .github/scripts/rename-workspace.sh + .github/scripts/rename-workspace.sh ./package.json ${{ inputs.channel }} + cat ./package.json fi - env: - TAURI_SIGNING_PUBLIC_KEY: ${{ secrets.TAURI_SIGNING_PUBLIC_KEY }} - - name: Build app run: | make build-tauri 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 }} @@ -191,19 +144,15 @@ jobs: TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} TAURI_SIGNING_PUBLIC_KEY: ${{ secrets.TAURI_SIGNING_PUBLIC_KEY }} + # Publish app + + ## Artifacts, for dev and test - name: Upload Artifact 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 - if: inputs.public_provider != 'github' - uses: actions/upload-artifact@v4 - with: - name: jan-linux-amd64-${{ inputs.new_version }}.deb.sig - path: ./src-tauri/target/release/bundle/deb/*.deb.sig - name: Upload Artifact if: inputs.public_provider != 'github' @@ -212,9 +161,106 @@ jobs: name: jan-linux-amd64-${{ inputs.new_version }}-AppImage path: ./src-tauri/target/release/bundle/appimage/*.AppImage - - name: Upload Artifact - if: inputs.public_provider != 'github' - uses: actions/upload-artifact@v4 + ## create zip file and latest-linux.yml for linux electron auto updater + - name: Create zip file and latest-linux.yml for linux electron auto updater + id: packageinfo + run: | + cd ./src-tauri/target/release/bundle + + if [ "${{ inputs.channel }}" != "stable" ]; then + DEB_FILE_NAME=Jan-${{ inputs.channel }}_${{ inputs.new_version }}_amd64.deb + APPIMAGE_FILE_NAME=Jan-${{ inputs.channel }}_${{ inputs.new_version }}_amd64.AppImage + DEB_SIG=$(cat deb/Jan-${{ inputs.channel }}_${{ inputs.new_version }}_amd64.deb.sig) + APPIMAGE_SIG=$(cat appimage/Jan-${{ inputs.channel }}_${{ inputs.new_version }}_amd64.AppImage.sig) + else + DEB_FILE_NAME=Jan_${{ inputs.new_version }}_amd64.deb + APPIMAGE_FILE_NAME=Jan_${{ inputs.new_version }}_amd64.AppImage + DEB_SIG=$(cat deb/Jan_${{ inputs.new_version }}_amd64.deb.sig) + APPIMAGE_SIG=$(cat appimage/Jan_${{ inputs.new_version }}_amd64.AppImage.sig) + fi + + DEB_FILE_SIZE=$(stat -c%s deb/$DEB_FILE_NAME) + APPIMAGE_FILE_SIZE=$(stat -c%s appimage/$APPIMAGE_FILE_NAME) + echo "deb file size: $DEB_FILE_SIZE" + echo "appimage file size: $APPIMAGE_FILE_SIZE" + + DEB_SH512_CHECKSUM=$(python3 ../../../../.github/scripts/electron-checksum.py deb/$DEB_FILE_NAME) + APPIMAGE_SH512_CHECKSUM=$(python3 ../../../../.github/scripts/electron-checksum.py appimage/$APPIMAGE_FILE_NAME) + echo "deb sh512 checksum: $DEB_SH512_CHECKSUM" + echo "appimage sh512 checksum: $APPIMAGE_SH512_CHECKSUM" + + CURRENT_TIME=$(date -u +"%Y-%m-%dT%H:%M:%S.%3NZ") + echo "releaseDate: $CURRENT_TIME" + + # Create latest-linux.yml file + echo "version: ${{ inputs.new_version }}" > latest-linux.yml + echo "files:" >> latest-linux.yml + echo " - url: $DEB_FILE_NAME" >> latest-linux.yml + echo " sha512: $DEB_SH512_CHECKSUM" >> latest-linux.yml + echo " size: $DEB_FILE_SIZE" >> latest-linux.yml + echo " - url: $APPIMAGE_FILE_NAME" >> latest-linux.yml + echo " sha512: $APPIMAGE_SH512_CHECKSUM" >> latest-linux.yml + echo " size: $APPIMAGE_FILE_SIZE" >> latest-linux.yml + echo "path: $APPIMAGE_FILE_NAME" >> latest-linux.yml + echo "sha512: $APPIMAGE_SH512_CHECKSUM" >> latest-linux.yml + echo "releaseDate: $CURRENT_TIME" >> latest-linux.yml + + cat latest-linux.yml + cp latest-linux.yml beta-linux.yml + + echo "DEB_SIG=$DEB_SIG" >> $GITHUB_OUTPUT + echo "APPIMAGE_SIG=$APPIMAGE_SIG" >> $GITHUB_OUTPUT + echo "DEB_FILE_NAME=$DEB_FILE_NAME" >> $GITHUB_OUTPUT + echo "APPIMAGE_FILE_NAME=$APPIMAGE_FILE_NAME" >> $GITHUB_OUTPUT + + ## Upload to s3 for nightly and beta + - name: upload to aws s3 if public provider is aws + if: inputs.public_provider == 'aws-s3' || inputs.channel == 'beta' + run: | + cd ./src-tauri/target/release/bundle + + # Upload for electron updater + aws s3 cp ./latest-linux.yml s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/temp-${{ inputs.channel }}/latest-linux.yml + aws s3 cp ./beta-linux.yml s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/temp-${{ inputs.channel }}/beta-linux.yml + + # Upload for tauri updater + aws s3 cp ./appimage/Jan-${{ inputs.channel }}_${{ inputs.new_version }}_amd64.AppImage s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/temp-${{ inputs.channel }}/Jan-${{ inputs.channel }}_${{ inputs.new_version }}_amd64.AppImage + aws s3 cp ./deb/Jan-${{ inputs.channel }}_${{ inputs.new_version }}_amd64.deb s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/temp-${{ inputs.channel }}/Jan-${{ inputs.channel }}_${{ inputs.new_version }}_amd64.deb + 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" + + ## Upload to github release for stable release + - name: Upload release assert if public provider is github + if: inputs.public_provider == 'github' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: actions/upload-release-asset@v1.0.1 with: - name: jan-linux-amd64-${{ inputs.new_version }}.AppImage.sig - path: ./src-tauri/target/release/bundle/appimage/*.AppImage.sig \ No newline at end of file + upload_url: ${{ inputs.upload_url }} + asset_path: ./src-tauri/target/release/bundle/latest-linux.yml + asset_name: latest-linux.yml + asset_content_type: text/yaml + - name: Upload release assert if public provider is github + if: inputs.public_provider == 'github' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: actions/upload-release-asset@v1.0.1 + with: + upload_url: ${{ inputs.upload_url }} + asset_path: ./src-tauri/target/release/bundle/appimage/${{ steps.packageinfo.outputs.APPIMAGE_FILE_NAME }} + asset_name: ${{ steps.packageinfo.outputs.APPIMAGE_FILE_NAME }} + asset_content_type: application/octet-stream + + - name: Upload release assert if public provider is github + if: inputs.public_provider == 'github' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: actions/upload-release-asset@v1.0.1 + with: + upload_url: ${{ inputs.upload_url }} + asset_path: ./src-tauri/target/release/bundle/deb/${{ steps.packageinfo.outputs.DEB_FILE_NAME }} + asset_name: ${{ steps.packageinfo.outputs.DEB_FILE_NAME }} + asset_content_type: application/octet-stream diff --git a/.github/workflows/template-tauri-build-macos.yml b/.github/workflows/template-tauri-build-macos.yml index 38434b7d8..3a8a88752 100644 --- a/.github/workflows/template-tauri-build-macos.yml +++ b/.github/workflows/template-tauri-build-macos.yml @@ -15,22 +15,19 @@ on: 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 + default: "" + upload_url: + required: false + type: string + default: '' + channel: + required: true + type: string + default: 'nightly' + description: 'The channel to use for this job' secrets: DELTA_AWS_S3_BUCKET_NAME: required: false @@ -54,10 +51,18 @@ on: required: false TAURI_SIGNING_PUBLIC_KEY: required: false + outputs: + MAC_UNIVERSAL_SIG: + value: ${{ jobs.build-macos.outputs.MAC_UNIVERSAL_SIG }} + TAR_NAME: + value: ${{ jobs.build-macos.outputs.TAR_NAME }} jobs: build-macos: runs-on: macos-latest + outputs: + MAC_UNIVERSAL_SIG: ${{ steps.metadata.outputs.MAC_UNIVERSAL_SIG }} + TAR_NAME: ${{ steps.metadata.outputs.TAR_NAME }} environment: production permissions: contents: write @@ -66,30 +71,11 @@ jobs: 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: Replace Icons for Beta Build + if: inputs.channel != 'stable' + shell: bash + run: | + cp .github/scripts/icon-${{ inputs.channel }}.png src-tauri/icons/icon.png - name: Installing node uses: actions/setup-node@v1 @@ -104,56 +90,36 @@ jobs: 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" + ctoml ./src-tauri/Cargo.toml package.version "${{ inputs.new_version }}" 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 }} + # Change app name for beta and nightly builds + if [ "${{ inputs.channel }}" != "stable" ]; then + jq '.plugins.updater.endpoints = ["https://delta.jan.ai/${{ inputs.channel }}/latest.json"]' ./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 ${{ inputs.channel }} + + cat ./src-tauri/tauri.conf.json + + # Update Cargo.toml + ctoml ./src-tauri/Cargo.toml package.name "Jan-${{ inputs.channel }}" + echo "------------------" + cat ./src-tauri/Cargo.toml + + chmod +x .github/scripts/rename-workspace.sh + .github/scripts/rename-workspace.sh ./package.json ${{ inputs.channel }} + cat ./package.json + fi - name: Get key for notarize run: base64 -d <<< "$NOTARIZE_P8_BASE64" > /tmp/notary-key.p8 shell: bash @@ -165,23 +131,10 @@ jobs: 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 app run: | + rustup target add x86_64-apple-darwin make build-tauri env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -198,26 +151,124 @@ jobs: TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} TAURI_SIGNING_PUBLIC_KEY: ${{ secrets.TAURI_SIGNING_PUBLIC_KEY }} - - name: Upload Artifact - if: inputs.public_provider != 'github' - uses: actions/upload-artifact@v4 - with: - name: jan-mac-universal-${{ inputs.new_version }}.dmg - path: | - ./src-tauri/target/release/bundle/dmg/*.dmg + # Publish app + ## Artifacts, for dev and test - name: Upload Artifact if: inputs.public_provider != 'github' uses: actions/upload-artifact@v4 with: - name: jan-mac-universal-${{ inputs.new_version }}.app.tar.gz + name: jan-${{ inputs.channel }}-mac-universal-${{ inputs.new_version }}.dmg path: | - ./src-tauri/target/release/bundle/macos/Jan-nightly.app.tar.gz + ./src-tauri/target/universal-apple-darwin/release/bundle/dmg/*.dmg - - name: Upload Artifact - if: inputs.public_provider != 'github' - uses: actions/upload-artifact@v4 + + ## create zip file and latest-mac.yml for mac electron auto updater + - name: create zip file and latest-mac.yml for mac electron auto updater + run: | + cd ./src-tauri/target/universal-apple-darwin/release/bundle/macos + if [ "${{ inputs.channel }}" != "stable" ]; then + zip -r jan-${{ inputs.channel }}-mac-universal-${{ inputs.new_version }}.zip Jan-${{ inputs.channel }}.app + FILE_NAME=jan-${{ inputs.channel }}-mac-universal-${{ inputs.new_version }}.zip + DMG_NAME=Jan--${{ inputs.channel }}_${{ inputs.new_version }}_universal.dmg + MAC_UNIVERSAL_SIG=$(cat Jan-${{ inputs.channel }}.app.tar.gz.sig) + TAR_NAME=Jan-${{ inputs.channel }}.app.tar.gz + else + zip -r jan-mac-universal-${{ inputs.new_version }}.zip Jan.app + FILE_NAME=jan-mac-universal-${{ inputs.new_version }}.zip + MAC_UNIVERSAL_SIG=$(cat Jan.app.tar.gz.sig) + DMG_NAME=Jan--${{ inputs.channel }}_${{ inputs.new_version }}_universal.dmg + TAR_NAME=Jan.app.tar.gz + fi + + FILE_SIZE=$(stat -f%z $FILE_NAME) + echo "size: $FILE_SIZE" + + SH512_CHECKSUM=$(python3 ../../../../../../.github/scripts/electron-checksum.py $FILE_NAME) + echo "sha512: $SH512_CHECKSUM" + CURRENT_TIME=$(date -u +"%Y-%m-%dT%H:%M:%S.%3NZ") + echo "releaseDate: $CURRENT_TIME" + + # Create latest-mac.yml file + echo "version: ${{ inputs.new_version }}" > latest-mac.yml + echo "files:" >> latest-mac.yml + echo " - url: $FILE_NAME" >> latest-mac.yml + echo " sha512: $SH512_CHECKSUM" >> latest-mac.yml + echo " size: $FILE_NAME" >> latest-mac.yml + echo "path: $FILE_NAME" >> latest-mac.yml + echo "sha512: $SH512_CHECKSUM" >> latest-mac.yml + echo "releaseDate: $CURRENT_TIME" >> latest-mac.yml + + cat latest-mac.yml + cp latest-mac.yml beta-mac.yml + + echo "::set-output name=MAC_UNIVERSAL_SIG::$MAC_UNIVERSAL_SIG" + echo "::set-output name=FILE_NAME::$FILE_NAME" + echo "::set-output name=DMG_NAME::$DMG_NAME" + echo "::set-output name=TAR_NAME::$TAR_NAME" + id: metadata + + ## Upload to s3 for nightly and beta + - name: upload to aws s3 if public provider is aws + if: inputs.public_provider == 'aws-s3' || inputs.channel == 'beta' + run: | + cd ./src-tauri/target/universal-apple-darwin/release/bundle + + # Upload for electron updater + aws s3 cp ./macos/latest-mac.yml s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/temp-${{ inputs.channel }}/latest-mac.yml + aws s3 cp ./macos/beta-mac.yml s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/temp-${{ inputs.channel }}/beta-mac.yml + aws s3 cp ./macos/jan-${{ inputs.channel }}-mac-universal-${{ inputs.new_version }}.zip s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/temp-${{ inputs.channel }}/jan-${{ inputs.channel }}-mac-universal-${{ inputs.new_version }}.zip + + # Upload for tauri updater + aws s3 cp ./dmg/Jan-${{ inputs.channel }}_${{ inputs.new_version }}_universal.dmg s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/temp-${{ inputs.channel }}/Jan-${{ inputs.channel }}_${{ inputs.new_version }}_universal.dmg + aws s3 cp ./macos/Jan-${{ inputs.channel }}.app.tar.gz s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/temp-${{ inputs.channel }}//Jan-${{ inputs.channel }}_${{ inputs.new_version }}.app.tar.gz + 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" + + ## Upload to github release for stable release + - name: Upload release assert if public provider is github + if: inputs.public_provider == 'github' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: actions/upload-release-asset@v1.0.1 with: - name: jan-mac-universal-${{ inputs.new_version }}.app.tar.gz.sig - path: | - ./src-tauri/target/release/bundle/macos/Jan-nightly.app.tar.gz.sig \ No newline at end of file + upload_url: ${{ inputs.upload_url }} + asset_path: ./src-tauri/target/universal-apple-darwin/release/macos/latest-mac.yml + asset_name: latest-mac.yml + asset_content_type: text/yaml + + - name: Upload release assert if public provider is github + if: inputs.public_provider == 'github' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: actions/upload-release-asset@v1.0.1 + with: + upload_url: ${{ inputs.upload_url }} + asset_path: ./src-tauri/target/universal-apple-darwin/release/macos/${{ steps.metadata.outputs.FILE_NAME }} + asset_name: ${{ steps.metadata.outputs.FILE_NAME }} + asset_content_type: application/gzip + + - name: Upload release assert if public provider is github + if: inputs.public_provider == 'github' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: actions/upload-release-asset@v1.0.1 + with: + upload_url: ${{ inputs.upload_url }} + asset_path: ./src-tauri/target/universal-apple-darwin/release/dmg/${{ steps.metadata.outputs.DMG_NAME }} + asset_name: ${{ steps.metadata.outputs.DMG_NAME }} + asset_content_type: application/octet-stream + + - name: Upload release assert if public provider is github + if: inputs.public_provider == 'github' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: actions/upload-release-asset@v1.0.1 + with: + upload_url: ${{ inputs.upload_url }} + asset_path: ./src-tauri/target/universal-apple-darwin/release/macos/${{ steps.metadata.outputs.TAR_NAME }} + asset_name: ${{ steps.metadata.outputs.TAR_NAME }} + asset_content_type: application/gzip \ 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 index b6e6a8ee2..47dd4ecd2 100644 --- a/.github/workflows/template-tauri-build-windows-x64.yml +++ b/.github/workflows/template-tauri-build-windows-x64.yml @@ -14,23 +14,20 @@ on: 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 + default: '' cortex_api_port: required: false type: string - default: null + default: "" + upload_url: + required: false + type: string + default: '' + channel: + required: true + type: string + default: 'nightly' + description: 'The channel to use for this job' secrets: DELTA_AWS_S3_BUCKET_NAME: required: false @@ -54,10 +51,18 @@ on: required: false TAURI_SIGNING_PUBLIC_KEY: required: false + outputs: + WIN_SIG: + value: ${{ jobs.build-windows-x64.outputs.WIN_SIG }} + FILE_NAME: + value: ${{ jobs.build-windows-x64.outputs.FILE_NAME }} jobs: build-windows-x64: runs-on: windows-latest + outputs: + WIN_SIG: ${{ steps.metadata.outputs.WIN_SIG }} + FILE_NAME: ${{ steps.metadata.outputs.FILE_NAME }} permissions: contents: write steps: @@ -66,29 +71,11 @@ jobs: 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: Replace Icons for Beta Build + if: inputs.channel != 'stable' + shell: bash + run: | + cp .github/scripts/icon-${{ inputs.channel }}.png src-tauri/icons/icon.png - name: Installing node uses: actions/setup-node@v1 @@ -109,123 +96,76 @@ jobs: 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 + 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 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" + ctoml ./src-tauri/Cargo.toml package.version "${{ inputs.new_version }}" cat ./src-tauri/Cargo.toml + + generate_build_version() { + ### Examble + ### input 0.5.6 output will be 0.5.6 and 0.5.6.0 + ### input 0.5.6-rc2-beta output will be 0.5.6 and 0.5.6.2 + ### input 0.5.6-1213 output will be 0.5.6 and and 0.5.6.1213 + local new_version="$1" + local base_version + local t_value + + # Check if it has a "-" + if [[ "$new_version" == *-* ]]; then + base_version="${new_version%%-*}" # part before - + suffix="${new_version#*-}" # part after - + + # Check if it is rcX-beta + if [[ "$suffix" =~ ^rc([0-9]+)-beta$ ]]; then + t_value="${BASH_REMATCH[1]}" + else + t_value="$suffix" + fi + else + base_version="$new_version" + t_value="0" + fi + + # Export two values + new_base_version="$base_version" + new_build_version="${base_version}.${t_value}" + } + generate_build_version ${{ inputs.new_version }} + sed -i "s/jan_version/$new_base_version/g" ./src-tauri/tauri.bundle.windows.nsis.template + sed -i "s/jan_build/$new_build_version/g" ./src-tauri/tauri.bundle.windows.nsis.template 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 + cat ./src-tauri/tauri.bundle.windows.nsis.template - - 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 + # Change app name for beta and nightly builds + if [ "${{ inputs.channel }}" != "stable" ]; then + jq '.plugins.updater.endpoints = ["https://delta.jan.ai/${{ inputs.channel }}/latest.json"]' ./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}" + chmod +x .github/scripts/rename-tauri-app.sh + .github/scripts/rename-tauri-app.sh ./src-tauri/tauri.conf.json ${{ inputs.channel }} - 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 + cat ./src-tauri/tauri.conf.json - 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 }} + # Update Cargo.toml + ctoml ./src-tauri/Cargo.toml package.name "Jan-${{ inputs.channel }}" + echo "------------------" + cat ./src-tauri/Cargo.toml + + chmod +x .github/scripts/rename-workspace.sh + .github/scripts/rename-workspace.sh ./package.json ${{ inputs.channel }} + cat ./package.json + + sed -i "s/jan_productname/Jan-${{ inputs.channel }}/g" ./src-tauri/tauri.bundle.windows.nsis.template + sed -i "s/jan_mainbinaryname/jan-${{ inputs.channel }}/g" ./src-tauri/tauri.bundle.windows.nsis.template + fi - 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 app shell: bash if: inputs.public_provider != 'github' @@ -255,10 +195,83 @@ jobs: name: jan-windows-${{ inputs.new_version }} path: | ./src-tauri/target/release/bundle/nsis/*.exe - - - name: Upload Artifact - uses: actions/upload-artifact@v4 + + ## create zip file and latest.yml for windows electron auto updater + - name: create zip file and latest.yml for windows electron auto updater + shell: bash + run: | + cd ./src-tauri/target/release/bundle/nsis + if [ "${{ inputs.channel }}" != "stable" ]; then + FILE_NAME=Jan-${{ inputs.channel }}_${{ inputs.new_version }}_x64-setup.exe + WIN_SIG=$(cat Jan-${{ inputs.channel }}_${{ inputs.new_version }}_x64-setup.exe.sig) + else + FILE_NAME=Jan_${{ inputs.new_version }}_x64-setup.exe + WIN_SIG=$(cat Jan_${{ inputs.new_version }}_x64-setup.exe.sig) + fi + + FILE_SIZE=$(stat -c %s $FILE_NAME) + echo "size: $FILE_SIZE" + + SH512_CHECKSUM=$(python3 ../../../../../.github/scripts/electron-checksum.py $FILE_NAME) + echo "sha512: $SH512_CHECKSUM" + CURRENT_TIME=$(date -u +"%Y-%m-%dT%H:%M:%S.%3NZ") + echo "releaseDate: $CURRENT_TIME" + + # Create latest.yml file + echo "version: ${{ inputs.new_version }}" > latest.yml + echo "files:" >> latest.yml + echo " - url: $FILE_NAME" >> latest.yml + echo " sha512: $SH512_CHECKSUM" >> latest.yml + echo " size: $FILE_NAME" >> latest.yml + echo "path: $FILE_NAME" >> latest.yml + echo "sha512: $SH512_CHECKSUM" >> latest.yml + echo "releaseDate: $CURRENT_TIME" >> latest.yml + + cat latest.yml + cp latest.yml beta.yml + + echo "::set-output name=WIN_SIG::$WIN_SIG" + echo "::set-output name=FILE_NAME::$FILE_NAME" + id: metadata + + ## Upload to s3 for nightly and beta + - name: upload to aws s3 if public provider is aws + shell: bash + if: inputs.public_provider == 'aws-s3' || inputs.channel == 'beta' + run: | + cd ./src-tauri/target/release/bundle/nsis + + # Upload for electron updater + aws s3 cp ./latest.yml s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/temp-${{ inputs.channel }}/latest.yml + aws s3 cp ./beta.yml s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/temp-${{ inputs.channel }}/beta.yml + + # Upload for tauri updater + aws s3 cp ./${{ steps.metadata.outputs.FILE_NAME }} s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/temp-${{ inputs.channel }}/${{ steps.metadata.outputs.FILE_NAME }} + 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" + + ## Upload to github release for stable release + - name: Upload release assert if public provider is github + if: inputs.public_provider == 'github' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: actions/upload-release-asset@v1.0.1 with: - name: jan-windows-${{ inputs.new_version }}.exe.sig - path: | - ./src-tauri/target/release/bundle/nsis/*.exe.sig + upload_url: ${{ inputs.upload_url }} + asset_path: ./src-tauri/target/release/bundle/nsis/latest.yml + asset_name: latest.yml + asset_content_type: text/yaml + + - name: Upload release assert if public provider is github + if: inputs.public_provider == 'github' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: actions/upload-release-asset@v1.0.1 + with: + upload_url: ${{ inputs.upload_url }} + asset_path: ./src-tauri/target/release/bundle/nsis/${{ steps.metadata.outputs.FILE_NAME }} + asset_name: ${{ steps.metadata.outputs.FILE_NAME }} + asset_content_type: application/octet-stream \ No newline at end of file diff --git a/package.json b/package.json index 7a04fbc4d..98af1415f 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,9 @@ "install:cortex:win32": "cd src-tauri/binaries && download.bat", "install:cortex": "run-script-os", "dev:tauri": "yarn build:icon && yarn copy:assets:tauri && tauri dev", - "build:tauri": "yarn install:cortex && yarn build:icon && yarn copy:assets:tauri && yarn tauri build --verbose", + "build:tauri:linux:win32": "yarn install:cortex && yarn build:icon && yarn copy:assets:tauri && yarn tauri build --verbose", + "build:tauri:darwin": "yarn install:cortex && yarn build:icon && yarn copy:assets:tauri && yarn tauri build --verbose --target universal-apple-darwin", + "build:tauri": "run-script-os", "build:icon": "tauri icon ./src-tauri/icons/icon.png", "build:server": "cd server && yarn build", "build:core": "cd core && yarn build && yarn pack", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 9ae8b0a63..3e2571070 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] -name = "Jan-nightly" -version = "0.5.16-1320" +name = "Jan" +version = "0.5.16" description = "Use offline LLMs with your own data. Run open source models like Llama2 or Falcon on your internal computers/servers." authors = ["Jan "] license = "MIT" diff --git a/src-tauri/binaries/download.sh b/src-tauri/binaries/download.sh index f9dbed958..17d0784d9 100755 --- a/src-tauri/binaries/download.sh +++ b/src-tauri/binaries/download.sh @@ -60,6 +60,7 @@ elif [ "$OS_TYPE" == "Darwin" ]; then chmod +x "./cortex-server" mv ./cortex-server ./cortex-server-universal-apple-darwin cp ./cortex-server-universal-apple-darwin ./cortex-server-aarch64-apple-darwin + cp ./cortex-server-universal-apple-darwin ./cortex-server-x86_64-apple-darwin # Download engines for macOS download "${ENGINE_DOWNLOAD_URL}-mac-arm64.tar.gz" "${SHARED_PATH}/engines/cortex.llamacpp/mac-arm64/v${ENGINE_VERSION}" diff --git a/src-tauri/latest.json.template b/src-tauri/latest.json.template new file mode 100644 index 000000000..50a570c9e --- /dev/null +++ b/src-tauri/latest.json.template @@ -0,0 +1,23 @@ +{ + "version": "", + "notes": "", + "pub_date": "", + "platforms": { + "linux-x86_64": { + "signature": "", + "url": "" + }, + "windows-x86_64": { + "signature": "", + "url": "" + }, + "darwin-aarch64": { + "signature": "", + "url": "" + }, + "darwin-x86_64": { + "signature": "", + "url": "" + } + } +} \ No newline at end of file diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index efbc154f0..3ae392d47 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,8 +1,8 @@ { "$schema": "https://schema.tauri.app/config/2", - "productName": "Jan-nightly", - "version": "0.5.16-1320", - "identifier": "jan-nightly.ai.app", + "productName": "Jan", + "version": "0.5.16", + "identifier": "jan.ai.app", "build": { "frontendDist": "../web/out", "devUrl": "http://localhost:3000", @@ -47,7 +47,7 @@ }, "plugins": { "updater": { - "pubkey": "", + "pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDJFNDEzMEVCMUEzNUFENDQKUldSRXJUVWE2ekJCTGc1Mm1BVXgrWmtES3huUlBFR0lCdG5qbWFvMzgyNDhGN3VTTko5Q1NtTW0K", "endpoints": [ "https://github.com/menloresearch/jan/releases/latest/download/latest.json" ], diff --git a/web/hooks/useDeleteThread.ts b/web/hooks/useDeleteThread.ts index d0c7cac1a..bdb82a268 100644 --- a/web/hooks/useDeleteThread.ts +++ b/web/hooks/useDeleteThread.ts @@ -44,7 +44,7 @@ export default function useDeleteThread() { ?.deleteMessage(threadId, message.id) .catch(console.error) } - + const thread = threads.find((e) => e.id === threadId) if (thread) { const updatedThread = {