Skip to content

Commit 22c6339

Browse files
authored
Improve pipeline announcements (#3)
* Improve pipeline announcements - Updated the discord announcement script - Added a script to get the beta changelog - Updated the way we generate release notes to match the type of release * update create release to change the versions for beta and normal
1 parent 7ca18a8 commit 22c6339

File tree

4 files changed

+137
-23
lines changed

4 files changed

+137
-23
lines changed

.github/workflow_scripts/announce_discord.sh

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
WEBHOOK_URL=""
33
VERSION=""
44
BETA="FALSE"
5+
CANARY="FALSE"
6+
REPO=""
57
while [[ $# -gt 0 ]]; do
68
case $1 in
79
--webhook-url)
@@ -18,6 +20,15 @@ while [[ $# -gt 0 ]]; do
1820
BETA="TRUE"
1921
shift
2022
;;
23+
--canary)
24+
CANARY="TRUE"
25+
shift
26+
;;
27+
--repo)
28+
REPO=$2
29+
shift
30+
shift
31+
;;
2132
*)
2233
echo "Invalid argument: $1" >&2
2334
exit 1
@@ -38,7 +49,23 @@ fi
3849

3950
# Get the latest changelog content
4051
SCRIPT_DIR=$(dirname "$(readlink -f "$0")")
41-
CHANGELOG_CONTENT=$("$SCRIPT_DIR/get-latest-changelog.sh")
52+
if [ "$BETA" = "TRUE" ]; then
53+
CHANGELOG_CONTENT=$("$SCRIPT_DIR/get-latest-beta-changelog.sh" "--repo" "$REPO" "--version" "$VERSION")
54+
elif [ "$CANARY" = "TRUE" ]; then
55+
CHANGELOG_CONTENT=$("$SCRIPT_DIR/get-latest-beta-changelog.sh" "--repo" "$REPO" "--version" "$VERSION")
56+
else
57+
CHANGELOG_CONTENT=$("$SCRIPT_DIR/get-latest-changelog.sh")
58+
fi
59+
60+
if [ $? -ne 0 ]; then
61+
echo "Failed to get changelog content"
62+
exit 1
63+
fi
64+
65+
if [ -z "$CHANGELOG_CONTENT" ]; then
66+
echo "No changelog content found"
67+
exit 1
68+
fi
4269

4370
# Escape special characters for JSON
4471
CHANGELOG_CONTENT=$(echo "$CHANGELOG_CONTENT" | jq -Rs .)
@@ -51,9 +78,19 @@ if [ ${#CHANGELOG_CONTENT} -gt 4096 ]; then
5178
CHANGELOG_CONTENT+=$"\nFor the complete changelog, visit: https://github.com/Parallels/terraform-provider-parallels-desktop/releases/tag/v${VERSION}"
5279
fi
5380

54-
TITLE="📢 New Release v${VERSION}"
81+
if [[ ! $VERSION == v* ]]; then
82+
VERSION="v${VERSION}"
83+
fi
84+
85+
TITLE="📢 New Release ${VERSION}"
86+
COLOR="5763719"
5587
if [ "$BETA" = "TRUE" ]; then
56-
TITLE="🧪 New Beta Release v${VERSION}"
88+
TITLE="🧪 New Beta Release ${VERSION}"
89+
COLOR="3447003"
90+
fi
91+
if [ "$CANARY" = "TRUE" ]; then
92+
TITLE="🐤 New Canary Release ${VERSION}"
93+
COLOR="16776960"
5794
fi
5895

5996
# Create the JSON payload
@@ -63,7 +100,7 @@ JSON_PAYLOAD=$(
63100
"embeds": [{
64101
"title": "${TITLE}",
65102
"description": "${CHANGELOG_CONTENT}",
66-
"color": 3447003
103+
"color": ${COLOR}
67104
}]
68105
}
69106
EOF
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/bin/bash
2+
3+
CHANGELOG_FILE="CHANGELOG.md"
4+
OUTPUT_FILE="release_notes.md"
5+
OUTPUT_TO_FILE="FALSE"
6+
REPO=""
7+
8+
while [[ $# -gt 0 ]]; do
9+
case $1 in
10+
-m)
11+
MODE=$2
12+
shift
13+
shift
14+
;;
15+
--version)
16+
VERSION=$2
17+
shift
18+
shift
19+
;;
20+
-v)
21+
VERSION=$2
22+
shift
23+
shift
24+
;;
25+
--CHANGELOG_FILE)
26+
CHANGELOG_FILE=$2
27+
shift
28+
shift
29+
;;
30+
--repo)
31+
REPO=$2
32+
shift
33+
shift
34+
;;
35+
--file)
36+
OUTPUT_FILE shift
37+
shift
38+
;;
39+
--output-to-file)
40+
OUTPUT_TO_FILE="TRUE"
41+
shift
42+
;;
43+
*)
44+
echo "Invalid argument: $1" >&2
45+
exit 1
46+
;;
47+
esac
48+
done
49+
50+
function generate_release_notes() {
51+
# Get the content for the highest version
52+
content=$(./.github/workflow_scripts/generate-changelog.sh --repo "$REPO" --mode RELEASE)
53+
54+
# Write the content to the output file
55+
if [ "$OUTPUT_TO_FILE" == "TRUE" ]; then
56+
echo -e "# Release Notes for v$VERSION\n\n$content" >$OUTPUT_FILE
57+
else
58+
echo -e "# Release Notes for v$VERSION\n\n$content"
59+
fi
60+
}
61+
62+
if [ -z "$REPO" ]; then
63+
echo "Error: --repo is not set" >&2
64+
exit 1
65+
fi
66+
67+
generate_release_notes

.github/workflows/create_release_pr.yml

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,53 +22,64 @@ jobs:
2222
contents: write
2323
pull-requests: write
2424
env:
25-
new_version: ''
25+
VERSION: ''
2626
steps:
2727
- uses: actions/checkout@v4
2828
- name: Setup Go
2929
uses: actions/setup-go@v4
3030
with:
3131
go-version: '1.22.x'
3232
cache-dependency-path: ${{ github.workspace }}/src/go.sum
33-
- name: Check for Changes to the Changelog
34-
id: diff
35-
if: false
33+
- name: Set new beta version
34+
if: ${{ vars.RELEASE_NAME == 'parallels-desktop-beta' }}
35+
run: |
36+
VERSION=${{ github.event.inputs.version }}
37+
MAJOR_VERSION=${VERSION%.*}
38+
NEW_VERSION=${VERSION%.*}.${{ github.run_id }}
39+
echo "VERSION=${NEW_VERSION}" >> "$GITHUB_ENV"
40+
echo "MAJOR_VERSION=${MAJOR_VERSION}" >> "$GITHUB_ENV"
41+
- name: Set new version
42+
if: ${{ vars.RELEASE_NAME == 'parallels-desktop' }}
3643
run: |
3744
NEW_VERSION=$(./.github/workflow_scripts/increment-version.sh -t ${{ inputs.version }} -f VERSION)
38-
LAST_CHANGELOG_VERSION=$(./.github/workflow_scripts/get-latest-changelog-version.sh)
39-
if [ "$NEW_VERSION" != "$LAST_CHANGELOG_VERSION" ]; then
40-
echo "Changelog not updated for version $NEW_VERSION latest version is $LAST_CHANGELOG_VERSION"
41-
exit 1
42-
fi
45+
echo "VERSION=${NEW_VERSION}" >> "$GITHUB_ENV"
4346
- name: Bump version and push
4447
env:
4548
GH_TOKEN: ${{ secrets.PARALLELS_WORKFLOW_PAT }}
49+
VERSION: ${{ github.event.inputs.version }}
4650
run: |
4751
git config --global user.email "cjlapao@gmail.com"
4852
git config --global user.name "cjlapao"
4953
50-
NEW_VERSION=$(./.github/workflow_scripts/increment-version.sh -t ${{ inputs.version }} -f VERSION)
51-
echo "$NEW_VERSION" > ./VERSION
54+
55+
echo "$VERSION" > ./VERSION
5256
5357
git checkout -b release/"$NEW_VERSION"
5458
5559
# Generate changelog for the new version
5660
./.github/workflow_scripts/generate-changelog.sh --repo ${{ github.repository }} --version $NEW_VERSION
5761
5862
git add VERSION CHANGELOG.md
59-
git commit -m "Release extension version $NEW_VERSION"
63+
git commit -m "Release extension version $VERSION"
6064
61-
git push --set-upstream origin release/$NEW_VERSION
62-
63-
echo "new_version=$NEW_VERSION" >> "$GITHUB_ENV"
65+
git push --set-upstream origin release/$VERSION
66+
- name: Generate beta release notes
67+
if: ${{ vars.RELEASE_NAME == 'parallels-desktop-beta' }}
68+
run: |
69+
./.github/workflow_scripts/get-latest-beta-changelog.sh --repo ${{ github.repository }} --output-to-file --version "${EXT_VERSION}"
70+
cat release_notes.md
71+
- name: Generate release notes
72+
if: ${{ vars.RELEASE_NAME == 'parallels-desktop' }}
73+
run: |
74+
./.github/workflow_scripts/get-latest-changelog.sh --output-to-file
75+
cat release_notes.md
6476
- name: Create PR
6577
run: |
66-
./.github/workflow_scripts/generate-changelog.sh --mode RELEASE --repo ${{ github.repository }} --version ${{ env.new_version }} --output-to-file
6778
gh pr create \
68-
--title "Release version ${{ env.new_version }}" \
79+
--title "Release version ${{ env.VERSION }}" \
6980
--body-file release_notes.md \
7081
--base main \
71-
--head release/${{ env.new_version }}
82+
--head release/${{ env.VERSION }}
7283
gh pr edit --add-label release-request
7384
env:
7485
GH_TOKEN: ${{ secrets.PARALLELS_WORKFLOW_PAT }}

.github/workflows/release.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ jobs:
5151
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
5252
AMPLITUDE_API_KEY: ${{ secrets.AMPLITUDE_API_KEY }}
5353
RELEASE_NAME: ${{ vars.RELEASE_NAME }}
54-
5554
verify-publications:
5655
needs: terraform-provider-release
5756
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)