-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(teams): update script to send a release message on teams channel (
#272) DSY-2732
- Loading branch information
Davi Mattos
authored
May 3, 2022
1 parent
3c8c291
commit 06c8f8d
Showing
3 changed files
with
47 additions
and
25 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 |
---|---|---|
@@ -1,42 +1,58 @@ | ||
#!/bin/bash | ||
|
||
# create new file to edit | ||
# create new message teams template file | ||
cp ./scripts/message_teams.json ./scripts/updated_message_teams.json | ||
|
||
# get last version at package | ||
LAST_VERSION=$(cat ./scripts/updated_package_version.json \ | ||
| grep last_version \ | ||
| head -1 \ | ||
| awk -F: '{ print $2 }' \ | ||
| sed 's/[", ]//g') | ||
|
||
# get and update version at message | ||
NEW_VERSION=$(cat package.json \ | ||
| grep version \ | ||
| head -1 \ | ||
| awk -F: '{ print $2 }' \ | ||
| sed 's/[",]//g') | ||
| sed 's/[", ]//g') | ||
|
||
if [ "$NEW_VERSION" != "$LAST_VERSION" ]; then | ||
echo 'New version found! updating message...' | ||
|
||
# create a version template file | ||
cp ./scripts/package_version.json ./scripts/updated_package_version.json | ||
|
||
echo "New version: $NEW_VERSION" | ||
# update the last version | ||
sed -i '' "s/LASTVERSIONVALUE/$NEW_VERSION/g" ./scripts/updated_package_version.json | ||
# update the new version in teams message | ||
sed -i '' "s/VERSIONVALUE/$NEW_VERSION/g" ./scripts/updated_message_teams.json | ||
|
||
sed -i '' "s/VERSIONVALUE/$NEW_VERSION/g" ./scripts/updated_message_teams.json | ||
releaselinecontent='https://github.com/natura-cosmeticos/natds-rn/compare/' | ||
major=`echo $NEW_VERSION | cut -d. -f1` | ||
minor=`echo $NEW_VERSION | cut -d. -f2` | ||
patch=`echo $NEW_VERSION | cut -d. -f3` | ||
rgxversion="$major\.$minor\.$patch" # regex for new version | ||
|
||
releaselinecontent='https://github.com/natura-cosmeticos/natds-rn/compare/' | ||
major=`echo $NEW_VERSION | cut -d. -f1` | ||
minor=`echo $NEW_VERSION | cut -d. -f2` | ||
patch=`echo $NEW_VERSION | cut -d. -f3` | ||
rgxversion="$major\.$minor\.$patch" # regex for new version | ||
# save last version output to file | ||
awk 's{print $0 > "./scripts/message_release.txt"}; $0~v {print $0 > "./scripts/message_release.txt"; s=1; next}; (!($0~v) && $0~l) {s=0};' RS= v=$rgxversion l=$releaselinecontent CHANGELOG.md | ||
# erase last line of file | ||
sed -i '' -e '$ d' ./scripts/message_release.txt | ||
|
||
# save last version output to file | ||
awk 's{print $0 > "./scripts/message_release.txt"}; $0~v {print $0 > "./scripts/message_release.txt"; s=1; next}; (!($0~v) && $0~l) {s=0};' RS= v=$rgxversion l=$releaselinecontent CHANGELOG.md | ||
# erase last line of file | ||
sed -i '' -e '$ d' ./scripts/message_release.txt | ||
# write release message with line breaks | ||
awk '{printf "%s\\\n ",$0 > "./scripts/message_text.txt"} END {print ""}' ./scripts/message_release.txt | ||
|
||
# write release message with line breaks | ||
awk '{printf "%s\\\n ",$0 > "./scripts/message_text.txt"} END {print ""}' ./scripts/message_release.txt | ||
# update release message at json | ||
CHANGELOG_UPDATES=`cat ./scripts/message_text.txt` | ||
sed -i '' "s|CHANGELOGMESSAGE|$CHANGELOG_UPDATES|g" ./scripts/updated_message_teams.json | ||
|
||
# update release message at json | ||
CHANGELOG_UPDATES=`cat ./scripts/message_text.txt` | ||
sed -i '' "s|CHANGELOGMESSAGE|$CHANGELOG_UPDATES|g" ./scripts/updated_message_teams.json | ||
# send message | ||
message=`cat ./scripts/updated_message_teams.json` | ||
curl -H 'Content-Type: application/json' -d "$message" "$TEAMS_RELEASE_WEBHOOK" | ||
|
||
# send message | ||
message=`cat ./scripts/updated_message_teams.json` | ||
curl -H 'Content-Type: application/json' -d "$message" "$TEAMS_RELEASE_WEBHOOK" | ||
# remove helper files | ||
rm ./scripts/updated_message_teams.json | ||
rm ./scripts/message_release.txt | ||
rm ./scripts/message_text.txt | ||
|
||
# remove helper files | ||
rm ./scripts/updated_message_teams.json | ||
rm ./scripts/message_release.txt | ||
rm ./scripts/message_text.txt | ||
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,3 @@ | ||
{ | ||
"last_version": "LASTVERSIONVALUE" | ||
} |
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,3 @@ | ||
{ | ||
"last_version": "7.26.7" | ||
} |