Explorar o código

Merge pull request #10603 from id/ci-enable-scheduled-builds-on-release-50

ci: move scheduled builds to a separate workflow
Ivan Dyachkov %!s(int64=2) %!d(string=hai) anos
pai
achega
ee8aa4feae

+ 1 - 28
.github/workflows/build_packages.yaml

@@ -5,8 +5,6 @@ concurrency:
   cancel-in-progress: true
   cancel-in-progress: true
 
 
 on:
 on:
-  schedule:
-  - cron:  '0 */6 * * *'
   push:
   push:
     branches:
     branches:
     - 'ci/**'
     - 'ci/**'
@@ -23,7 +21,6 @@ on:
 jobs:
 jobs:
   prepare:
   prepare:
     runs-on: ubuntu-22.04
     runs-on: ubuntu-22.04
-    if: (github.repository_owner == 'emqx' && github.event_name == 'schedule') || github.event_name != 'schedule'
     container: ghcr.io/emqx/emqx-builder/5.0-34:1.13.4-24.3.4.2-3-ubuntu22.04
     container: ghcr.io/emqx/emqx-builder/5.0-34:1.13.4-24.3.4.2-3-ubuntu22.04
     outputs:
     outputs:
       BUILD_PROFILE: ${{ steps.get_profile.outputs.BUILD_PROFILE }}
       BUILD_PROFILE: ${{ steps.get_profile.outputs.BUILD_PROFILE }}
@@ -134,14 +131,6 @@ jobs:
       with:
       with:
         name: ${{ matrix.profile }}
         name: ${{ matrix.profile }}
         path: source/_packages/${{ matrix.profile }}/
         path: source/_packages/${{ matrix.profile }}/
-    - name: Send notification to Slack
-      uses: slackapi/slack-github-action@v1.23.0
-      if: failure() && github.event_name == 'schedule'
-      env:
-        SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
-      with:
-        payload: |
-          {"text": "Scheduled run of ${{ github.workflow }}@Windows failed: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"}
 
 
   mac:
   mac:
     needs: prepare
     needs: prepare
@@ -182,14 +171,6 @@ jobs:
       with:
       with:
         name: ${{ matrix.profile }}
         name: ${{ matrix.profile }}
         path: _packages/${{ matrix.profile }}/
         path: _packages/${{ matrix.profile }}/
-    - name: Send notification to Slack
-      uses: slackapi/slack-github-action@v1.23.0
-      if: failure() && github.event_name == 'schedule'
-      env:
-        SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
-      with:
-        payload: |
-          {"text": "Scheduled run of ${{ github.workflow }}@${{ matrix.os }} failed: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"}
 
 
   linux:
   linux:
     needs: prepare
     needs: prepare
@@ -304,19 +285,11 @@ jobs:
       with:
       with:
         name: ${{ matrix.profile }}
         name: ${{ matrix.profile }}
         path: source/_packages/${{ matrix.profile }}/
         path: source/_packages/${{ matrix.profile }}/
-    - name: Send notification to Slack
-      uses: slackapi/slack-github-action@v1.23.0
-      if: failure() && github.event_name == 'schedule'
-      env:
-        SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
-      with:
-        payload: |
-          {"text": "Scheduled run of ${{ github.workflow }}@${{ matrix.os }} failed: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"}
 
 
   publish_artifacts:
   publish_artifacts:
     runs-on: ubuntu-22.04
     runs-on: ubuntu-22.04
     needs: [prepare, mac, linux]
     needs: [prepare, mac, linux]
-    if: needs.prepare.outputs.IS_EXACT_TAG && github.event_name != 'schedule'
+    if: needs.prepare.outputs.IS_EXACT_TAG
     strategy:
     strategy:
       fail-fast: false
       fail-fast: false
       matrix:
       matrix:

+ 152 - 0
.github/workflows/build_packages_cron.yaml

@@ -0,0 +1,152 @@
+name: Scheduled build packages
+
+concurrency:
+  group: build-${{ github.event_name }}-${{ github.ref }}
+  cancel-in-progress: true
+
+on:
+  schedule:
+    - cron:  '0 */6 * * *'
+
+  prepare:
+    runs-on: aws-amd64
+    if: github.repository_owner == 'emqx'
+    container: ghcr.io/emqx/emqx-builder/5.0-34:1.13.4-24.3.4.2-3-ubuntu22.04
+    strategy:
+      fail-fast: false
+      matrix:
+        profile:
+          - ['emqx', 'master']
+          - ['emqx-enterprise', 'release-50']
+
+    steps:
+      - uses: actions/checkout@v3
+        with:
+          ref: ${{ matrix.profile[1] }}
+          path: source
+          fetch-depth: 0
+      - name: get_all_deps
+        run: |
+          make -C source deps-all
+          zip -ryq source.zip source/* source/.[^.]*
+      - uses: actions/upload-artifact@v3
+        with:
+          name: source-${{ matrix.profile[1] }}
+          path: source.zip
+
+  linux:
+    needs: prepare
+    runs-on: aws-${{ matrix.arch }}
+
+    strategy:
+      fail-fast: false
+      matrix:
+        profile:
+          - emqx
+          - emqx-enterprise
+        otp:
+          - 24.3.4.2-3
+        arch:
+          - amd64
+        os:
+          - debian10
+          - amzn2
+        builder:
+          - 5.0-34
+        elixir:
+          - 1.13.4
+
+    defaults:
+      run:
+        shell: bash
+
+    steps:
+      - uses: AutoModality/action-clean@v1
+      - uses: actions/download-artifact@v3
+        with:
+          name: source-${{ matrix.profile }}
+          path: .
+      - name: unzip source code
+        run: unzip -q source.zip
+      - name: build emqx packages
+        working-directory: source
+        env:
+          BUILDER: ${{ matrix.builder }}
+          ELIXIR: ${{ matrix.elixir }}
+          OTP: ${{ matrix.otp }}
+          PROFILE: ${{ matrix.profile[0] }}
+          ARCH: ${{ matrix.arch }}
+          OS: ${{ matrix.os }}
+        run: |
+          set -eu
+          PKGTYPES="tgz pkg"
+          IS_ELIXIR="no"
+          for PKGTYPE in ${PKGTYPES};
+          do
+            ./scripts/buildx.sh \
+              --profile "${PROFILE}" \
+              --pkgtype "${PKGTYPE}" \
+              --arch "${ARCH}" \
+              --elixir "${IS_ELIXIR}" \
+              --builder "ghcr.io/emqx/emqx-builder/${BUILDER}:${ELIXIR}-${OTP}-${OS}
+          done
+      - uses: actions/upload-artifact@v3
+        if: success()
+        with:
+          name: ${{ matrix.profile }}
+          path: source/_packages/${{ matrix.profile }}/
+      - name: Send notification to Slack
+        uses: slackapi/slack-github-action@v1.23.0
+        if: failure()
+        env:
+          SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
+        with:
+          payload: |
+            {"text": "Scheduled build of ${{ matrix.profile }} package for ${{ matrix.os }} failed: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"}
+
+  mac:
+    needs: prepare
+    strategy:
+      fail-fast: false
+      matrix:
+        profile:
+          - emqx
+        otp:
+          - 24.3.4.2-3
+        os:
+          - macos-12
+          - macos-12-arm64
+    runs-on: ${{ matrix.os }}
+    steps:
+      - uses: emqx/self-hosted-cleanup-action@v1.0.3
+      - uses: actions/download-artifact@v3
+        with:
+          name: source-${{ matrix.profile }}
+          path: .
+      - name: unzip source code
+        run: |
+          ln -s . source
+          unzip -o -q source.zip
+          rm source source.zip
+      - uses: ./.github/actions/package-macos
+        with:
+          profile: ${{ matrix.profile }}
+          otp: ${{ matrix.otp }}
+          os: ${{ matrix.os }}
+          apple_id_password: ${{ secrets.APPLE_ID_PASSWORD }}
+          apple_developer_identity: ${{ secrets.APPLE_DEVELOPER_IDENTITY }}
+          apple_developer_id_bundle: ${{ secrets.APPLE_DEVELOPER_ID_BUNDLE }}
+          apple_developer_id_bundle_password: ${{ secrets.APPLE_DEVELOPER_ID_BUNDLE_PASSWORD }}
+      - uses: actions/upload-artifact@v3
+        if: success()
+        with:
+          name: ${{ matrix.profile }}
+          path: _packages/${{ matrix.profile }}/
+      - name: Send notification to Slack
+        uses: slackapi/slack-github-action@v1.23.0
+        if: failure()
+        env:
+          SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
+        with:
+          payload: |
+            {"text": "Scheduled build of ${{ matrix.profile }} package for ${{ matrix.os }} failed: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"}