Skip to content
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

Improve pipeline announcements #3

Merged
merged 3 commits into from
Jan 23, 2025
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
45 changes: 41 additions & 4 deletions .github/workflow_scripts/announce_discord.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
WEBHOOK_URL=""
VERSION=""
BETA="FALSE"
CANARY="FALSE"
REPO=""
while [[ $# -gt 0 ]]; do
case $1 in
--webhook-url)
Expand All @@ -18,6 +20,15 @@ while [[ $# -gt 0 ]]; do
BETA="TRUE"
shift
;;
--canary)
CANARY="TRUE"
shift
;;
--repo)
REPO=$2
shift
shift
;;
*)
echo "Invalid argument: $1" >&2
exit 1
Expand All @@ -38,7 +49,23 @@ fi

# Get the latest changelog content
SCRIPT_DIR=$(dirname "$(readlink -f "$0")")
CHANGELOG_CONTENT=$("$SCRIPT_DIR/get-latest-changelog.sh")
if [ "$BETA" = "TRUE" ]; then
CHANGELOG_CONTENT=$("$SCRIPT_DIR/get-latest-beta-changelog.sh" "--repo" "$REPO" "--version" "$VERSION")
elif [ "$CANARY" = "TRUE" ]; then
CHANGELOG_CONTENT=$("$SCRIPT_DIR/get-latest-beta-changelog.sh" "--repo" "$REPO" "--version" "$VERSION")
else
CHANGELOG_CONTENT=$("$SCRIPT_DIR/get-latest-changelog.sh")
fi

if [ $? -ne 0 ]; then
echo "Failed to get changelog content"
exit 1
fi

if [ -z "$CHANGELOG_CONTENT" ]; then
echo "No changelog content found"
exit 1
fi

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

TITLE="📢 New Release v${VERSION}"
if [[ ! $VERSION == v* ]]; then
VERSION="v${VERSION}"
fi

TITLE="📢 New Release ${VERSION}"
COLOR="5763719"
if [ "$BETA" = "TRUE" ]; then
TITLE="🧪 New Beta Release v${VERSION}"
TITLE="🧪 New Beta Release ${VERSION}"
COLOR="3447003"
fi
if [ "$CANARY" = "TRUE" ]; then
TITLE="🐤 New Canary Release ${VERSION}"
COLOR="16776960"
fi

# Create the JSON payload
Expand All @@ -63,7 +100,7 @@ JSON_PAYLOAD=$(
"embeds": [{
"title": "${TITLE}",
"description": "${CHANGELOG_CONTENT}",
"color": 3447003
"color": ${COLOR}
}]
}
EOF
Expand Down
67 changes: 67 additions & 0 deletions .github/workflow_scripts/get-latest-beta-changelog.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/bash

CHANGELOG_FILE="CHANGELOG.md"
OUTPUT_FILE="release_notes.md"
OUTPUT_TO_FILE="FALSE"
REPO=""

while [[ $# -gt 0 ]]; do
case $1 in
-m)
MODE=$2
shift
shift
;;
--version)
VERSION=$2
shift
shift
;;
-v)
VERSION=$2
shift
shift
;;
--CHANGELOG_FILE)
CHANGELOG_FILE=$2
shift
shift
;;
--repo)
REPO=$2
shift
shift
;;
--file)
OUTPUT_FILE shift
shift
;;
--output-to-file)
OUTPUT_TO_FILE="TRUE"
shift
;;
*)
echo "Invalid argument: $1" >&2
exit 1
;;
esac
done

function generate_release_notes() {
# Get the content for the highest version
content=$(./.github/workflow_scripts/generate-changelog.sh --repo "$REPO" --mode RELEASE)

# Write the content to the output file
if [ "$OUTPUT_TO_FILE" == "TRUE" ]; then
echo -e "# Release Notes for v$VERSION\n\n$content" >$OUTPUT_FILE
else
echo -e "# Release Notes for v$VERSION\n\n$content"
fi
}

if [ -z "$REPO" ]; then
echo "Error: --repo is not set" >&2
exit 1
fi

generate_release_notes
47 changes: 29 additions & 18 deletions .github/workflows/create_release_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,53 +22,64 @@ jobs:
contents: write
pull-requests: write
env:
new_version: ''
VERSION: ''
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.22.x'
cache-dependency-path: ${{ github.workspace }}/src/go.sum
- name: Check for Changes to the Changelog
id: diff
if: false
- name: Set new beta version
if: ${{ vars.RELEASE_NAME == 'parallels-desktop-beta' }}
run: |
VERSION=${{ github.event.inputs.version }}
MAJOR_VERSION=${VERSION%.*}
NEW_VERSION=${VERSION%.*}.${{ github.run_id }}
echo "VERSION=${NEW_VERSION}" >> "$GITHUB_ENV"
echo "MAJOR_VERSION=${MAJOR_VERSION}" >> "$GITHUB_ENV"
- name: Set new version
if: ${{ vars.RELEASE_NAME == 'parallels-desktop' }}
run: |
NEW_VERSION=$(./.github/workflow_scripts/increment-version.sh -t ${{ inputs.version }} -f VERSION)
LAST_CHANGELOG_VERSION=$(./.github/workflow_scripts/get-latest-changelog-version.sh)
if [ "$NEW_VERSION" != "$LAST_CHANGELOG_VERSION" ]; then
echo "Changelog not updated for version $NEW_VERSION latest version is $LAST_CHANGELOG_VERSION"
exit 1
fi
echo "VERSION=${NEW_VERSION}" >> "$GITHUB_ENV"
- name: Bump version and push
env:
GH_TOKEN: ${{ secrets.PARALLELS_WORKFLOW_PAT }}
VERSION: ${{ github.event.inputs.version }}
run: |
git config --global user.email "[email protected]"
git config --global user.name "cjlapao"

NEW_VERSION=$(./.github/workflow_scripts/increment-version.sh -t ${{ inputs.version }} -f VERSION)
echo "$NEW_VERSION" > ./VERSION

echo "$VERSION" > ./VERSION

git checkout -b release/"$NEW_VERSION"

# Generate changelog for the new version
./.github/workflow_scripts/generate-changelog.sh --repo ${{ github.repository }} --version $NEW_VERSION

git add VERSION CHANGELOG.md
git commit -m "Release extension version $NEW_VERSION"
git commit -m "Release extension version $VERSION"

git push --set-upstream origin release/$NEW_VERSION

echo "new_version=$NEW_VERSION" >> "$GITHUB_ENV"
git push --set-upstream origin release/$VERSION
- name: Generate beta release notes
if: ${{ vars.RELEASE_NAME == 'parallels-desktop-beta' }}
run: |
./.github/workflow_scripts/get-latest-beta-changelog.sh --repo ${{ github.repository }} --output-to-file --version "${EXT_VERSION}"
cat release_notes.md
- name: Generate release notes
if: ${{ vars.RELEASE_NAME == 'parallels-desktop' }}
run: |
./.github/workflow_scripts/get-latest-changelog.sh --output-to-file
cat release_notes.md
- name: Create PR
run: |
./.github/workflow_scripts/generate-changelog.sh --mode RELEASE --repo ${{ github.repository }} --version ${{ env.new_version }} --output-to-file
gh pr create \
--title "Release version ${{ env.new_version }}" \
--title "Release version ${{ env.VERSION }}" \
--body-file release_notes.md \
--base main \
--head release/${{ env.new_version }}
--head release/${{ env.VERSION }}
gh pr edit --add-label release-request
env:
GH_TOKEN: ${{ secrets.PARALLELS_WORKFLOW_PAT }}
1 change: 0 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ jobs:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
AMPLITUDE_API_KEY: ${{ secrets.AMPLITUDE_API_KEY }}
RELEASE_NAME: ${{ vars.RELEASE_NAME }}

verify-publications:
needs: terraform-provider-release
runs-on: ubuntu-latest
Expand Down
Loading