From d54597e0d454edb3fd5ad11e12a490a7b0fe8951 Mon Sep 17 00:00:00 2001 From: Ivan Dyachkov Date: Wed, 16 Nov 2022 11:55:02 +0100 Subject: [PATCH 1/2] ci: fix version for push-helm-action --- .github/workflows/release.yaml | 57 ++++++++++++---------------------- 1 file changed, 20 insertions(+), 37 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 05dcb62e3..7c5bf94e4 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -15,22 +15,34 @@ jobs: 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 + - uses: actions/checkout@v3 + with: + ref: ${{ github.ref }} + - name: Detect profile + id: profile run: | REF=${{ github.ref_name }} case "$REF" in v*) - s3dir='emqx-ce' + echo "profile=emqx" >> $GITHUB_OUTPUT + echo "s3dir=emqx-ce" >> $GITHUB_OUTPUT + echo "version=$(./pkg-vsn.sh emqx)" >> $GITHUB_OUTPUT ;; e*) - s3dir='emqx-ee' + echo "profile=emqx-enterprise" >> $GITHUB_OUTPUT + echo "s3dir=emqx-ee" >> $GITHUB_OUTPUT + echo "version=$(./pkg-vsn.sh emqx-enterprise)" >> $GITHUB_OUTPUT ;; *) echo "tag $REF is not supported" exit 1 ;; esac - aws s3 cp --recursive s3://${{ secrets.AWS_S3_BUCKET }}/$s3dir/${{ github.ref_name }} packages + - name: Get packages + run: | + BUCKET=${{ secrets.AWS_S3_BUCKET }} + OUTPUT_DIR=${{ steps.profile.outputs.s3dir }} + aws s3 cp --recursive s3://$BUCKET/$OUTPUT_DIR/${{ github.ref_name }} packages cd packages DEFAULT_BEAM_PLATFORM='otp24.3.4.2-1' # all packages including full-name and default-name are uploaded to s3 @@ -58,18 +70,8 @@ jobs: -d "{\"repo\":\"emqx/emqx\", \"tag\": \"${{ github.ref_name }}\" }" \ ${{ secrets.EMQX_IO_RELEASE_API }} - name: update homebrew packages - if: github.event_name == 'release' + if: github.event_name == 'release' && startsWith(github.ref_name, 'v') run: | - REF=${{ github.ref_name }} - case "$REF" in - v*) - BOOL_FLAG_NAME="emqx_ce" - ;; - e*) - echo "Not updating homebrew for enterprise eidition" - exit 0 - ;; - esac if [ -z $(echo $version | grep -oE "(alpha|beta|rc)\.[0-9]") ]; then curl --silent --show-error \ -H "Authorization: token ${{ secrets.CI_GIT_TOKEN }}" \ @@ -78,30 +80,11 @@ jobs: -d "{\"ref\":\"v1.0.4\",\"inputs\":{\"version\": \"${{ github.ref_name }}\"}}" \ "https://api.github.com/repos/emqx/emqx-ci-helper/actions/workflows/update_emqx_homebrew.yaml/dispatches" fi - - upload-helm: - runs-on: ubuntu-20.04 - if: github.event_name == 'release' - strategy: - fail-fast: false - steps: - - uses: actions/checkout@v3 - with: - ref: ${{ github.ref }} - uses: emqx/push-helm-action@v1 - if: startsWith(github.ref_name, 'v') + if: github.event_name == 'release' with: - charts_dir: "${{ github.workspace }}/deploy/charts/emqx" - version: ${{ github.ref_name }} - aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws_region: "us-west-2" - aws_bucket_name: "repos-emqx-io" - - uses: emqx/push-helm-action@v1 - if: startsWith(github.ref_name, 'e') - with: - charts_dir: "${{ github.workspace }}/deploy/charts/emqx-enterprise" - version: ${{ github.ref_name }} + charts_dir: "${{ github.workspace }}/deploy/charts/${{ steps.profile.outputs.profile }}" + version: ${{ steps.profile.outputs.version }} aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws_region: "us-west-2" From 70c52f43cc82edb56a46cb8013fd6119c9b77b16 Mon Sep 17 00:00:00 2001 From: Ivan Dyachkov Date: Wed, 16 Nov 2022 14:28:47 +0100 Subject: [PATCH 2/2] ci: enable manual trigger on release workflow --- .github/workflows/release.yaml | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 7c5bf94e4..3a4f32499 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -3,6 +3,15 @@ on: release: types: - published + workflow_dispatch: + inputs: + tag: + type: string + required: true + publish_release_artefacts: + type: boolean + required: true + default: false jobs: upload: @@ -17,25 +26,26 @@ jobs: aws-region: ${{ secrets.AWS_DEFAULT_REGION }} - uses: actions/checkout@v3 with: - ref: ${{ github.ref }} + ref: ${{ github.event.inputs.tag }} - name: Detect profile id: profile run: | - REF=${{ github.ref_name }} + if git describe --tags --match '[v|e]*' --exact; then + REF=$(git describe --tags --match '[v|e]*' --exact) + else + echo "Only release tags matching '[v|e]*' are supported" + exit 1 + fi case "$REF" in v*) echo "profile=emqx" >> $GITHUB_OUTPUT - echo "s3dir=emqx-ce" >> $GITHUB_OUTPUT echo "version=$(./pkg-vsn.sh emqx)" >> $GITHUB_OUTPUT + echo "s3dir=emqx-ce" >> $GITHUB_OUTPUT ;; e*) echo "profile=emqx-enterprise" >> $GITHUB_OUTPUT - echo "s3dir=emqx-ee" >> $GITHUB_OUTPUT echo "version=$(./pkg-vsn.sh emqx-enterprise)" >> $GITHUB_OUTPUT - ;; - *) - echo "tag $REF is not supported" - exit 1 + echo "s3dir=emqx-ee" >> $GITHUB_OUTPUT ;; esac - name: Get packages @@ -59,7 +69,7 @@ jobs: with: asset_paths: '["packages/*"]' - name: update to emqx.io - if: github.event_name == 'release' + if: github.event_name == 'release' || inputs.publish_release_artefacts run: | set -e -x -u curl -w %{http_code} \ @@ -70,7 +80,7 @@ jobs: -d "{\"repo\":\"emqx/emqx\", \"tag\": \"${{ github.ref_name }}\" }" \ ${{ secrets.EMQX_IO_RELEASE_API }} - name: update homebrew packages - if: github.event_name == 'release' && startsWith(github.ref_name, 'v') + if: steps.profile.outputs.profile == 'emqx' && (github.event_name == 'release' || inputs.publish_release_artefacts) run: | if [ -z $(echo $version | grep -oE "(alpha|beta|rc)\.[0-9]") ]; then curl --silent --show-error \ @@ -81,7 +91,7 @@ jobs: "https://api.github.com/repos/emqx/emqx-ci-helper/actions/workflows/update_emqx_homebrew.yaml/dispatches" fi - uses: emqx/push-helm-action@v1 - if: github.event_name == 'release' + if: github.event_name == 'release' || inputs.publish_release_artefacts with: charts_dir: "${{ github.workspace }}/deploy/charts/${{ steps.profile.outputs.profile }}" version: ${{ steps.profile.outputs.version }}