From f85d4756728ba5ac5c1c23291b8ab33ca1ab1b40 Mon Sep 17 00:00:00 2001 From: Hien To Date: Tue, 16 Jan 2024 17:56:27 +0700 Subject: [PATCH] Correct syntax reuse workflow github action --- .github/workflows/build-linux-x64.yml | 54 ++++++++----- .github/workflows/build-macos.yml | 79 ++++++++++++------- .github/workflows/build-windows-x64.yml | 57 +++++++++---- .../workflows/delete-cloudflare-r2-folder.yml | 20 +++-- .github/workflows/get-update-version.yml | 19 +++-- .../workflows/jan-electron-build-nightly.yml | 43 +++++----- .../jan-electron-build-pre-release copy.yml | 55 +++++++++++++ .../jan-electron-build-pre-release.yml | 28 ++----- .../noti-discord-and-update-url-readme.yml | 36 ++++++--- 9 files changed, 262 insertions(+), 129 deletions(-) create mode 100644 .github/workflows/jan-electron-build-pre-release copy.yml diff --git a/.github/workflows/build-linux-x64.yml b/.github/workflows/build-linux-x64.yml index 7c7a4724e9..26596accf0 100644 --- a/.github/workflows/build-linux-x64.yml +++ b/.github/workflows/build-linux-x64.yml @@ -1,5 +1,6 @@ -jobs: - delete-cloudflare-r2-folder: +name: build-linux-x64 +on: + workflow_call: inputs: ref: required: true @@ -9,15 +10,32 @@ jobs: required: true type: boolean default: false - condition: - required: false - type: string - default: 'github.ref == ''refs/heads/main''' upload_cloudflare_r2: required: true type: boolean default: false + new-version: + required: true + type: string + default: '' + secrets: + CLOUDFLARE_R2_PUBLIC_URL: + required: false + CLOUDFLARE_R2_BUCKET_NAME: + required: false + CLOUDFLARE_R2_ACCESS_KEY_ID: + required: false + CLOUDFLARE_R2_SECRET_ACCESS_KEY: + required: false + CLOUDFLARE_ACCOUNT_ID: + required: false + GITHUB_TOKEN: + required: false + +jobs: + build-linux-x64: runs-on: ubuntu-latest + environment: production permissions: contents: write steps: @@ -38,9 +56,9 @@ jobs: id: version_update run: | # Update the version in electron/package.json - jq --arg version "${{ needs.get-update-version.outputs.new_version }}" '.version = $version' electron/package.json > /tmp/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 "${{ needs.get-update-version.outputs.new_version }}" '.version = $version' web/package.json > /tmp/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": "${{ secrets.CLOUDFLARE_R2_PUBLIC_URL }}", "channel": "latest"}]' electron/package.json > /tmp/package.json mv /tmp/package.json electron/package.json @@ -54,25 +72,25 @@ jobs: - name: Upload Artifact uses: actions/upload-artifact@v2 with: - name: jan-linux-amd64-${{ needs.get-update-version.outputs.new_version }}-deb + name: jan-linux-amd64-${{ inputs.new-version }}-deb path: ./electron/dist/*.deb - name: Upload Artifact uses: actions/upload-artifact@v2 with: - name: jan-linux-amd64-${{ needs.get-update-version.outputs.new_version }}-AppImage + name: jan-linux-amd64-${{ inputs.new-version }}-AppImage path: ./electron/dist/*.AppImage - - ${{ if eq(parameters.upload_cloudflare_r2, true) }}- name: put-object using awscli s3api - ${{ if eq(parameters.enable_condition, true) }}if: ${{ parameters.condition }} + + - name: put-object using awscli s3api + if: eq(${{ inputs.upload_cloudflare_r2 }}, true) run: | ls -al ./electron/dist - aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "latest/jan-linux-amd64-${{ needs.get-update-version.outputs.new_version }}.deb" --body "./electron/dist/jan-linux-amd64-${{ needs.get-update-version.outputs.new_version }}.deb" --content-type "application/octet-stream" - aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "${{ needs.get-update-version.outputs.new_version }}/jan-linux-amd64-${{ needs.get-update-version.outputs.new_version }}.deb" --body "./electron/dist/jan-linux-amd64-${{ needs.get-update-version.outputs.new_version }}.deb" --content-type "application/octet-stream" - aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "latest/jan-linux-x86_64-${{ needs.get-update-version.outputs.new_version }}.AppImage" --body "./electron/dist/jan-linux-x86_64-${{ needs.get-update-version.outputs.new_version }}.AppImage" --content-type "application/octet-stream" - aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "${{ needs.get-update-version.outputs.new_version }}/jan-linux-x86_64-${{ needs.get-update-version.outputs.new_version }}.AppImage" --body "./electron/dist/jan-linux-x86_64-${{ needs.get-update-version.outputs.new_version }}.AppImage" --content-type "application/octet-stream" + aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "latest/jan-linux-amd64-${{ inputs.new-version }}.deb" --body "./electron/dist/jan-linux-amd64-${{ inputs.new-version }}.deb" --content-type "application/octet-stream" + aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "${{ inputs.new-version }}/jan-linux-amd64-${{ inputs.new-version }}.deb" --body "./electron/dist/jan-linux-amd64-${{ inputs.new-version }}.deb" --content-type "application/octet-stream" + aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "latest/jan-linux-x86_64-${{ inputs.new-version }}.AppImage" --body "./electron/dist/jan-linux-x86_64-${{ inputs.new-version }}.AppImage" --content-type "application/octet-stream" + aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "${{ inputs.new-version }}/jan-linux-x86_64-${{ inputs.new-version }}.AppImage" --body "./electron/dist/jan-linux-x86_64-${{ inputs.new-version }}.AppImage" --content-type "application/octet-stream" aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "latest/latest-linux.yml" --body "./electron/dist/latest-linux.yml" --content-type "text/yaml" - aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "${{ needs.get-update-version.outputs.new_version }}/latest-linux.yml" --body "./electron/dist/latest-linux.yml" --content-type "text/yaml" + aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "${{ inputs.new-version }}/latest-linux.yml" --body "./electron/dist/latest-linux.yml" --content-type "text/yaml" env: AWS_ACCESS_KEY_ID: ${{ secrets.CLOUDFLARE_R2_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.CLOUDFLARE_R2_SECRET_ACCESS_KEY }} diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index e75bbe7760..7a125497a0 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -1,10 +1,7 @@ -jobs: - delete-cloudflare-r2-folder: +name: build-linux-x64 +on: + workflow_call: inputs: - environment: - required: true - type: string - default: 'production' ref: required: true type: string @@ -13,21 +10,49 @@ jobs: required: true type: boolean default: false - condition: - required: false - type: string - default: 'github.ref == ''refs/heads/main''' upload_cloudflare_r2: required: true type: boolean default: false + new-version: + required: true + type: string + default: '' + secrets: + CLOUDFLARE_R2_PUBLIC_URL: + required: false + CLOUDFLARE_R2_BUCKET_NAME: + required: false + CLOUDFLARE_R2_ACCESS_KEY_ID: + required: false + CLOUDFLARE_R2_SECRET_ACCESS_KEY: + required: false + CLOUDFLARE_ACCOUNT_ID: + required: false + GITHUB_TOKEN: + 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 + +jobs: + build-macos: runs-on: macos-latest - environment: ${{ parameters.environment }} + environment: production + permissions: + contents: write steps: - name: Getting the repo uses: actions/checkout@v3 with: - ref: ${{ parameters.ref }} + ref: ${{ inputs.ref }} - name: Installing node uses: actions/setup-node@v1 @@ -42,10 +67,10 @@ jobs: id: version_update run: | # Update the version in electron/package.json - jq --arg version "${{ needs.get-update-version.outputs.new_version }}" '.version = $version' electron/package.json > /tmp/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 "${{ needs.get-update-version.outputs.new_version }}" '.version = $version' web/package.json > /tmp/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": "${{ secrets.CLOUDFLARE_R2_PUBLIC_URL }}", "channel": "latest"}]' electron/package.json > /tmp/package.json @@ -79,27 +104,27 @@ jobs: - name: Upload Artifact uses: actions/upload-artifact@v2 with: - name: jan-mac-x64-${{ needs.get-update-version.outputs.new_version }} - path: ./electron/dist/jan-mac-x64-${{ needs.get-update-version.outputs.new_version }}.dmg + name: jan-mac-x64-${{ inputs.new-version }} + path: ./electron/dist/jan-mac-x64-${{ inputs.new-version }}.dmg - name: Upload Artifact uses: actions/upload-artifact@v2 with: - name: jan-mac-arm64-${{ needs.get-update-version.outputs.new_version }} - path: ./electron/dist/jan-mac-arm64-${{ needs.get-update-version.outputs.new_version }}.dmg + name: jan-mac-arm64-${{ inputs.new-version }} + path: ./electron/dist/jan-mac-arm64-${{ inputs.new-version }}.dmg - ${{ if eq(parameters.upload_cloudflare_r2, true) }}- name: put-object using awscli s3api - ${{ if eq(parameters.enable_condition, true) }}if: ${{ parameters.condition }} + - name: put-object using awscli s3api + if: eq(${{ inputs.upload_cloudflare_r2 }}, true) continue-on-error: true run: | ls -al ./electron/dist - aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "latest/jan-mac-x64-${{ needs.get-update-version.outputs.new_version }}.dmg" --body "./electron/dist/jan-mac-x64-${{ needs.get-update-version.outputs.new_version }}.dmg" --content-type "application/octet-stream" - aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "latest/jan-mac-arm64-${{ needs.get-update-version.outputs.new_version }}.dmg" --body "./electron/dist/jan-mac-arm64-${{ needs.get-update-version.outputs.new_version }}.dmg" --content-type "application/octet-stream" - aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "latest/jan-mac-x64-${{ needs.get-update-version.outputs.new_version }}.zip" --body "./electron/dist/jan-mac-x64-${{ needs.get-update-version.outputs.new_version }}.zip" --content-type "application/zip" - aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "latest/jan-mac-arm64-${{ needs.get-update-version.outputs.new_version }}.zip" --body "./electron/dist/jan-mac-arm64-${{ needs.get-update-version.outputs.new_version }}.zip" --content-type "application/zip" - aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "${{ needs.get-update-version.outputs.new_version }}/jan-mac-x64-${{ needs.get-update-version.outputs.new_version }}.dmg" --body "./electron/dist/jan-mac-x64-${{ needs.get-update-version.outputs.new_version }}.dmg" --content-type "application/octet-stream" - aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "${{ needs.get-update-version.outputs.new_version }}/jan-mac-arm64-${{ needs.get-update-version.outputs.new_version }}.dmg" --body "./electron/dist/jan-mac-arm64-${{ needs.get-update-version.outputs.new_version }}.dmg" --content-type "application/octet-stream" - aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "${{ needs.get-update-version.outputs.new_version }}/latest-mac.yml" --body "./electron/dist/latest-mac.yml" --content-type "text/yaml" + aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "latest/jan-mac-x64-${{ inputs.new-version }}.dmg" --body "./electron/dist/jan-mac-x64-${{ inputs.new-version }}.dmg" --content-type "application/octet-stream" + aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "latest/jan-mac-arm64-${{ inputs.new-version }}.dmg" --body "./electron/dist/jan-mac-arm64-${{ inputs.new-version }}.dmg" --content-type "application/octet-stream" + aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "latest/jan-mac-x64-${{ inputs.new-version }}.zip" --body "./electron/dist/jan-mac-x64-${{ inputs.new-version }}.zip" --content-type "application/zip" + aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "latest/jan-mac-arm64-${{ inputs.new-version }}.zip" --body "./electron/dist/jan-mac-arm64-${{ inputs.new-version }}.zip" --content-type "application/zip" + aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "${{ inputs.new-version }}/jan-mac-x64-${{ inputs.new-version }}.dmg" --body "./electron/dist/jan-mac-x64-${{ inputs.new-version }}.dmg" --content-type "application/octet-stream" + aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "${{ inputs.new-version }}/jan-mac-arm64-${{ inputs.new-version }}.dmg" --body "./electron/dist/jan-mac-arm64-${{ inputs.new-version }}.dmg" --content-type "application/octet-stream" + aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "${{ inputs.new-version }}/latest-mac.yml" --body "./electron/dist/latest-mac.yml" --content-type "text/yaml" aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "latest/latest-mac.yml" --body "./electron/dist/latest-mac.yml" --content-type "text/yaml" env: AWS_ACCESS_KEY_ID: ${{ secrets.CLOUDFLARE_R2_ACCESS_KEY_ID }} diff --git a/.github/workflows/build-windows-x64.yml b/.github/workflows/build-windows-x64.yml index fe9d3e07cb..d1a17dd167 100644 --- a/.github/workflows/build-windows-x64.yml +++ b/.github/workflows/build-windows-x64.yml @@ -1,5 +1,6 @@ -jobs: - delete-cloudflare-r2-folder: +name: build-windows-x64 +on: + workflow_call: inputs: ref: required: true @@ -9,14 +10,40 @@ jobs: required: true type: boolean default: false - condition: - required: false - type: string - default: 'github.ref == ''refs/heads/main''' upload_cloudflare_r2: required: true type: boolean default: false + new-version: + required: true + type: string + default: '' + secrets: + CLOUDFLARE_R2_PUBLIC_URL: + required: false + CLOUDFLARE_R2_BUCKET_NAME: + required: false + CLOUDFLARE_R2_ACCESS_KEY_ID: + required: false + CLOUDFLARE_R2_SECRET_ACCESS_KEY: + required: false + CLOUDFLARE_ACCOUNT_ID: + required: false + GITHUB_TOKEN: + 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 + +jobs: + build-windows-x64: runs-on: windows-latest permissions: contents: write @@ -39,10 +66,10 @@ jobs: shell: bash run: | # Update the version in electron/package.json - jq --arg version "${{ needs.get-update-version.outputs.new_version }}" '.version = $version' electron/package.json > /tmp/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 "${{ needs.get-update-version.outputs.new_version }}" '.version = $version' web/package.json > /tmp/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": "${{ secrets.CLOUDFLARE_R2_PUBLIC_URL }}", "channel": "latest"}]' electron/package.json > /tmp/package.json @@ -68,19 +95,19 @@ jobs: - name: Upload Artifact uses: actions/upload-artifact@v2 with: - name: jan-win-x64-${{ needs.get-update-version.outputs.new_version }} + name: jan-win-x64-${{ inputs.new-version }} path: ./electron/dist/*.exe - ${{ if eq(parameters.upload_cloudflare_r2, true) }}- name: put-object using awscli s3api - ${{ if eq(parameters.enable_condition, true) }}if: ${{ parameters.condition }} + - name: put-object using awscli s3api + if: eq(${{ inputs.upload_cloudflare_r2 }}, true) shell: bash run: | ls -al ./electron/dist - aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "latest/jan-win-x64-${{ needs.get-update-version.outputs.new_version }}.exe" --body "./electron/dist/jan-win-x64-${{ needs.get-update-version.outputs.new_version }}.exe" - aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "latest/jan-win-x64-${{ needs.get-update-version.outputs.new_version }}.exe.blockmap" --body "./electron/dist/jan-win-x64-${{ needs.get-update-version.outputs.new_version }}.exe.blockmap" - aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "${{ needs.get-update-version.outputs.new_version }}/jan-win-x64-${{ needs.get-update-version.outputs.new_version }}.exe" --body "./electron/dist/jan-win-x64-${{ needs.get-update-version.outputs.new_version }}.exe" + aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "latest/jan-win-x64-${{ inputs.new-version }}.exe" --body "./electron/dist/jan-win-x64-${{ inputs.new-version }}.exe" + aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "latest/jan-win-x64-${{ inputs.new-version }}.exe.blockmap" --body "./electron/dist/jan-win-x64-${{ inputs.new-version }}.exe.blockmap" + aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "${{ inputs.new-version }}/jan-win-x64-${{ inputs.new-version }}.exe" --body "./electron/dist/jan-win-x64-${{ inputs.new-version }}.exe" aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "latest/latest.yml" --body "./electron/dist/latest.yml" - aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "${{ needs.get-update-version.outputs.new_version }}/latest.yml" --body "./electron/dist/latest.yml" + aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "${{ inputs.new-version }}/latest.yml" --body "./electron/dist/latest.yml" env: AWS_ACCESS_KEY_ID: ${{ secrets.CLOUDFLARE_R2_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.CLOUDFLARE_R2_SECRET_ACCESS_KEY }} diff --git a/.github/workflows/delete-cloudflare-r2-folder.yml b/.github/workflows/delete-cloudflare-r2-folder.yml index 0b43071e58..372946c5bb 100644 --- a/.github/workflows/delete-cloudflare-r2-folder.yml +++ b/.github/workflows/delete-cloudflare-r2-folder.yml @@ -1,12 +1,20 @@ +name: build-windows-x64 +on: + workflow_call: + secrets: + CLOUDFLARE_R2_BUCKET_NAME: + required: false + CLOUDFLARE_R2_ACCESS_KEY_ID: + required: false + CLOUDFLARE_R2_SECRET_ACCESS_KEY: + required: false + CLOUDFLARE_ACCOUNT_ID: + required: false + jobs: delete-cloudflare-r2-folder: - inputs: - environment: - required: true - type: string - default: 'production' runs-on: ubuntu-latest - environment: ${{ parameters.environment }} + environment: production steps: - name: install-aws-cli-action uses: unfor19/install-aws-cli-action@v1 diff --git a/.github/workflows/get-update-version.yml b/.github/workflows/get-update-version.yml index 98ffcf9221..d71cbf2c12 100644 --- a/.github/workflows/get-update-version.yml +++ b/.github/workflows/get-update-version.yml @@ -1,14 +1,13 @@ +name: get-update-version +on: + workflow_call: + jobs: get-update-version: - inputs: - environment: - required: true - type: string - default: 'production' runs-on: ubuntu-latest - environment: ${{ parameters.environment }} + environment: production outputs: - new_version: ${{ steps.version_update.outputs.new_version }} + new-version: ${{ steps.version_update.outputs.new-version }} steps: - name: Install jq uses: dcarbone/install-jq-action@v2.0.1 @@ -39,6 +38,6 @@ jobs: LATEST_TAG=$(get_latest_tag) # Remove the 'v' and append the build number to the version - NEW_VERSION="${LATEST_TAG#v}-${GITHUB_RUN_NUMBER}" - echo "New version: $NEW_VERSION" - echo "::set-output name=new_version::$NEW_VERSION" \ No newline at end of file + new-version="${LATEST_TAG#v}-${GITHUB_RUN_NUMBER}" + echo "New version: $new-version" + echo "::set-output name=new-version::$new-version" \ No newline at end of file diff --git a/.github/workflows/jan-electron-build-nightly.yml b/.github/workflows/jan-electron-build-nightly.yml index 168966720d..fe00cb88a6 100644 --- a/.github/workflows/jan-electron-build-nightly.yml +++ b/.github/workflows/jan-electron-build-nightly.yml @@ -4,47 +4,56 @@ on: schedule: - cron: '0 20 * * 2,3,4' # At 8 PM UTC on Tuesday, Wednesday, and Thursday, which is 3 AM UTC+7 - workflow_dispatch: - jobs: + # Get condition to upload to cloudflare re + # get-condition-to-upload-cloudflare-r2: + # runs-on: ubuntu-latest + # outputs: + # condition: ${{ steps.get-condition-to-upload-cloudflare-r2.outputs.condition }} + # steps: + # - name: Get condition to upload to cloudflare re + # id: get-condition-to-upload-cloudflare-r2 + # run: | + # if [ "${{ github.event_name }}" == "schedule" ]; then + # echo "::set-output name=condition::true" + # else + # echo "::set-output name=condition::false" + # fi + delete-cloudflare-r2-folder: uses: ./.github/workflows/delete-cloudflare-r2-folder.yml - with: - environment: production # Job create Update app version based on latest release tag with build number and save to output get-update-version: uses: ./.github/workflows/get-update-version.yml - with: - environment: production build-macos: uses: ./.github/workflows/build-macos.yml + needs: [delete-cloudflare-r2-folder, get-update-version] with: - environment: production ref: refs/heads/dev enable_condition: true - condition: github.ref == 'refs/heads/dev' upload_cloudflare_r2: true + new-version: ${{ needs.get-update-version.outputs.new-version }} build-windows-x64: uses: ./.github/workflows/build-windows-x64.yml + needs: [delete-cloudflare-r2-folder, get-update-version] with: - environment: production ref: refs/heads/dev enable_condition: true - condition: github.ref == 'refs/heads/dev' upload_cloudflare_r2: true + new-version: ${{ needs.get-update-version.outputs.new-version }} build-linux-x64: uses: ./.github/workflows/build-linux-x64.yml + needs: [delete-cloudflare-r2-folder, get-update-version] with: - environment: production ref: refs/heads/dev enable_condition: true - condition: github.ref == 'refs/heads/dev' upload_cloudflare_r2: true + new-version: ${{ needs.get-update-version.outputs.new-version }} noti-discord-nightly-and-update-url-readme: needs: [build-macos, build-windows-x64, build-linux-x64, delete-cloudflare-r2-folder, get-update-version] @@ -54,12 +63,4 @@ jobs: ref: refs/heads/dev build_reason: Nightly push_to_branch: main - - noti-discord-manual-and-update-url-readme: - needs: [build-macos, build-windows-x64, build-linux-x64, delete-cloudflare-r2-folder, get-update-version] - if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/dev' - uses: ./.github/workflows/noti-discord-and-update-url-readme.yml - with: - ref: refs/heads/dev - build_reason: Manual - push_to_branch: main \ No newline at end of file + new-version: ${{ needs.get-update-version.outputs.new-version }} diff --git a/.github/workflows/jan-electron-build-pre-release copy.yml b/.github/workflows/jan-electron-build-pre-release copy.yml new file mode 100644 index 0000000000..dc0a7ec78d --- /dev/null +++ b/.github/workflows/jan-electron-build-pre-release copy.yml @@ -0,0 +1,55 @@ +name: Jan Build Electron App Nightly or Manual + +on: + workflow_dispatch: + inputs: + upload_cloudflare_r2: + description: 'Upload to Cloudflare R2' + required: true + type: boolean + default: false + +jobs: + delete-cloudflare-r2-folder: + uses: ./.github/workflows/delete-cloudflare-r2-folder.yml + + # Job create Update app version based on latest release tag with build number and save to output + get-update-version: + uses: ./.github/workflows/get-update-version.yml + + build-macos: + uses: ./.github/workflows/build-macos.yml + needs: [delete-cloudflare-r2-folder, get-update-version] + with: + ref: refs/heads/main + enable_condition: true + upload_cloudflare_r2: ${{ github.event.inputs.upload_cloudflare_r2 }} + new-version: ${{ needs.get-update-version.outputs.new-version }} + + build-windows-x64: + uses: ./.github/workflows/build-windows-x64.yml + needs: [delete-cloudflare-r2-folder, get-update-version] + with: + ref: refs/heads/main + enable_condition: true + upload_cloudflare_r2: ${{ github.event.inputs.upload_cloudflare_r2 }} + new-version: ${{ needs.get-update-version.outputs.new-version }} + + build-linux-x64: + uses: ./.github/workflows/build-linux-x64.yml + needs: [delete-cloudflare-r2-folder, get-update-version] + with: + ref: refs/heads/main + enable_condition: true + upload_cloudflare_r2: ${{ github.event.inputs.upload_cloudflare_r2 }} + 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, delete-cloudflare-r2-folder, get-update-version] + if: github.event_name == 'workflow_dispatch' && github.event.inputs.upload_cloudflare_r2 == 'true' + uses: ./.github/workflows/noti-discord-and-update-url-readme.yml + with: + ref: refs/heads/main + build_reason: Manual + push_to_branch: main + new-version: ${{ needs.get-update-version.outputs.new-version }} \ No newline at end of file diff --git a/.github/workflows/jan-electron-build-pre-release.yml b/.github/workflows/jan-electron-build-pre-release.yml index 45fe233500..ccab96a094 100644 --- a/.github/workflows/jan-electron-build-pre-release.yml +++ b/.github/workflows/jan-electron-build-pre-release.yml @@ -6,47 +6,41 @@ on: - main paths: - "!README.md" - workflow_dispatch: jobs: delete-cloudflare-r2-folder: uses: ./.github/workflows/delete-cloudflare-r2-folder.yml - with: - environment: production # Job create Update app version based on latest release tag with build number and save to output get-update-version: uses: ./.github/workflows/get-update-version.yml - with: - environment: production build-macos: uses: ./.github/workflows/build-macos.yml + needs: [delete-cloudflare-r2-folder, get-update-version] with: - environment: production ref: refs/heads/main enable_condition: true - condition: github.ref == 'refs/heads/main' upload_cloudflare_r2: true + new-version: ${{ needs.get-update-version.outputs.new-version }} build-windows-x64: uses: ./.github/workflows/build-windows-x64.yml + needs: [delete-cloudflare-r2-folder, get-update-version] with: - environment: production ref: refs/heads/main enable_condition: true - condition: github.ref == 'refs/heads/main' upload_cloudflare_r2: true + new-version: ${{ needs.get-update-version.outputs.new-version }} - build-linux-x64: uses: ./.github/workflows/build-linux-x64.yml + needs: [delete-cloudflare-r2-folder, get-update-version] with: - environment: production ref: refs/heads/main enable_condition: true - condition: github.ref == 'refs/heads/main' upload_cloudflare_r2: true + new-version: ${{ needs.get-update-version.outputs.new-version }} noti-discord-nightly-and-update-url-readme: needs: [build-macos, build-windows-x64, build-linux-x64, delete-cloudflare-r2-folder, get-update-version] @@ -56,12 +50,4 @@ jobs: ref: refs/heads/main build_reason: Nightly push_to_branch: main - - noti-discord-manual-and-update-url-readme: - needs: [build-macos, build-windows-x64, build-linux-x64, delete-cloudflare-r2-folder, get-update-version] - if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main' - uses: ./.github/workflows/noti-discord-and-update-url-readme.yml - with: - ref: refs/heads/main - build_reason: Manual - push_to_branch: main \ No newline at end of file + new-version: ${{ needs.get-update-version.outputs.new-version }} diff --git a/.github/workflows/noti-discord-and-update-url-readme.yml b/.github/workflows/noti-discord-and-update-url-readme.yml index ecff8e4084..309fc4d35e 100644 --- a/.github/workflows/noti-discord-and-update-url-readme.yml +++ b/.github/workflows/noti-discord-and-update-url-readme.yml @@ -1,5 +1,6 @@ -jobs: - delete-cloudflare-r2-folder: +name: build-windows-x64 +on: + workflow_call: inputs: ref: required: true @@ -13,6 +14,19 @@ jobs: required: true type: string default: 'main' + new-version: + required: true + type: string + default: '' + secrets: + PAT_SERVICE_ACCOUNT: + required: false + DISCORD_WEBHOOK: + required: false + +jobs: + delete-cloudflare-r2-folder: + environment: production runs-on: ubuntu-latest permissions: contents: write @@ -22,17 +36,17 @@ jobs: with: fetch-depth: "0" token: ${{ secrets.PAT_SERVICE_ACCOUNT }} - ref: ${{ parameters.ref }} + ref: ${{ inputs.ref }} - name: Set version to environment variable run: | - echo "VERSION=${{ needs.get-update-version.outputs.new_version }}" >> $GITHUB_ENV + echo "VERSION=${{ inputs.new-version }}" >> $GITHUB_ENV - name: Notify Discord uses: Ilshidur/action-discord@master with: args: | - Jan App ${{ parameters.build_reason }} build artifact version {{ VERSION }}: + Jan App ${{ inputs.build_reason }} build artifact version {{ VERSION }}: - Windows: https://delta.jan.ai/{{ VERSION }}/jan-win-x64-{{ VERSION }}.exe - macOS Intel: https://delta.jan.ai/{{ VERSION }}/jan-mac-x64-{{ VERSION }}.dmg - macOS Apple Silicon: https://delta.jan.ai/{{ VERSION }}/jan-mac-arm64-{{ VERSION }}.dmg @@ -44,15 +58,15 @@ jobs: - name: Update README.md with artifact URL run: | - sed -i "s|||" README.md - sed -i "s|||" README.md - sed -i "s|||" README.md - sed -i "s|||" README.md - sed -i "s|||" README.md + sed -i "s|||" README.md + sed -i "s|||" README.md + sed -i "s|||" README.md + sed -i "s|||" README.md + sed -i "s|||" README.md git config --global user.email "service@jan.ai" git config --global user.name "Service Account" git add README.md git commit -m "${GITHUB_REPOSITORY}: Update README.md with nightly build artifact URL" - git -c http.extraheader="AUTHORIZATION: bearer ${{ secrets.PAT_SERVICE_ACCOUNT }}" push origin HEAD:${{ parameters.push_to_branch }} + git -c http.extraheader="AUTHORIZATION: bearer ${{ secrets.PAT_SERVICE_ACCOUNT }}" push origin HEAD:${{ inputs.push_to_branch }} env: GITHUB_RUN_ID: ${{ github.run_id }}