From 08c4535308b842d072717d61b02fda47725a029f Mon Sep 17 00:00:00 2001 From: Antonis Stamatiou Date: Mon, 13 Mar 2023 18:16:29 +0200 Subject: [PATCH] Replace release creation with gh CLI (#2608) * replace release creation with gh CLI * Create nightly builds abstraction with tag creation * Enable also workflow dispatch for main nighlty build --- .github/workflows/nightly-browser-view.yml | 36 ++++++++++++------- .github/workflows/nightly-rainforest.yml | 26 +++++++++----- .github/workflows/nightly.yaml | 42 ++++++++++++++++++++++ .github/workflows/release.yaml | 16 +++------ 4 files changed, 88 insertions(+), 32 deletions(-) create mode 100644 .github/workflows/nightly.yaml diff --git a/.github/workflows/nightly-browser-view.yml b/.github/workflows/nightly-browser-view.yml index b53a5e5a..99981192 100644 --- a/.github/workflows/nightly-browser-view.yml +++ b/.github/workflows/nightly-browser-view.yml @@ -1,9 +1,18 @@ name: nightly-browser-view on: + workflow_call: + inputs: + tag: + description: "Reference tag of the nightly build" + required: true + type: string workflow_dispatch: - schedule: - - cron: 0 4 * * 0-5 + inputs: + tag: + description: "Reference tag of the nightly build" + required: true + type: string defaults: run: @@ -12,6 +21,7 @@ defaults: env: TERM: xterm MM_WIN_INSTALLERS: 1 + REFERENCE: ${{ inputs.tag }} jobs: build-linux: @@ -19,14 +29,14 @@ jobs: steps: - name: ci/checkout-repo uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + with: + ref: ${{ env.REFERENCE }} - name: ci/setup-node uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 with: node-version-file: "package.json" cache: "npm" cache-dependency-path: package-lock.json - - name: nightly/patch-version - uses: ./.github/actions/patch-nightly-version - name: ci/install-dependencies env: PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1 @@ -53,14 +63,14 @@ jobs: steps: - name: nightly/checkout-repo uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + with: + ref: ${{ env.REFERENCE }} - name: nightly/setup-node uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 with: node-version-file: "package.json" cache: "npm" cache-dependency-path: package-lock.json - - name: nightly/patch-version - uses: ./.github/actions/patch-nightly-version - name: nightly/optimize shell: powershell run: ./scripts/Makefile.ps1 optimize @@ -109,14 +119,14 @@ jobs: steps: - name: nightly/checkout-repo uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + with: + ref: ${{ env.REFERENCE }} - name: nightly/setup-node uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 with: node-version-file: "package.json" cache: "npm" cache-dependency-path: package-lock.json - - name: nightly/patch-version - uses: ./.github/actions/patch-nightly-version - name: nightly/install-dependencies run: | brew install yq @@ -139,14 +149,14 @@ jobs: steps: - name: nightly/checkout-repo uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + with: + ref: ${{ env.REFERENCE }} - name: nightly/setup-node uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 with: node-version-file: "package.json" cache: "npm" cache-dependency-path: package-lock.json - - name: nightly/patch-version - uses: ./.github/actions/patch-nightly-version - name: nightly/install-dependencies run: | brew install yq rename @@ -185,8 +195,8 @@ jobs: steps: - name: nightly/checkout-repo uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 - - name: nightly/patch-version - uses: ./.github/actions/patch-nightly-version + with: + ref: ${{ env.REFERENCE }} - name: nightly/setup-aws-credentials uses: aws-actions/configure-aws-credentials@67fbcbb121271f7775d2e7715933280b06314838 # v1.7.0 with: @@ -232,4 +242,4 @@ jobs: --arg username "NightBuilder" \ --arg text "${{ needs.upload-to-s3.outputs.links }}" \ '{"username":$username,"icon_url": $icon_url, "text": $text }' > /tmp/webhook-data.json - curl -i -X POST -H "Content-Type: application/json" -d @/tmp/webhook-data.json ${{ secrets.MM_DESKTOP_NIGHTLY_WEBHOOK_URL }} || echo "NOFICATION FAILED! check logs as this will succeed intentionally" + curl -i -X POST -H "Content-Type: application/json" -d @/tmp/webhook-data.json ${{ secrets.MM_DESKTOP_NIGHTLY_WEBHOOK_URL }} diff --git a/.github/workflows/nightly-rainforest.yml b/.github/workflows/nightly-rainforest.yml index 81030c90..1a510746 100644 --- a/.github/workflows/nightly-rainforest.yml +++ b/.github/workflows/nightly-rainforest.yml @@ -1,9 +1,18 @@ name: nightly-rainforest on: + workflow_call: + inputs: + tag: + description: "Reference tag of the nightly build" + required: true + type: string workflow_dispatch: - schedule: - - cron: 0 4 * * 0-5 + inputs: + tag: + description: "Reference tag of the nightly build" + required: true + type: string defaults: run: @@ -14,6 +23,7 @@ env: MM_DESKTOP_BUILD_DISABLEGPU: true MM_DESKTOP_BUILD_SKIPONBOARDINGSCREENS: true MM_WIN_INSTALLERS: 1 + REFERENCE: ${{ inputs.tag }} jobs: build-msi-installer: @@ -21,14 +31,14 @@ jobs: steps: - name: nightly/checkout-repo uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + with: + ref: ${{ env.REFERENCE }} - name: nightly/setup-node uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 with: node-version-file: "package.json" cache: "npm" cache-dependency-path: package-lock.json - - name: nightly/patch-version - uses: ./.github/actions/patch-nightly-version - name: nightly/optimize shell: powershell run: ./scripts/Makefile.ps1 optimize @@ -69,14 +79,14 @@ jobs: steps: - name: nightly/checkout-repo uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + with: + ref: ${{ env.REFERENCE }} - name: nightly/setup-node uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 with: node-version-file: "package.json" cache: "npm" cache-dependency-path: package-lock.json - - name: nightly/patch-version - uses: ./.github/actions/patch-nightly-version - name: nightly/install-dependencies run: | brew install yq rename @@ -112,8 +122,8 @@ jobs: steps: - name: nightly/checkout-repo uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 - - name: nightly/patch-version - uses: ./.github/actions/patch-nightly-version + with: + ref: ${{ env.REFERENCE }} - name: nightly/setup-aws-credentials uses: aws-actions/configure-aws-credentials@67fbcbb121271f7775d2e7715933280b06314838 # v1.7.0 with: diff --git a/.github/workflows/nightly.yaml b/.github/workflows/nightly.yaml new file mode 100644 index 00000000..637f2d1e --- /dev/null +++ b/.github/workflows/nightly.yaml @@ -0,0 +1,42 @@ +name: nightly-builds + +on: + workflow_dispatch: + schedule: + - cron: 0 4 * * 0-5 + +jobs: + tag-nightly-build: + runs-on: ubuntu-22.04 + outputs: + tag: ${{ steps.tag-creation.outputs.tag }} + steps: + - name: nightly/checkout-repo + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - name: nightly/patch-version + uses: ./.github/actions/patch-nightly-version + - name: nightly/create-nightly-build-tag + id: tag-creation + run: | + git config --global user.email "nightly-build@mattermost.com" + git config --global user.name "Nightly Build" + git checkout -b "$(jq -r .version package.json)" + git add package.json + git commit -m "Nightly build $(jq -r .version package.json)" + git tag "$(jq -r .version package.json)" -m "Nightly build $(jq -r .version package.json)" + git push --tags --force + echo "tag=$(jq -r .version package.json)" >> $GITHUB_OUTPUT + + nightly-browser-view: + needs: + - tag-nightly-build + uses: ./.github/workflows/nightly-browser-view.yml + with: + tag: ${{ needs.tag-nightly-build.outputs.tag }} + + nightly-rainforest: + needs: + - tag-nightly-build + uses: ./.github/workflows/nightly-rainforest.yml + with: + tag: ${{ needs.tag-nightly-build.outputs.tag }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 9291e3c9..dc8b548f 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -228,20 +228,14 @@ jobs: mkdir -p ./ghr-dist find ./build/{macos-release,win-release,linux} -type f -exec cp --backup=numbered -t ./ghr-dist {} + - name: release/publish-release + env: + GITHUB_TOKEN: ${{ secrets.MATTERMOST_BUILD_GH_TOKEN }} run: | - go install github.com/tcnksm/ghr@latest VERSION=$(jq -r .version package.json) + ./scripts/generate_release_markdown.sh ${VERSION} > release-notes.md RELEASE_TITLE="v${VERSION} ($(date -u "+%Y-%m-%d"))" - ghr \ - -t ${GITHUB_TOKEN} \ - -u ${GITHUB_ACTOR} \ - -draft \ - --body="$(./scripts/generate_release_markdown.sh $VERSION)" \ - --name="${RELEASE_TITLE}" $( [[ $VERSION =~ "-rc" ]] && printf %s "-prerelease") \ - -r ${GITHUB_REPOSITORY} \ - -c ${GITHUB_SHA} \ - -delete \ - v${VERSION} ./ghr-dist + [[ $VERSION =~ "-rc" ]] && PRERELEASE="--prerelease" + gh release create --draft ${PRERELEASE} --verify-tag -F release-notes.md --target "${GITHUB_SHA}" --title "${RELEASE_TITLE}" "${GITHUB_REF_NAME}" ./ghr-dist/* end-notification: runs-on: ubuntu-22.04