From 82973c38e4c936d555171ec03d966a35163224b6 Mon Sep 17 00:00:00 2001 From: Chris Evich Date: Wed, 12 Jun 2024 13:53:57 -0400 Subject: [PATCH] GHA: Send release notification mail Rather than manually crafting what ends up being nearly identical release e-mails, do it automatically whenever a release is created. Note: At the time of this commit, there is a possible race condition with the `mac-pkg.yml` workflow, since it runs in parallel. It could fail, or fail to complete prior to the e-mail content being generated. This should be unlikely, if `release-artifacts.yml` goes through and compiles every artifact, but it's not guaranteed. Signed-off-by: Chris Evich --- .github/workflows/release-artifacts.yml | 49 ++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release-artifacts.yml b/.github/workflows/release-artifacts.yml index d966b846e5..cc6abd9ab4 100644 --- a/.github/workflows/release-artifacts.yml +++ b/.github/workflows/release-artifacts.yml @@ -31,6 +31,7 @@ jobs: echo "::group::Event JSON" jq --color-output "." ${{ github.event_path }}"" echo "::endgroup::" + - name: Determine Version id: getversion run: | @@ -105,7 +106,6 @@ jobs: steps.actual_dryrun.outputs.dryrun == 'true' uses: actions/checkout@v4 with: - repository: containers/podman ref: ${{steps.getversion.outputs.version}} - name: Set up Go @@ -185,6 +185,7 @@ jobs: release/* - name: Upload to Release + id: upload if: >- steps.check.outputs.buildartifacts == 'true' && steps.actual_dryrun.outputs.dryrun == 'false' @@ -196,6 +197,9 @@ jobs: gh release upload ${{steps.getversion.outputs.version}} release/*.zip release/*.tar.gz gh release upload ${{steps.getversion.outputs.version}} --clobber shasums + # WARNING: This should only be set when 'notification' job should be triggered + echo "complete=true" >> $GITHUB_OUTPUT + - name: Trigger Windows Installer if: >- steps.check.outputs.windows_amd == 'true' || @@ -204,3 +208,46 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | gh workflow run upload-win-installer.yml -f version=${{steps.getversion.outputs.version}} -f dryrun=false + outputs: + uploaded: ${{ steps.upload.outputs.complete }} + version: ${{ steps.getversion.outputs.version }} + + notification: + if: needs.build.outputs.uploaded == 'true' + runs-on: ubuntu-22.04 + needs: build + steps: + - name: Format release email + env: + VERSION: ${{ needs.build.outputs.version }} + run: | + cat <email_body.txt + Hi all, + + Podman $VERSION is now available. You may view the full details at + https://github.com/${{ github.repository }}/releases/tag/$VERSION + + Release Notes: + -------------- + EOF + + echo ${{ secrets.GITHUB_TOKEN }} | gh auth login --with-token + gh release view $VERSION \ + --repo ${{ github.repository }} --json=body --jq '.body' >> email_body.txt + + # If job fails, permit operator to observe contents in case helpful. + - name: Provide release e-mail contents for examination + run: cat email_body.txt + + - name: Send release notification e-mail + # Ref: https://github.com/dawidd6/action-send-mail + uses: dawidd6/action-send-mail@v3.12.0 + with: + server_address: ${{secrets.ACTION_MAIL_SERVER}} + server_port: 465 + username: ${{secrets.ACTION_MAIL_USERNAME}} + password: ${{secrets.ACTION_MAIL_PASSWORD}} + subject: Podman ${{ needs.build.outputs.version }} Released + to: Podman List + from: ${{secrets.ACTION_MAIL_SENDER}} + body: file://./email_body.txt