From 740a856168da03386e9918afd7bcc2d39fd4479a Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Thu, 13 Mar 2025 02:16:18 +0100 Subject: [PATCH] git-artifacts: suggest to validate installer in a PR comment It is currently a bit cumbersome to find the download link to the installer artifact, and I even missed that it was available for testing already while the `aarch64` stuff was still being built. Let's imitate c99c7f2 (release-git(announcement): add a helpful comment, 2025-03-11) and add a helpful PR comment not only when the release finished, but also when the x86_64 installer was successfully uploaded and is ready for manual testing. Signed-off-by: Johannes Schindelin --- .github/workflows/git-artifacts.yml | 38 +++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/.github/workflows/git-artifacts.yml b/.github/workflows/git-artifacts.yml index f1cda22d..28bc5711 100644 --- a/.github/workflows/git-artifacts.yml +++ b/.github/workflows/git-artifacts.yml @@ -470,9 +470,47 @@ jobs: cp /usr/src/build-extra/mingit/root/etc/package-versions.txt artifacts/ - name: Publish ${{matrix.artifact.name}}-${{env.ARCHITECTURE}} uses: actions/upload-artifact@v4 + id: upload-artifact with: name: ${{matrix.artifact.name}}-${{env.ARCHITECTURE}} path: artifacts + - uses: actions/create-github-app-token@v1 + if: matrix.artifact.name == 'installer' && github.event.inputs.architecture == 'x86_64' + id: pr-comment-token + with: + app-id: ${{ secrets.GH_APP_ID }} + private-key: ${{ secrets.GH_APP_PRIVATE_KEY }} + owner: ${{ env.OWNER }} + repositories: ${{ env.REPO }} + - name: Add a PR comment suggesting to validate the installer manually + if: matrix.artifact.name == 'installer' && github.event.inputs.architecture == 'x86_64' + uses: actions/github-script@v7 + with: + github-token: ${{ steps.pr-comment-token.outputs.token }} + script: | + const installerURL = ${{ toJSON(steps.upload-artifact.outputs.artifact-url) }} + const preFlightChecklistURL = 'https://github.com/git-for-windows/build-extra/blob/HEAD/installer/checklist.txt' + const body = `## Validate the installer manually + + The [installer](${installerURL}) was built successfully; + Please download, install, and run through [the pre-flight check-list](${preFlightChecklistURL}).` + + const fs = require('fs') + const gitSHA = fs.readFileSync('bundle-artifacts/git-commit-oid') + const q = `repo:${process.env.OWNER}/${process.env.REPO}+is:pr+is:open+${gitSHA}` + const { data } = await github.rest.search.issuesAndPullRequests({ q }) + if (data.items.length !== 1) { + core.warning(`${data.items.length} PRs found for ${gitSHA}, not posting a comment, would have posted:\n${body}`) + } else { + const req = { + owner: process.env.OWNER, + repo: process.env.REPO, + issue_number: data.items[0].number, + body: `${body}\n@${data.items[0].user.login} ☝️`, + } + + await github.rest.issues.createComment(req) + } - name: restore check-run state if: needs.pkg.outputs.check-run-state != '' && always() id: check-run-state