-
-
Notifications
You must be signed in to change notification settings - Fork 997
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Adding release announcement workflow (#3419)
- Loading branch information
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
URL="${URL:?Required environment variable URL}" | ||
REPO="${REPO:?Required environment variable REPO}" | ||
TAG_NAME="${TAG_NAME:?Required environment variable TAG_NAME}" | ||
ROLE_ID="${ROLE_ID:?Required environment variable ROLE_ID}" | ||
USERNAME="${USERNAME:?Required environment variable USERNAME}" | ||
AVATAR_URL="${AVATAR_URL:?Required environment variable AVATAR_URL}" | ||
|
||
if RELEASE_JSON=$(gh -R "$REPO" release view "$TAG_NAME" --json body --json url --json name); then | ||
RELEASE_NOTES=$(jq '.body' <<<"$RELEASE_JSON") | ||
|
||
PAYLOAD=$( | ||
jq \ | ||
--argjson release_notes "$RELEASE_NOTES" \ | ||
--arg username "$USERNAME" \ | ||
--arg avatar_url "$AVATAR_URL" \ | ||
-cn '{"content": $release_notes, username: $username, avatar_url: $avatar_url, "flags": 4}' | ||
) | ||
|
||
tmpfile=$(mktemp) | ||
jq '.content = "'"<@&$ROLE_ID> $(jq -r '.name' <<<"$RELEASE_JSON")\n"'>>> " + .content + "'"\n\n**[View release on GitHub]($(jq -r '.url' <<<"$RELEASE_JSON"))**"'"' <<<"$PAYLOAD" >"$tmpfile" | ||
|
||
curl -X POST \ | ||
--data-binary "@$tmpfile" \ | ||
-H "Content-Type: application/json" \ | ||
"$URL" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: Announce Release | ||
on: | ||
release: | ||
# This is intentionally not `published` to avoid announcing pre-releases | ||
types: [released] | ||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Announce Release | ||
run: ./.github/scripts/announce-release.sh | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
REPO: ${{ github.repository }} | ||
TAG_NAME: ${{ github.event.release.tag_name }} | ||
URL: ${{ secrets.RELEASE_ANNOUNCEMENT_URL }} | ||
ROLE_ID: ${{ secrets.RELEASE_ANNOUNCEMENT_ROLE_ID }} | ||
USERNAME: ${{ secrets.RELEASE_ANNOUNCEMENT_USERNAME }} | ||
AVATAR_URL: ${{ secrets.RELEASE_ANNOUNCEMENT_AVATAR_URL }} |