From 9fbd9b39d61534a8c8249f396936e45ce5fca2c5 Mon Sep 17 00:00:00 2001 From: Joooye_34 Date: Thu, 21 Dec 2023 10:00:12 +0000 Subject: [PATCH] ci: set version correctly and remove nightly build workflow (#5367) --- .github/actions/setup-version/action.yml | 4 + .github/workflows/deploy.yml | 5 + .github/workflows/nightly-build.yml | 258 ------------------ .github/workflows/release-desktop.yml | 1 + .../electron/scripts/generate-assets.ts | 3 +- 5 files changed, 12 insertions(+), 259 deletions(-) delete mode 100644 .github/workflows/nightly-build.yml diff --git a/.github/actions/setup-version/action.yml b/.github/actions/setup-version/action.yml index 4c60d599d2..f27ce3fc35 100644 --- a/.github/actions/setup-version/action.yml +++ b/.github/actions/setup-version/action.yml @@ -1,5 +1,9 @@ name: Setup Version description: 'Setup Version' +outputs: + APP_VERSION: + description: 'App Version' + value: ${{ steps.version.outputs.APP_VERSION }} runs: using: 'composite' steps: diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 7749f50975..57827411bf 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -23,6 +23,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Setup Version + id: version uses: ./.github/actions/setup-version - name: Setup Node.js uses: ./.github/actions/setup-node @@ -43,6 +44,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Setup Version + id: version uses: ./.github/actions/setup-version - name: Setup Node.js uses: ./.github/actions/setup-node @@ -76,6 +78,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Setup Version + id: version uses: ./.github/actions/setup-version - name: Setup Node.js uses: ./.github/actions/setup-node @@ -99,6 +102,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Setup Version + id: version uses: ./.github/actions/setup-version - name: Setup Node.js uses: ./.github/actions/setup-node @@ -220,6 +224,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Setup Version + id: version uses: ./.github/actions/setup-version - name: Deploy to ${{ github.event.inputs.flavor }} uses: ./.github/actions/deploy diff --git a/.github/workflows/nightly-build.yml b/.github/workflows/nightly-build.yml deleted file mode 100644 index 2a0de72264..0000000000 --- a/.github/workflows/nightly-build.yml +++ /dev/null @@ -1,258 +0,0 @@ -name: Build Canary Desktop App on Staging Branch - -on: - workflow_dispatch: - inputs: - channel_override: - description: 'channel type (canary, beta, or stable)' - type: choice - default: beta - options: - - canary - - beta - - stable - push: - branches: - # 0.6.x-staging - - v[0-9]+.[0-9]+.x-staging - # 0.6.1-staging - - v[0-9]+.[0-9]+.[0-9]+-staging - paths-ignore: - - README.md - - .github/** - - '!.github/workflows/nightly-build.yml' - - '!.github/actions/build-rust/action.yml' - - '!.github/actions/setup-node/action.yml' - -permissions: - actions: write - contents: write - security-events: write - -concurrency: - # The concurrency group contains the workflow name and the branch name for - # pull requests or the commit hash for any other events. - group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} - cancel-in-progress: true - -env: - # BUILD_TYPE => app icon, app name, etc - BUILD_TYPE: internal - # BUILD_TYPE_OVERRIDE => channel type (canary, beta, or stable) - get the channel type (the api configs) - BUILD_TYPE_OVERRIDE: ${{ github.event.inputs.channel_override || 'beta' }} - -jobs: - set-build-version: - runs-on: ubuntu-latest - outputs: - version: 0.0.0-internal.${{ steps.version.outputs.version }} - steps: - - uses: actions/checkout@v4 - - uses: toeverything/set-build-version@latest - - id: version - run: echo ::set-output name=version::${{ env.BUILD_VERSION }} - - before-make: - runs-on: ubuntu-latest - needs: - - set-build-version - steps: - - uses: actions/checkout@v4 - - name: Setup Node.js - uses: ./.github/actions/setup-node - - name: Setup @sentry/cli - uses: ./.github/actions/setup-sentry - - name: Replace Version - run: ./scripts/set-version.sh ${{ needs.set-build-version.outputs.version }} - - name: generate-assets - run: yarn workspace @affine/electron generate-assets - env: - SENTRY_ORG: ${{ secrets.SENTRY_ORG }} - SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }} - SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} - SENTRY_DSN: ${{ secrets.SENTRY_DSN }} - RELEASE_VERSION: ${{ needs.set-build-version.outputs.version }} - SKIP_PLUGIN_BUILD: 'true' - SKIP_NX_CACHE: 'true' - - - name: Upload core artifact - uses: actions/upload-artifact@v3 - with: - name: core - path: packages/frontend/electron/resources/web-static - - make-distribution: - strategy: - # all combinations: macos-latest x64, macos-latest arm64, ubuntu-latest x64 - # For windows, we need a separate approach - matrix: - spec: - - runner: macos-latest - platform: darwin - arch: x64 - target: x86_64-apple-darwin - - runner: macos-latest - platform: darwin - arch: arm64 - target: aarch64-apple-darwin - - runner: ubuntu-latest - platform: linux - arch: x64 - target: x86_64-unknown-linux-gnu - - runner: windows-latest - platform: win32 - arch: x64 - target: x86_64-pc-windows-msvc - runs-on: ${{ matrix.spec.runner }} - needs: - - before-make - - set-build-version - env: - APPLE_ID: ${{ secrets.APPLE_ID }} - APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }} - APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} - SKIP_GENERATE_ASSETS: 1 - steps: - - uses: actions/checkout@v4 - - name: Setup Node.js - timeout-minutes: 10 - if: ${{ matrix.spec.platform == 'darwin' }} - uses: ./.github/actions/setup-node - with: - extra-flags: workspaces focus @affine/electron @affine/monorepo - hard-link-nm: false - build-plugins: false - nmHoistingLimits: workspaces - enableScripts: false - - name: Setup Node.js - timeout-minutes: 10 - if: ${{ matrix.spec.platform != 'darwin' }} - uses: ./.github/actions/setup-node - with: - extra-flags: workspaces focus @affine/electron @affine/monorepo - hard-link-nm: false - build-plugins: false - nmHoistingLimits: workspaces - - name: Build AFFiNE native - uses: ./.github/actions/build-rust - with: - target: ${{ matrix.spec.target }} - package: '@affine/native' - nx_token: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }} - - name: Replace Version - run: ./scripts/set-version.sh ${{ needs.set-build-version.outputs.version }} - - uses: actions/download-artifact@v3 - with: - name: core - path: packages/frontend/electron/resources/web-static - - - name: Build Plugins - run: yarn run build:plugins - - - name: Build Desktop Layers - run: yarn workspace @affine/electron build - - - name: Signing By Apple Developer ID - if: ${{ matrix.spec.platform == 'darwin' }} - uses: apple-actions/import-codesign-certs@v2 - with: - p12-file-base64: ${{ secrets.CERTIFICATES_P12 }} - p12-password: ${{ secrets.CERTIFICATES_P12_PASSWORD }} - - - name: make - run: yarn workspace @affine/electron make --platform=${{ matrix.spec.platform }} --arch=${{ matrix.spec.arch }} - env: - SKIP_PLUGIN_BUILD: 1 - SKIP_WEB_BUILD: 1 - HOIST_NODE_MODULES: 1 - - - name: Save artifacts (mac) - if: ${{ matrix.spec.platform == 'darwin' }} - run: | - mkdir -p builds - mv packages/frontend/electron/out/*/make/*.dmg ./builds/affine-${{ env.BUILD_TYPE }}-macos-${{ matrix.spec.arch }}.dmg - mv packages/frontend/electron/out/*/make/zip/darwin/${{ matrix.spec.arch }}/*.zip ./builds/affine-${{ env.BUILD_TYPE }}-macos-${{ matrix.spec.arch }}.zip - - name: Save artifacts (windows) - if: ${{ matrix.spec.platform == 'win32' }} - run: | - mkdir -p builds - mv packages/frontend/electron/out/*/make/zip/win32/x64/AFFiNE*-win32-x64-*.zip ./builds/affine-${{ env.BUILD_TYPE }}-windows-x64.zip - mv packages/frontend/electron/out/*/make/squirrel.windows/x64/*.exe ./builds/affine-${{ env.BUILD_TYPE }}-windows-x64.exe - mv packages/frontend/electron/out/*/make/squirrel.windows/x64/*.msi ./builds/affine-${{ env.BUILD_TYPE }}-windows-x64.msi - mv packages/frontend/electron/out/*/make/squirrel.windows/x64/*.nupkg ./builds/affine-${{ env.BUILD_TYPE }}-windows-x64.nupkg - - - name: Save artifacts (linux) - if: ${{ matrix.spec.platform == 'linux' }} - run: | - mkdir -p builds - mv packages/frontend/electron/out/*/make/zip/linux/x64/*.zip ./builds/affine-${{ env.BUILD_TYPE }}-linux-x64.zip - mv packages/frontend/electron/out/*/make/AppImage/x64/*.AppImage ./builds/affine-${{ env.BUILD_TYPE }}-linux-x64.AppImage - - - name: Upload Artifact - uses: actions/upload-artifact@v3 - with: - name: affine-${{ matrix.spec.platform }}-${{ matrix.spec.arch }}-builds - path: builds - - release: - needs: - - make-distribution - - set-build-version - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - name: Download Artifacts (macos-x64) - uses: actions/download-artifact@v3 - with: - name: affine-darwin-x64-builds - path: ./ - - name: Download Artifacts (macos-arm64) - uses: actions/download-artifact@v3 - with: - name: affine-darwin-arm64-builds - path: ./ - - name: Download Artifacts (windows-x64) - uses: actions/download-artifact@v3 - with: - name: affine-win32-x64-builds - path: ./ - - name: Download Artifacts (linux-x64) - uses: actions/download-artifact@v3 - with: - name: affine-linux-x64-builds - path: ./ - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: 18 - - name: Generate Release yml - run: | - node ./packages/frontend/electron/scripts/generate-yml.js - env: - RELEASE_VERSION: ${{ needs.set-build-version.outputs.version }} - - name: Generate SHA512 checksums - run: | - sha512sum *-linux-* > SHA512SUMS.txt - sha512sum *-macos-* >> SHA512SUMS.txt - sha512sum *-windows-* >> SHA512SUMS.txt - - name: Create Release Draft - uses: softprops/action-gh-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} - with: - repository: 'toeverything/AFFiNE-Releases' - name: ${{ needs.set-build-version.outputs.version }} - tag_name: ${{ needs.set-build-version.outputs.version }} - prerelease: true - files: | - ./SHA512SUMS.txt - ./VERSION - ./*.zip - ./*.dmg - ./*.exe - ./*.nupkg - ./RELEASES - ./*.AppImage - ./*.apk - ./*.yml diff --git a/.github/workflows/release-desktop.yml b/.github/workflows/release-desktop.yml index 7dc9755ab8..45d1593c4b 100644 --- a/.github/workflows/release-desktop.yml +++ b/.github/workflows/release-desktop.yml @@ -43,6 +43,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Setup Version + id: version uses: ./.github/actions/setup-version - name: Setup Node.js uses: ./.github/actions/setup-node diff --git a/packages/frontend/electron/scripts/generate-assets.ts b/packages/frontend/electron/scripts/generate-assets.ts index 0284274d21..3b7de92dda 100755 --- a/packages/frontend/electron/scripts/generate-assets.ts +++ b/packages/frontend/electron/scripts/generate-assets.ts @@ -17,13 +17,14 @@ const affineCoreOutDir = path.join(affineCoreDir, 'dist'); const publicAffineOutDir = path.join(publicDistDir, `web-static`); const releaseVersionEnv = process.env.RELEASE_VERSION || ''; -console.log('build with following dir', { +console.log('build with following variables', { repoRootDir, electronRootDir, publicDistDir, affineSrcDir: affineCoreDir, affineSrcOutDir: affineCoreOutDir, publicAffineOutDir, + releaseVersionEnv, }); // step 0: check version match