From 2d62ec72a70135b7906c91fcba1e7f949109044c Mon Sep 17 00:00:00 2001 From: LongYinan Date: Wed, 1 Nov 2023 15:38:15 +0800 Subject: [PATCH] ci: dynamic setup server deploy environment by release tag (#4790) --- .github/workflows/build-desktop.yml | 3 --- .github/workflows/build-server.yml | 4 --- .github/workflows/build.yml | 5 ---- .github/workflows/deploy.yml | 7 +----- .github/workflows/dispatch-deploy.yml | 30 +++++++++++++++++++++++ .github/workflows/nightly-build.yml | 3 --- .github/workflows/publish-storybook.yml | 1 - .github/workflows/release-desktop-app.yml | 5 ---- 8 files changed, 31 insertions(+), 27 deletions(-) create mode 100644 .github/workflows/dispatch-deploy.yml diff --git a/.github/workflows/build-desktop.yml b/.github/workflows/build-desktop.yml index 4d0eaaa23..6c701f570 100644 --- a/.github/workflows/build-desktop.yml +++ b/.github/workflows/build-desktop.yml @@ -38,7 +38,6 @@ jobs: build-core: name: Build @affine/core runs-on: ubuntu-latest - environment: development steps: - uses: actions/checkout@v4 @@ -58,7 +57,6 @@ jobs: build-native: name: Build Native runs-on: ubuntu-latest - environment: development needs: build-core steps: - uses: actions/checkout@v4 @@ -77,7 +75,6 @@ jobs: desktop-test: name: Desktop Test runs-on: ${{ matrix.spec.os }} - environment: development strategy: fail-fast: false # all combinations: macos-latest x64, macos-latest arm64, windows-latest x64, ubuntu-latest x64 diff --git a/.github/workflows/build-server.yml b/.github/workflows/build-server.yml index 9d8462182..d444a4dd4 100644 --- a/.github/workflows/build-server.yml +++ b/.github/workflows/build-server.yml @@ -39,7 +39,6 @@ jobs: runs-on: ubuntu-latest env: RUSTFLAGS: '-C debuginfo=1' - environment: development steps: - uses: actions/checkout@v4 @@ -66,7 +65,6 @@ jobs: server-test: name: Server Test runs-on: ubuntu-latest - environment: development needs: build-storage services: postgres: @@ -137,7 +135,6 @@ jobs: server-e2e-test: name: Server E2E Test runs-on: ubuntu-latest - environment: development needs: build-storage services: postgres: @@ -219,7 +216,6 @@ jobs: server-desktop-e2e-test: name: Server Desktop E2E Test runs-on: ubuntu-latest - environment: development needs: build-storage services: postgres: diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e3a3ac28e..bf200a6a5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -39,7 +39,6 @@ jobs: lint: name: Lint runs-on: ubuntu-latest - environment: development steps: - uses: actions/checkout@v4 @@ -75,7 +74,6 @@ jobs: e2e-plugin-test: name: E2E Plugin Test runs-on: ubuntu-latest - environment: development steps: - uses: actions/checkout@v4 - name: Setup Node.js @@ -115,7 +113,6 @@ jobs: fail-fast: false matrix: shard: [1, 2, 3, 4, 5] - environment: development steps: - uses: actions/checkout@v4 - name: Setup Node.js @@ -153,7 +150,6 @@ jobs: e2e-migration-test: name: E2E Migration Test runs-on: ubuntu-latest - environment: development steps: - uses: actions/checkout@v4 - name: Setup Node.js @@ -176,7 +172,6 @@ jobs: unit-test: name: Unit Test runs-on: ubuntu-latest - environment: development steps: - uses: actions/checkout@v4 - name: Setup Node.js diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 01bdefef7..ce0874e73 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,11 +1,6 @@ name: Deploy on: - push: - branches: - - master - tags: - - 'v[0-9]+.[0-9]+.[0-9]+-canary.[0-9]+' workflow_dispatch: inputs: flavor: @@ -200,7 +195,7 @@ jobs: deploy: name: Deploy to cluster - if: ${{ github.event_name == 'workflow_dispatch' || github.ref_type == 'tag' }} + if: ${{ github.event_name == 'workflow_dispatch' }} environment: ${{ github.event.inputs.flavor }} permissions: contents: 'write' diff --git a/.github/workflows/dispatch-deploy.yml b/.github/workflows/dispatch-deploy.yml new file mode 100644 index 000000000..fa58a0a67 --- /dev/null +++ b/.github/workflows/dispatch-deploy.yml @@ -0,0 +1,30 @@ +name: Dispatch Deploy by tag + +on: + push: + tags: + - 'v[0-9]+.[0-9]+.[0-9]+-canary.[0-9]+' + +jobs: + dispatch-deploy-by-tag: + runs-on: ubuntu-latest + name: Setup deploy environment + steps: + - uses: actions/checkout@v4 + - name: Setup Node.js + uses: ./.github/actions/setup-node + with: + extra-flags: 'workspaces focus @affine/monorepo' + hard-link-nm: false + electron-install: false + build-infra: false + build-plugins: false + - name: Setup output value + id: flavor + run: | + node -e "const env = require('semver').parse('${{ github.ref_name }}').prerelease[0] ?? 'stable'; console.log(`flavor=${env}`)" >> "$GITHUB_OUTPUT" + - name: dispatch deploy + uses: benc-uk/workflow-dispatch@v1 + with: + workflow: deploy.yml + inputs: '{ "flavor": "${{ steps.flavor.outputs.flavor }}" }' diff --git a/.github/workflows/nightly-build.yml b/.github/workflows/nightly-build.yml index c08dc1c3c..dbf29c997 100644 --- a/.github/workflows/nightly-build.yml +++ b/.github/workflows/nightly-build.yml @@ -44,7 +44,6 @@ env: jobs: set-build-version: runs-on: ubuntu-latest - environment: production outputs: version: 0.0.0-internal.${{ steps.version.outputs.version }} steps: @@ -55,7 +54,6 @@ jobs: before-make: runs-on: ubuntu-latest - environment: production needs: - set-build-version steps: @@ -83,7 +81,6 @@ jobs: path: packages/frontend/electron/resources/web-static make-distribution: - environment: production strategy: # all combinations: macos-latest x64, macos-latest arm64, ubuntu-latest x64 # For windows, we need a separate approach diff --git a/.github/workflows/publish-storybook.yml b/.github/workflows/publish-storybook.yml index ace6dbc9a..ca8745ab6 100644 --- a/.github/workflows/publish-storybook.yml +++ b/.github/workflows/publish-storybook.yml @@ -22,7 +22,6 @@ jobs: publish-storybook: name: Publish Storybook runs-on: ubuntu-latest - environment: development steps: - uses: actions/checkout@v4 with: diff --git a/.github/workflows/release-desktop-app.yml b/.github/workflows/release-desktop-app.yml index c231b260c..6308a7fe0 100644 --- a/.github/workflows/release-desktop-app.yml +++ b/.github/workflows/release-desktop-app.yml @@ -40,7 +40,6 @@ env: jobs: before-make: runs-on: ubuntu-latest - environment: production outputs: RELEASE_VERSION: ${{ steps.get-canary-version.outputs.RELEASE_VERSION }} steps: @@ -76,7 +75,6 @@ jobs: path: packages/frontend/electron/resources/web-static make-distribution: - environment: production strategy: # all combinations: macos-latest x64, macos-latest arm64, ubuntu-latest x64 # For windows, we need a separate approach @@ -159,7 +157,6 @@ jobs: path: builds package-distribution-windows: - environment: production strategy: # all combinations: macos-latest x64, macos-latest arm64, ubuntu-latest x64 # For windows, we need a separate approach @@ -235,7 +232,6 @@ jobs: artifact-name: packaged-win32-x64 make-windows-installer: - environment: production needs: sign-packaged-artifacts-windows strategy: # all combinations: macos-latest x64, macos-latest arm64, ubuntu-latest x64 @@ -289,7 +285,6 @@ jobs: artifact-name: installer-win32-x64 finalize-installer-windows: - environment: production needs: sign-installer-artifacts-windows strategy: # all combinations: macos-latest x64, macos-latest arm64, ubuntu-latest x64