-
Notifications
You must be signed in to change notification settings - Fork 48
ci: automatically send a slack message for new releases #557
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
MoKamall
wants to merge
35
commits into
dev
Choose a base branch
from
ci/automate-release-notes-for-slack
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 34 commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
24e281c
ci: add a job to send release notes based on changelog to slack
MoKamall f8ebddd
ci: add a workflow to test the slack message job on test slack channel
MoKamall 77484d8
ci: change job image from macos to base
MoKamall 9fd3312
fix: correctly indented brackets in config.yml file
MoKamall 2d7ed13
fix: split notification job into two jobs; approval, and notification
MoKamall 4e2b72d
fix: add missing slack orb
MoKamall 6560e32
fix: add checkout step before notification command
MoKamall 0fdeb5d
fix: correct case-sensitive naming for .sh script
MoKamall 0c74b84
fix: grant correct run permissions to all scripts in .scripts/*
MoKamall 1ec3dcd
fix: change curl command format, change jq selector name to match cur…
MoKamall 628b019
fix: retrieve workflow ID dynamically from circleci
MoKamall c305b35
ci: add debugging prints in get_job_approver.sh
MoKamall 8a3a583
ci: add more debugging statements
MoKamall 21e9de3
ci: change curl command format for retrieving user
MoKamall 174c0d2
chore: test get_release_notes script alone
MoKamall 18a0bcf
chore: remove comments from message block
MoKamall 16d38eb
chore: test get_sdk_version script alone
MoKamall 80f7ee2
fix: add another block to the message body
MoKamall 5c7c935
chore: test get_job_approver script alone
MoKamall fa720ff
ci: disable verbose logging for curl commands
MoKamall 571759f
chore: add some clean-up logic to json outputs
MoKamall 6fc314c
ci: change slack job environment to macos
MoKamall 0e4581b
ci: add install jq to job
MoKamall 62ec228
chore: enable debug mode for slack job
MoKamall a58b0a1
chore: remove all inner echo statements and switch to here-string (<<…
MoKamall 5cf8b87
chore: change slack job environment back to default, test get_release…
MoKamall 5149eae
fix: add a shebang on top of the changelog_to_slack_formatter script
MoKamall 587ca72
chore: enable debug mode for slack/notify, add shebang on top of get_…
MoKamall db5e650
chore: directly format message inside get_release_notes
MoKamall d91110a
fix: format message in seperate script again, and output correct slac…
MoKamall 5dd7637
fix: remove angular brackets from release notes body
MoKamall 0b7f3aa
fix: show correct sdk version
MoKamall 2bde506
chore: add mentions section
MoKamall 74d358b
ci: change channel id to planning_releases, send message on successfu…
MoKamall f690c32
chore: remove commented code from shell scripts
MoKamall File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
|
@@ -5,6 +5,7 @@ orbs: | |
flutter: circleci/[email protected] | ||
node: circleci/[email protected] | ||
advanced-checkout: vsco/[email protected] | ||
slack: circleci/[email protected] | ||
|
||
commands: | ||
setup_flutter: | ||
|
@@ -103,6 +104,37 @@ commands: | |
- run: | ||
name: Build Pigeons | ||
command: dart run build_runner build --delete-conflicting-outputs | ||
notify_slack_with_release: | ||
steps: | ||
- slack/notify: | ||
channel: C8PDY2Q8H | ||
event: pass | ||
custom: | | ||
{ | ||
"blocks": [ | ||
{ | ||
"type": "section", | ||
"text": { | ||
"type": "mrkdwn", | ||
"text": ":flutter: Flutter `v$(./scripts/releases/get_sdk_version.sh)` is released by <@$(./scripts/releases/get_job_approver.sh)> 🚀" | ||
} | ||
}, | ||
{ | ||
"type": "section", | ||
"text": { | ||
"type": "mrkdwn", | ||
"text": "$(./scripts/releases/get_release_notes.sh)" | ||
} | ||
}, | ||
{ | ||
"type": "section", | ||
"text": { | ||
"type": "mrkdwn", | ||
"text": "cc: <@U5697F4EL> @support_team <@ULDFCC09J>" | ||
} | ||
} | ||
] | ||
} | ||
|
||
jobs: | ||
danger: | ||
|
@@ -278,6 +310,13 @@ jobs: | |
working_directory: project | ||
command: Escape flutter publish | ||
|
||
release_slack_notification: | ||
docker: | ||
- image: cimg/base:current | ||
steps: | ||
- advanced-checkout/shallow-checkout | ||
- notify_slack_with_release | ||
|
||
workflows: | ||
version: 2 | ||
build-test-and-approval-deploy: | ||
|
@@ -324,4 +363,8 @@ workflows: | |
- hold_release | ||
filters: | ||
branches: | ||
only: master | ||
only: master | ||
- release_slack_notification: | ||
requires: | ||
- release | ||
context: slack-app |
Empty file.
This file contains hidden or 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,9 @@ | ||
#!/usr/bin/env bash | ||
input=$(cat) | ||
|
||
input=$(sed -E \ | ||
-e 's/\[([^]]+)\]\(([^)]+)\)/<\2|\1>/g' \ | ||
-e 's/^#{1,6}[[:space:]]*([^[:space:]].*)$/\*\1\*/' \ | ||
-e 's/^- /• /' <<< "$input") | ||
|
||
echo "$input" |
This file contains hidden or 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,20 @@ | ||
jobsJson=$(curl -s -X GET "https://circleci.com/api/v2/workflow/$CIRCLE_WORKFLOW_ID/job" --header "Circle-Token: $CIRCLE_TOKEN") | ||
|
||
#jobsJson=$(echo "$jobsJson" | jq -R '.' | jq -s '.' | jq -r 'join("")') | ||
job=$(jq '.items[] | select(.name == "hold_release_slack_notification")' <<< "$jobsJson") | ||
|
||
#job=$(echo "$job" | jq -R '.' | jq -s '.' | jq -r 'join("")') | ||
MoKamall marked this conversation as resolved.
Show resolved
Hide resolved
|
||
approver_id=$(jq '.approved_by' <<< "$job") | ||
|
||
approver_id=$(tr -d '"' <<< "$approver_id") | ||
|
||
user=$(curl -s -X GET "https://circleci.com/api/v2/user/$approver_id" --header "Circle-Token: $CIRCLE_TOKEN") | ||
|
||
#user=$(echo "$user" | jq -R '.' | jq -s '.' | jq -r 'join("")') | ||
MoKamall marked this conversation as resolved.
Show resolved
Hide resolved
|
||
username=$(jq '.login' <<< "$user") | ||
|
||
username=$(tr -d '"' <<< "$username") | ||
|
||
slack_id=$(./scripts/releases/get_slack_id_from_username.sh "$username") | ||
|
||
echo "$slack_id" |
This file contains hidden or 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 @@ | ||
#!/usr/bin/env bash | ||
latest_release="" | ||
capturing=false | ||
|
||
while IFS= read -r line; do | ||
if [[ "$line" == "## ["* ]]; then | ||
if $capturing; then | ||
break | ||
fi | ||
fi | ||
|
||
if [[ "$line" == "### "* ]]; then | ||
capturing=true | ||
fi | ||
|
||
if $capturing; then | ||
line=$(./scripts/releases/changelog_to_slack_formatter.sh <<< "$line") | ||
latest_release+="$line\n" | ||
fi | ||
done < CHANGELOG.md | ||
|
||
echo "$latest_release" |
This file contains hidden or 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,5 @@ | ||
sdk_version=$(grep -i 'version' pubspec.yaml) #version: xx.x.x+x | ||
sdk_version=$(cut -f2 -d' ' <<< $sdk_version) #xx.x.x+x | ||
sdk_version=$(cut -f1 -d'+' <<< $sdk_version) #xx.x.x | ||
|
||
echo "$sdk_version" |
This file contains hidden or 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,24 @@ | ||
github_username=$1 | ||
|
||
case $github_username in | ||
'mzelzoghbi') | ||
sid='U5697F4EL' | ||
;; | ||
'AndrewAminInstabug') | ||
sid='U06JVRNMKE1' | ||
;; | ||
'ahmedAlaaInstabug') | ||
sid='U06AE2G1161' | ||
;; | ||
'kholood-ea') | ||
sid='U06SU2QR280' | ||
;; | ||
'AyaMahmoud148') | ||
sid='U07GZSURC8K' | ||
;; | ||
'MoKamall') | ||
sid='U06JHDS3JJK' | ||
;; | ||
*) | ||
esac | ||
echo "$sid" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.