From 9d50d5e99daba597028b1ab7d20223cd806c0682 Mon Sep 17 00:00:00 2001 From: zhanghongtong Date: Wed, 23 Feb 2022 17:15:35 +0800 Subject: [PATCH 1/3] ci(cross build): splitting cross builds and upload assets --- .github/workflows/build_packages.yaml | 102 ++++----------------- .github/workflows/build_slim_packages.yaml | 4 - .github/workflows/release.yaml | 96 +++++++++++++++++++ 3 files changed, 113 insertions(+), 89 deletions(-) create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/build_packages.yaml b/.github/workflows/build_packages.yaml index 94bfccb22..8315ae834 100644 --- a/.github/workflows/build_packages.yaml +++ b/.github/workflows/build_packages.yaml @@ -7,9 +7,10 @@ concurrency: on: schedule: - cron: '0 */6 * * *' - release: - types: - - published + push: + tags: + - v* + - e* workflow_dispatch: jobs: @@ -424,14 +425,6 @@ jobs: file: source/deploy/docker/Dockerfile.enterprise context: source - delete-artifact: - runs-on: ubuntu-20.04 - needs: [prepare, mac, linux, docker] - steps: - - uses: geekyeggo/delete-artifact@v1 - with: - name: source - upload: runs-on: ubuntu-20.04 @@ -450,12 +443,6 @@ jobs: otp: windows # otp version on windows is rather fixed steps: - - uses: actions/checkout@v2 - - name: get_version - run: | - echo 'version<> $GITHUB_ENV - echo ${{ github.ref }} | sed -r "s ^refs/heads/|^refs/tags/(.*) \1 g" >> $GITHUB_ENV - echo 'EOF' >> $GITHUB_ENV - uses: actions/download-artifact@v2 with: name: ${{ matrix.profile }}-${{ matrix.otp }} @@ -471,72 +458,17 @@ jobs: echo "$(cat $var.sha256) $var" | sha256sum -c || exit 1 done cd - + - uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.AWS_DEFAULT_REGION }} - name: upload aws s3 - run: | - set -e -u - if [ "${{ matrix.profile }}" == "emqx" ];then - broker="emqx-ce" - else - broker=${{ matrix.profile }} - fi - aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY_ID }} - aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws configure set default.region ${{ secrets.AWS_DEFAULT_REGION }} - - aws s3 cp --recursive _packages/${{ matrix.profile }} s3://${{ secrets.AWS_S3_BUCKET }}/$broker/${{ env.version }} - aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT_ID }} --paths "/$broker/${{ env.version }}/*" - - uses: Rory-Z/upload-release-asset@v1 - if: github.event_name == 'release' && matrix.profile != 'emqx-ee' - with: - repo: emqx - path: "_packages/${{ matrix.profile }}/emqx-*" - token: ${{ github.token }} - - uses: Rory-Z/upload-release-asset@v1 - if: github.event_name == 'release' && matrix.profile == 'emqx-ee' - with: - repo: emqx-enterprise - path: "_packages/${{ matrix.profile }}/emqx-*" - token: ${{ github.token }} - - name: update to emqx.io - if: github.event_name == 'release' - run: | - set -e -x -u - curl -w %{http_code} \ - --insecure \ - -H "Content-Type: application/json" \ - -H "token: ${{ secrets.EMQX_IO_TOKEN }}" \ - -X POST \ - -d "{\"repo\":\"emqx/emqx\", \"tag\": \"${{ env.version }}\" }" \ - ${{ secrets.EMQX_IO_RELEASE_API }} - - name: update repo.emqx.io - if: github.event_name == 'release' && matrix.profile == 'emqx-ee' - run: | - curl --silent --show-error \ - -H "Authorization: token ${{ secrets.CI_GIT_TOKEN }}" \ - -H "Accept: application/vnd.github.v3+json" \ - -X POST \ - -d "{\"ref\":\"v1.0.4\",\"inputs\":{\"version\": \"${{ env.version }}\", \"emqx_ee\": \"true\"}}" \ - "https://api.github.com/repos/emqx/emqx-ci-helper/actions/workflows/update_emqx_repos.yaml/dispatches" - - name: update repo.emqx.io - if: github.event_name == 'release' && matrix.profile == 'emqx' - run: | - curl --silent --show-error \ - -H "Authorization: token ${{ secrets.CI_GIT_TOKEN }}" \ - -H "Accept: application/vnd.github.v3+json" \ - -X POST \ - -d "{\"ref\":\"v1.0.4\",\"inputs\":{\"version\": \"${{ env.version }}\", \"emqx_ce\": \"true\"}}" \ - "https://api.github.com/repos/emqx/emqx-ci-helper/actions/workflows/update_emqx_repos.yaml/dispatches" - - name: update homebrew packages - if: github.event_name == 'release' && endsWith(github.repository, 'emqx') && matrix.profile == 'emqx' - run: | - if [ -z $(echo $version | grep -oE "(alpha|beta|rc)\.[0-9]") ]; then - curl --silent --show-error \ - -H "Authorization: token ${{ secrets.CI_GIT_TOKEN }}" \ - -H "Accept: application/vnd.github.v3+json" \ - -X POST \ - -d "{\"ref\":\"v1.0.4\",\"inputs\":{\"version\": \"${{ env.version }}\"}}" \ - "https://api.github.com/repos/emqx/emqx-ci-helper/actions/workflows/update_emqx_homebrew.yaml/dispatches" - fi - - uses: geekyeggo/delete-artifact@v1 - with: - name: ${{ matrix.profile }} + run: | + if [ "${{ matrix.profile }}" == "emqx" ];then + s3dir="emqx-ce" + else + s3dir=${{ matrix.profile }} + fi + aws s3 cp --recursive _packages/${{ matrix.profile }} s3://${{ secrets.AWS_S3_BUCKET }}/$s3dir/${{ github.ref_name }} + aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT_ID }} --paths "/$s3dir/${{ github.ref_name }}/*" \ No newline at end of file diff --git a/.github/workflows/build_slim_packages.yaml b/.github/workflows/build_slim_packages.yaml index 685dc3f94..fb6f130b7 100644 --- a/.github/workflows/build_slim_packages.yaml +++ b/.github/workflows/build_slim_packages.yaml @@ -6,10 +6,6 @@ concurrency: on: - push: - tags: - - v* - - e* pull_request: workflow_dispatch: diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 000000000..1d58fea86 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,96 @@ +name: Upload release assets +on: + release: + types: + - published + +jobs: + prepare: + runs-on: ubuntu-20.04 + container: emqx/build-env:erl23.2.7.2-emqx-3-ubuntu20.04 + + outputs: + profiles: ${{ steps.set_profile.outputs.profiles}} + + steps: + - uses: actions/checkout@v2 + with: + path: source + fetch-depth: 0 + - name: set profile + id: set_profile + shell: bash + run: | + cd source + if make emqx-ee --dry-run > /dev/null 2>&1; then + echo "::set-output name=profiles::[\"emqx-ee\"]" + else + echo "::set-output name=profiles::[\"emqx\", \"emqx-edge\"]" + fi + + upload: + runs-on: ubuntu-20.04 + needs: prepare + strategy: + fail-fast: false + matrix: + profile: ${{fromJSON(needs.prepare.outputs.profiles)}} + + steps: + - uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.AWS_DEFAULT_REGION }} + - name: Get packages + run: | + if [ "${{ matrix.profile }}" == "emqx" ];then + s3dir="emqx-ce" + else + s3dir=${{ matrix.profile }} + fi + aws s3 cp --recursive s3://${{ secrets.AWS_S3_BUCKET }}/$s3dir/${{ github.ref_name }} packages + - uses: alexellis/upload-assets@0.2.2 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + asset_paths: '["packages/*"]' + - name: update to emqx.io + run: | + set -e -x -u + curl -w %{http_code} \ + --insecure \ + -H "Content-Type: application/json" \ + -H "token: ${{ secrets.EMQX_IO_TOKEN }}" \ + -X POST \ + -d "{\"repo\":\"emqx/emqx\", \"tag\": \"${{ github.ref_name }}\" }" \ + ${{ secrets.EMQX_IO_RELEASE_API }} + - name: update repo.emqx.io + if: github.event_name == 'release' && endsWith(github.repository, 'enterprise') && matrix.profile == 'emqx-ee' + run: | + curl --silent --show-error \ + -H "Authorization: token ${{ secrets.CI_GIT_TOKEN }}" \ + -H "Accept: application/vnd.github.v3+json" \ + -X POST \ + -d "{\"ref\":\"v1.0.3\",\"inputs\":{\"version\": \"${{ github.ref_name }}\", \"emqx_ee\": \"true\"}}" \ + "https://api.github.com/repos/emqx/emqx-ci-helper/actions/workflows/update_emqx_repos.yaml/dispatches" + - name: update repo.emqx.io + if: github.event_name == 'release' && endsWith(github.repository, 'emqx') && matrix.profile == 'emqx' + run: | + curl --silent --show-error \ + -H "Authorization: token ${{ secrets.CI_GIT_TOKEN }}" \ + -H "Accept: application/vnd.github.v3+json" \ + -X POST \ + -d "{\"ref\":\"v1.0.3\",\"inputs\":{\"version\": \"${{ github.ref_name }}\", \"emqx_ce\": \"true\"}}" \ + "https://api.github.com/repos/emqx/emqx-ci-helper/actions/workflows/update_emqx_repos.yaml/dispatches" + - name: update homebrew packages + if: github.event_name == 'release' && endsWith(github.repository, 'emqx') && matrix.profile == 'emqx' + run: | + if [ -z $(echo $version | grep -oE "(alpha|beta|rc)\.[0-9]") ]; then + curl --silent --show-error \ + -H "Authorization: token ${{ secrets.CI_GIT_TOKEN }}" \ + -H "Accept: application/vnd.github.v3+json" \ + -X POST \ + -d "{\"ref\":\"v1.0.3\",\"inputs\":{\"version\": \"${{ github.ref_name }}\"}}" \ + "https://api.github.com/repos/emqx/emqx-ci-helper/actions/workflows/update_emqx_homebrew.yaml/dispatches" + fi \ No newline at end of file From 7d52bc3d3a23c3d63dc24897d819bfebcd3a72f2 Mon Sep 17 00:00:00 2001 From: zhanghongtong Date: Wed, 23 Feb 2022 18:29:49 +0800 Subject: [PATCH 2/3] ci(cross build): fix syntax error --- .github/workflows/build_packages.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build_packages.yaml b/.github/workflows/build_packages.yaml index 8315ae834..a2826708b 100644 --- a/.github/workflows/build_packages.yaml +++ b/.github/workflows/build_packages.yaml @@ -464,11 +464,11 @@ jobs: aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-region: ${{ secrets.AWS_DEFAULT_REGION }} - name: upload aws s3 - run: | - if [ "${{ matrix.profile }}" == "emqx" ];then - s3dir="emqx-ce" - else - s3dir=${{ matrix.profile }} - fi - aws s3 cp --recursive _packages/${{ matrix.profile }} s3://${{ secrets.AWS_S3_BUCKET }}/$s3dir/${{ github.ref_name }} - aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT_ID }} --paths "/$s3dir/${{ github.ref_name }}/*" \ No newline at end of file + run: | + if [ "${{ matrix.profile }}" == "emqx" ];then + s3dir="emqx-ce" + else + s3dir=${{ matrix.profile }} + fi + aws s3 cp --recursive _packages/${{ matrix.profile }} s3://${{ secrets.AWS_S3_BUCKET }}/$s3dir/${{ github.ref_name }} + aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT_ID }} --paths "/$s3dir/${{ github.ref_name }}/*" \ No newline at end of file From 2796113c20f3dc8b9b900414c9bfdb7579c33e30 Mon Sep 17 00:00:00 2001 From: zhanghongtong Date: Wed, 23 Feb 2022 20:03:33 +0800 Subject: [PATCH 3/3] ci(cross build): fix syntax error --- .github/workflows/build_packages.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_packages.yaml b/.github/workflows/build_packages.yaml index a2826708b..a873a56e7 100644 --- a/.github/workflows/build_packages.yaml +++ b/.github/workflows/build_packages.yaml @@ -470,5 +470,5 @@ jobs: else s3dir=${{ matrix.profile }} fi - aws s3 cp --recursive _packages/${{ matrix.profile }} s3://${{ secrets.AWS_S3_BUCKET }}/$s3dir/${{ github.ref_name }} - aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT_ID }} --paths "/$s3dir/${{ github.ref_name }}/*" \ No newline at end of file + aws s3 cp --recursive _packages/${{ matrix.profile }} s3://${{ secrets.AWS_S3_BUCKET }}/$s3dir/${{ github.ref_name }} + aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT_ID }} --paths "/$s3dir/${{ github.ref_name }}/*" \ No newline at end of file