Skip to content

Commit

Permalink
provider: update changelog via seperate script and update release scr…
Browse files Browse the repository at this point in the history
…ipt to just push tag (hashicorp#28131)

* provider: update changelog via tag workflow instead of release script

* address pr comments and remove commit from changelog script

* remove workflow for now

* rename file
  • Loading branch information
katbyte authored Dec 26, 2024
1 parent 65dc1c0 commit cde02da
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- id: go-version
run: echo "version=$(cat ./.go-version)" >>${GITHUB_OUTPUT}

release-notes:
runs-on: custom-linux-xl
steps:
Expand All @@ -36,7 +37,6 @@ jobs:
name: 'Terraform Provider Release'
needs: [go-version, release-notes]
uses: hashicorp/ghaction-terraform-provider-release/.github/workflows/hashicorp.yml@393dac4dd208c749b1622323f9f0e8d26a6f26cc # v4.0.1

secrets:
hc-releases-github-token: '${{ secrets.HASHI_RELEASES_GITHUB_TOKEN }}'
hc-releases-host-staging: '${{ secrets.HC_RELEASES_HOST_STAGING }}'
Expand Down
42 changes: 42 additions & 0 deletions scripts/release-update-changelog-and-export-schema.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0

if [[ "$(uname)" == "Darwin" ]]; then
echo "(Using BSD sed)"
SED="sed -E"
else
echo "(Using GNU sed)"
SED="sed -r"
fi

DATE="$(date '+%B %d, %Y')"
PROVIDER_URL="https:\/\/github.com\/hashicorp\/terraform-provider-azurerm\/issues"

echo "Preparing changelog for release..."

if [[ ! -f CHANGELOG.md ]]; then
echo "Error: CHANGELOG.md not found."
exit 2
fi

# Get the next release
RELEASE="$($SED -n 's/^## v?([0-9.]+) \(Unreleased\)/\1/p' CHANGELOG.md)"
if [[ "${RELEASE}" == "" ]]; then
echo "Error: could not determine next release in CHANGELOG.md" >&2
exit 3
fi

# Replace [GH-nnnn] references with issue links
( set -x; ${debug}$SED -i.bak "s/\[GH-([0-9]+)\]/\(\[#\1\]\(${PROVIDER_URL}\/\1\)\)/g" CHANGELOG.md )

# Set the date for the latest release
( set -x; ${debug}$SED -i.bak "s/^(## v?[0-9.]+) \(Unreleased\)/\1 (${DATE})/i" CHANGELOG.md )

${debug}rm CHANGELOG.md.bak

echo "exporting Provider Schema JSON"
(
set -x
${debug}go run internal/tools/schema-api/main.go -export .release/provider-schema.json
)
32 changes: 0 additions & 32 deletions scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ else
SED="sed -r"
fi

DATE="$(date '+%B %d, %Y')"
PROVIDER_URL="https:\/\/github.com\/hashicorp\/terraform-provider-azurerm\/issues"

BRANCH="$(git rev-parse --abbrev-ref HEAD)"
if [[ "${BRANCH}" != "${TRUNK}" ]]; then
if [[ "${FORCE}" == "1" ]]; then
Expand All @@ -87,13 +84,6 @@ else
( set -x; TF_ACC= scripts/run-test.sh )
fi

echo "Preparing changelog for release..."

if [[ ! -f CHANGELOG.md ]]; then
echo "Error: CHANGELOG.md not found."
exit 2
fi

# Get the next release
RELEASE="$($SED -n 's/^## v?([0-9.]+) \(Unreleased\)/\1/p' CHANGELOG.md)"
if [[ "${RELEASE}" == "" ]]; then
Expand All @@ -104,33 +94,11 @@ fi
# Ensure latest changes are checked out
( set -x; ${debug}git pull --rebase origin "${TRUNK}" )

# Replace [GH-nnnn] references with issue links
( set -x; ${debug}$SED -i.bak "s/\[GH-([0-9]+)\]/\(\[#\1\]\(${PROVIDER_URL}\/\1\)\)/g" CHANGELOG.md )

# Set the date for the latest release
( set -x; ${debug}$SED -i.bak "s/^(## v?[0-9.]+) \(Unreleased\)/\1 (${DATE})/i" CHANGELOG.md )

${debug}rm CHANGELOG.md.bak

if [[ "${NOTAG}" == "1" ]]; then
echo "Warning: Skipping commit, tag and push."
exit 0
fi

echo "exporting Provider Schema JSON"
(
set -x
${debug}go run internal/tools/schema-api/main.go -export .release/provider-schema.json
)

echo "Committing changelog and provider schema..."
(
set -x
${debug}git commit CHANGELOG.md .release/provider-schema.json -m v"${RELEASE}"
${debug}git push origin "${BRANCH}"
)


echo "Releasing v${RELEASE}..."

(
Expand Down

0 comments on commit cde02da

Please sign in to comment.