Skip to content

Commit

Permalink
Add the ability to create beta versions
Browse files Browse the repository at this point in the history
- Added the ability to deploy beta versions for terraform
  • Loading branch information
cjlapao committed Jan 22, 2025
1 parent b0e4ef1 commit 5478f90
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
14 changes: 12 additions & 2 deletions .github/workflow_scripts/announce_discord.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash
WEBHOOK_URL=""
VERSION=""
BETA="FALSE"
while [[ $# -gt 0 ]]; do
case $1 in
--webhook-url)
Expand All @@ -13,6 +14,10 @@ while [[ $# -gt 0 ]]; do
shift
shift
;;
--beta)
BETA="TRUE"
shift
;;
*)
echo "Invalid argument: $1" >&2
exit 1
Expand Down Expand Up @@ -46,12 +51,17 @@ 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 [ "$BETA" = "TRUE" ]; then
TITLE="🧪 New Beta Release v${VERSION}"
fi

# Create the JSON payload
JSON_PAYLOAD=$(
cat <<EOF
{
"embeds": [{
"title": "📢 New Release v${VERSION}",
"title": "${TITLE}",
"description": "${CHANGELOG_CONTENT}",
"color": 3447003
}]
Expand All @@ -68,6 +78,6 @@ curl -H "Content-Type: application/json" \
if [ $? -eq 0 ]; then
echo "Successfully posted changelog to Discord"
else
echo "Failed to post changelog to Discord"
echo "Failed to post changelog to Discord webhook"
exit 1
fi
13 changes: 11 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
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
Expand All @@ -72,7 +73,7 @@ jobs:
if (targetVersion.startsWith('v')) {
targetVersion = targetVersion.substring(1);
}
const url = `${registry}/providers/Parallels/parallels-desktop/versions`;
const url = `${registry}/providers/Parallels/${{ vars.RELEASE_NAME }}/versions`;
const response = await fetch(url);
if (!response.ok) {
Expand Down Expand Up @@ -134,8 +135,16 @@ jobs:
run: |
VERSION=$(cat VERSION)
echo "VERSION=${VERSION}" >> "$GITHUB_ENV"
- name: Announce on discord
- name: Announce on discord beta
id: announce_discord_beta
if: ${{ vars.RELEASE_NAME == 'parallels-desktop-beta' }}
run: |
./.github/workflow_scripts/announce_discord.sh --webhook-url $DISCORD_WEBHOOK --version $VERSION --beta
env:
SLACK_WEBHOOKS: ${{ env.DISCORD_WEBHOOK }}
- name: Announce on discord stable
id: announce_discord
if: ${{ vars.RELEASE_NAME == 'parallels-desktop' }}
run: |
./.github/workflow_scripts/announce_discord.sh --webhook-url $DISCORD_WEBHOOK --version $VERSION
env:
Expand Down
2 changes: 1 addition & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ builds:
flags:
- -trimpath
ldflags:
- "-s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X 'terraform-provider-parallels-desktop/internal/telemetry.AMPLITUDE_API_KEY={{ .Env.AMPLITUDE_API_KEY }}'"
- "-s -w -X main.version={{.Version}} -X main.release_name={{.Env.RELEASE_NAME}} -X main.commit={{.Commit}} -X 'terraform-provider-parallels-desktop/internal/telemetry.AMPLITUDE_API_KEY={{ .Env.AMPLITUDE_API_KEY }}'"
goos:
- freebsd
- windows
Expand Down
7 changes: 5 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ import (

// these will be set by the goreleaser configuration
// to appropriate values for the compiled binary.
var version string = "dev"
var (
version string = "dev"
release_name string = "parallels-desktop"
)

// goreleaser can pass other information to the main package, such as the specific commit
// https://goreleaser.com/cookbooks/using-main.version/
Expand All @@ -45,7 +48,7 @@ func main() {
// provider address is used in these tutorials in conjunction with a
// specific Terraform CLI configuration for manual development testing
// of this provider.
Address: "registry.terraform.io/parallels/parallels-desktop",
Address: "registry.terraform.io/parallels/" + release_name,
Debug: debug,
}

Expand Down

0 comments on commit 5478f90

Please sign in to comment.