Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .github/workflows/release-dispatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ jobs:
go-version: '1.24'

- name: Create and push release tag
run: ./scripts/release-version.sh "${{ inputs.bump }}" --push
id: release_tag
run: |
./scripts/release-version.sh "${{ inputs.bump }}" --push
echo "tag=$(git describe --tags --exact-match)" >> "${GITHUB_OUTPUT}"

# Run GoReleaser in the SAME job rather than relying on the tag push to
# trigger release.yml. The tag above is pushed with the default
Expand All @@ -57,3 +60,8 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAP_GITHUB_TOKEN: ${{ secrets.TAP_GITHUB_TOKEN }}

- name: Notify Slack
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_ALERTS_WEBHOOK_URL }}
run: ./scripts/notify-slack-release.sh "${{ steps.release_tag.outputs.tag }}"
5 changes: 5 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,8 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAP_GITHUB_TOKEN: ${{ secrets.TAP_GITHUB_TOKEN }}

- name: Notify Slack
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_ALERTS_WEBHOOK_URL }}
run: ./scripts/notify-slack-release.sh "${{ github.ref_name }}"
63 changes: 63 additions & 0 deletions scripts/notify-slack-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/env bash

set -euo pipefail

TAG="${1:-}"
WEBHOOK_URL="${SLACK_WEBHOOK_URL:-}"
REPOSITORY="${GITHUB_REPOSITORY:-hostodo/odo-cli}"
SERVER_URL="${GITHUB_SERVER_URL:-https://github.com}"

if [[ ! "${TAG}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: release tag must use vMAJOR.MINOR.PATCH format." >&2
exit 1
fi

if [[ -z "${WEBHOOK_URL}" ]]; then
echo "Error: SLACK_WEBHOOK_URL is not configured." >&2
exit 1
fi

RELEASE_URL="${SERVER_URL}/${REPOSITORY}/releases/tag/${TAG}"
PAYLOAD="$(jq -n \
--arg title "odo CLI ${TAG} released" \
--arg url "${RELEASE_URL}" \
'{
text: $title,
blocks: [
{
type: "header",
text: {type: "plain_text", text: $title}
},
{
type: "section",
text: {
type: "plain_text",
text: "New macOS, Linux, and Windows builds are available."
}
},
{
type: "actions",
elements: [
{
type: "button",
text: {type: "plain_text", text: "View release"},
url: $url,
action_id: "view_odo_cli_release"
}
]
}
]
}')"

curl \
--fail-with-body \
--silent \
--show-error \
--retry 3 \
--retry-all-errors \
--header 'Content-Type: application/json' \
--data-binary "${PAYLOAD}" \
"${WEBHOOK_URL}"

echo
echo "Slack release notification sent for ${TAG}."
Loading