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 <cevich@redhat.com>
This commit is contained in:
Chris Evich
2024-06-12 13:53:57 -04:00
parent ad56dc7e2b
commit 82973c38e4

View File

@ -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 <<EOF>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 <podman@lists.podman.io>
from: ${{secrets.ACTION_MAIL_SENDER}}
body: file://./email_body.txt