diff --git a/.github/scripts/rename-app-beta.sh b/.github/scripts/rename-app-beta.sh new file mode 100644 index 000000000..403e57a02 --- /dev/null +++ b/.github/scripts/rename-app-beta.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +# Check if the correct number of arguments is provided +if [ "$#" -ne 1 ]; then + echo "Usage: $0 " + exit 1 +fi + +INPUT_JSON_FILE="$1" + +# Check if the input file exists +if [ ! -f "$INPUT_JSON_FILE" ]; then + echo "Input file not found: $INPUT_JSON_FILE" + exit 1 +fi + +# Use jq to transform the content +jq ' + .name = "jan-beta" | + .build.productName = "Jan-beta" | + .build.appId = "jan-beta.ai.app" | + .build.protocols[0].name = "Jan-beta" | + .build.protocols[0].schemes = ["jan-beta"] | + .build.artifactName = "jan-beta-${os}-${arch}-${version}.${ext}" | + .build.publish[0].channel = "beta" +' "$INPUT_JSON_FILE" > ./package.json.tmp + +cat ./package.json.tmp + +rm $INPUT_JSON_FILE +mv ./package.json.tmp $INPUT_JSON_FILE \ No newline at end of file diff --git a/.github/scripts/rename-uninstaller-beta.sh b/.github/scripts/rename-uninstaller-beta.sh new file mode 100644 index 000000000..c322825da --- /dev/null +++ b/.github/scripts/rename-uninstaller-beta.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +# File path to be modified +FILE_PATH="electron/scripts/uninstaller.nsh" + +# Check if the file exists +if [ ! -f "$FILE_PATH" ]; then + echo "File does not exist: $FILE_PATH" + exit 1 +fi + +# Perform the replacements +sed -i -e "s#jan#jan-beta#g" "$FILE_PATH" + +# Notify completion +echo "File has been updated: $FILE_PATH" \ No newline at end of file diff --git a/.github/scripts/rename-workspace-beta.sh b/.github/scripts/rename-workspace-beta.sh new file mode 100644 index 000000000..6286d1889 --- /dev/null +++ b/.github/scripts/rename-workspace-beta.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +# File path to be modified +FILE_PATH="$1" + +# Check if the file exists +if [ ! -f "$FILE_PATH" ]; then + echo "File does not exist: $FILE_PATH" + exit 1 +fi + +# Perform the replacements +sed -i -e 's/yarn workspace jan/yarn workspace jan-beta/g' "$FILE_PATH" + +# Notify completion +echo "File has been updated: $FILE_PATH" \ No newline at end of file diff --git a/.github/workflows/jan-electron-build-beta.yml b/.github/workflows/jan-electron-build-beta.yml new file mode 100644 index 000000000..75114555d --- /dev/null +++ b/.github/workflows/jan-electron-build-beta.yml @@ -0,0 +1,120 @@ +name: Electron 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 + + 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 + generate_release_notes: true + + build-macos-x64: + uses: ./.github/workflows/template-build-macos-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 + + build-macos-arm64: + uses: ./.github/workflows/template-build-macos-arm64.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 + + build-windows-x64: + uses: ./.github/workflows/template-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 + + build-linux-x64: + uses: ./.github/workflows/template-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 + + combine-latest-mac-yml: + needs: [build-macos-x64, build-macos-arm64, create-draft-release] + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Getting the repo + uses: actions/checkout@v3 + + - name: Download mac-x64 artifacts + uses: actions/download-artifact@v4 + with: + name: latest-mac-x64 + path: ./latest-mac-x64 + - name: Download mac-arm artifacts + uses: actions/download-artifact@v4 + with: + name: latest-mac-arm64 + path: ./latest-mac-arm64 + + - name: 'Merge latest-mac.yml' + # unfortunately electron-builder doesn't understand that we have two different releases for mac-x64 and mac-arm, so we need to manually merge the latest files + # see https://github.com/electron-userland/electron-builder/issues/5592 + run: | + ls -la . + ls -la ./latest-mac-x64 + ls -la ./latest-mac-arm64 + ls -la ./electron + cp ./electron/merge-latest-ymls.js /tmp/merge-latest-ymls.js + npm install js-yaml --prefix /tmp + node /tmp/merge-latest-ymls.js ./latest-mac-x64/latest-mac.yml ./latest-mac-arm64/latest-mac.yml ./latest-mac.yml + cat ./latest-mac.yml + + - name: Yet Another Upload Release Asset Action + uses: shogo82148/actions-upload-release-asset@v1.7.2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.create-draft-release.outputs.upload_url }} + asset_path: ./latest-mac.yml + asset_name: latest-mac.yml + asset_content_type: text/yaml + overwrite: true + diff --git a/.github/workflows/template-build-linux-x64.yml b/.github/workflows/template-build-linux-x64.yml index 386a0ee4f..a7284b4a9 100644 --- a/.github/workflows/template-build-linux-x64.yml +++ b/.github/workflows/template-build-linux-x64.yml @@ -19,6 +19,10 @@ on: required: false type: string default: '/latest/' + beta: + required: false + type: boolean + default: false secrets: DELTA_AWS_S3_BUCKET_NAME: required: false @@ -60,13 +64,22 @@ jobs: mv /tmp/package.json electron/package.json cat electron/package.json + - name: Change App Name for beta version + if: inputs.beta == true + shell: bash + run: | + chmod +x .github/scripts/rename-app-beta.sh + .github/scripts/rename-app-beta.sh ./electron/package.json + chmod +x .github/scripts/rename-workspace-beta.sh + .github/scripts/rename-workspace-beta.sh ./package.json + echo "------------------------" + cat ./electron/package.json + echo "------------------------" + 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: | - if [[ ! "${VERSION_TAG}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - echo "Error: Tag is not valid!" - exit 1 - fi 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 diff --git a/.github/workflows/template-build-macos-arm64.yml b/.github/workflows/template-build-macos-arm64.yml index 40d40164f..629fd596a 100644 --- a/.github/workflows/template-build-macos-arm64.yml +++ b/.github/workflows/template-build-macos-arm64.yml @@ -19,6 +19,10 @@ on: required: false type: string default: '/latest/' + beta: + required: false + type: boolean + default: false secrets: DELTA_AWS_S3_BUCKET_NAME: required: false @@ -76,13 +80,22 @@ jobs: cat electron/package.json + - name: Change App Name for beta version + if: inputs.beta == true + shell: bash + run: | + chmod +x .github/scripts/rename-app-beta.sh + .github/scripts/rename-app-beta.sh ./electron/package.json + chmod +x .github/scripts/rename-workspace-beta.sh + .github/scripts/rename-workspace-beta.sh ./package.json + echo "------------------------" + cat ./electron/package.json + echo "------------------------" + 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: | - if [[ ! "${VERSION_TAG}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - echo "Error: Tag is not valid!" - exit 1 - fi 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 diff --git a/.github/workflows/template-build-macos-x64.yml b/.github/workflows/template-build-macos-x64.yml index b7103fd06..f86bbfa48 100644 --- a/.github/workflows/template-build-macos-x64.yml +++ b/.github/workflows/template-build-macos-x64.yml @@ -19,6 +19,10 @@ on: required: false type: string default: '/latest/' + beta: + required: false + type: boolean + default: false secrets: DELTA_AWS_S3_BUCKET_NAME: required: false @@ -76,13 +80,22 @@ jobs: cat electron/package.json + - name: Change App Name for beta version + if: inputs.beta == true + shell: bash + run: | + chmod +x .github/scripts/rename-app-beta.sh + .github/scripts/rename-app-beta.sh ./electron/package.json + chmod +x .github/scripts/rename-workspace-beta.sh + .github/scripts/rename-workspace-beta.sh ./package.json + echo "------------------------" + cat ./electron/package.json + echo "------------------------" + 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: | - if [[ ! "${VERSION_TAG}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - echo "Error: Tag is not valid!" - exit 1 - fi 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 diff --git a/.github/workflows/template-build-windows-x64.yml b/.github/workflows/template-build-windows-x64.yml index b1110e316..7fa769630 100644 --- a/.github/workflows/template-build-windows-x64.yml +++ b/.github/workflows/template-build-windows-x64.yml @@ -19,6 +19,10 @@ on: required: false type: string default: '/latest/' + beta: + required: false + type: boolean + default: false secrets: DELTA_AWS_S3_BUCKET_NAME: required: false @@ -76,14 +80,27 @@ jobs: mv /tmp/package.json electron/package.json cat electron/package.json + - name: Change App Name for beta version + if: inputs.beta == true + shell: bash + run: | + chmod +x .github/scripts/rename-app-beta.sh + .github/scripts/rename-app-beta.sh ./electron/package.json + chmod +x .github/scripts/rename-workspace-beta.sh + .github/scripts/rename-workspace-beta.sh ./package.json + chmod +x .github/scripts/rename-uninstaller-beta.sh + .github/scripts/rename-uninstaller-beta.sh + echo "------------------------" + cat ./electron/package.json + 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: | - if [[ ! "${VERSION_TAG}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - echo "Error: Tag is not valid!" - exit 1 - fi 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