Skip to content

Commit 72eb28a

Browse files
committed
fix: Pulling in changes from working implementation
1 parent 247a0d0 commit 72eb28a

4 files changed

Lines changed: 27 additions & 105 deletions

File tree

.github/scripts/release/check-edit-meaningful.sh

Lines changed: 0 additions & 30 deletions
This file was deleted.

.github/scripts/release/resolve-version-ref.sh

Lines changed: 21 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,58 +2,39 @@
22

33
set -euo pipefail
44

5-
# Script to resolve the release version and target ref from either a
6-
# release event or a workflow_dispatch input.
7-
#
8-
# For workflow_dispatch: looks up the existing draft release by version
9-
# and extracts the target commitish.
10-
# For release events: reads version and ref directly from event context.
5+
# Script to resolve the release version and target ref from a
6+
# workflow_dispatch input by looking up the existing draft release.
117
#
128
# Usage: resolve-version-ref.sh
139
# Environment variables:
14-
# EVENT_NAME: GitHub event name (workflow_dispatch or release)
15-
# INPUT_VERSION: Version provided via workflow_dispatch (required for workflow_dispatch)
16-
# RELEASE_TAG_NAME: Tag name from the release event (required for release events)
17-
# RELEASE_TARGET: Target commitish from the release event (required for release events)
18-
# GH_TOKEN: GitHub token for authentication (required for workflow_dispatch)
10+
# INPUT_VERSION: Version provided via workflow_dispatch (required)
11+
# GH_TOKEN: GitHub token for authentication (required)
1912
# GITHUB_OUTPUT: Path to GitHub output file
2013

2114
function main {
22-
: "${EVENT_NAME:?ERROR: EVENT_NAME is a required environment variable}"
15+
: "${INPUT_VERSION:?ERROR: INPUT_VERSION is a required environment variable}"
16+
: "${GH_TOKEN:?ERROR: GH_TOKEN is a required environment variable}"
2317
: "${GITHUB_OUTPUT:?ERROR: GITHUB_OUTPUT is a required environment variable}"
2418

25-
local version
26-
local ref
27-
28-
if [[ "$EVENT_NAME" == "workflow_dispatch" ]]; then
29-
: "${INPUT_VERSION:?ERROR: INPUT_VERSION is required for workflow_dispatch}"
30-
: "${GH_TOKEN:?ERROR: GH_TOKEN is required for workflow_dispatch}"
31-
32-
version="$INPUT_VERSION"
33-
34-
# Look up the release to get target_commitish
35-
local release_json
36-
if ! release_json=$(gh release view "$version" --json 'isDraft,targetCommitish' 2>/dev/null); then
37-
echo "ERROR: No release found for version $version" >&2
38-
exit 1
39-
fi
19+
local version="$INPUT_VERSION"
4020

41-
local is_draft
42-
is_draft=$(jq -r '.isDraft' <<<"$release_json")
43-
if [[ "$is_draft" != "true" ]]; then
44-
echo "ERROR: Release $version is already published. Cannot rebuild a published release." >&2
45-
exit 1
46-
fi
47-
48-
ref=$(jq -r '.targetCommitish' <<<"$release_json")
49-
else
50-
: "${RELEASE_TAG_NAME:?ERROR: RELEASE_TAG_NAME is required for release events}"
51-
: "${RELEASE_TARGET:?ERROR: RELEASE_TARGET is required for release events}"
21+
# Look up the release to get target_commitish
22+
local release_json
23+
if ! release_json=$(gh release view "$version" --json 'isDraft,targetCommitish' 2>/dev/null); then
24+
echo "ERROR: No release found for version $version" >&2
25+
exit 1
26+
fi
5227

53-
version="$RELEASE_TAG_NAME"
54-
ref="$RELEASE_TARGET"
28+
local is_draft
29+
is_draft=$(jq -r '.isDraft' <<<"$release_json")
30+
if [[ "$is_draft" != "true" ]]; then
31+
echo "ERROR: Release $version is already published. Cannot rebuild a published release." >&2
32+
exit 1
5533
fi
5634

35+
local ref
36+
ref=$(jq -r '.targetCommitish' <<<"$release_json")
37+
5738
{
5839
printf 'version=%s\n' "$version"
5940
printf 'ref=%s\n' "$ref"

.github/workflows/release.yml

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
name: Release
22

33
on:
4-
release:
5-
types: [created, edited]
64
workflow_dispatch:
75
inputs:
86
version:
9-
description: 'Version to rebuild (must match an existing draft release, e.g., v1.0.2)'
7+
description: 'Version to build (must match an existing draft release, e.g., v1.0.2)'
108
required: true
119
type: string
1210

@@ -15,50 +13,28 @@ jobs:
1513
# targeting an explicit commit SHA.
1614
validate:
1715
name: Validate Release
18-
# For release events, only run for draft releases.
19-
# For workflow_dispatch, always run (we check draft status in a step).
20-
if: github.event_name == 'workflow_dispatch' || github.event.release.draft == true
2116
runs-on: ubuntu-latest
2217
outputs:
2318
version: ${{ steps.resolve.outputs.version }}
2419
ref: ${{ steps.resolve.outputs.ref }}
25-
skip: ${{ steps.check_changes.outputs.skip }}
2620

2721
steps:
2822
- name: Checkout code
2923
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
30-
with:
31-
# For release events on drafts, GITHUB_REF points to a tag that
32-
# doesn't exist yet. Use the release target or fall back to the
33-
# default branch for workflow_dispatch.
34-
ref: ${{ github.event.release.target_commitish || github.sha }}
35-
36-
- name: Check if edit is meaningful
37-
id: check_changes
38-
if: github.event.action == 'edited'
39-
env:
40-
CHANGES_JSON: ${{ toJSON(github.event.changes) }}
41-
run: .github/scripts/release/check-edit-meaningful.sh
4224

4325
- name: Resolve version and ref
4426
id: resolve
45-
if: steps.check_changes.outputs.skip != 'true'
4627
env:
47-
EVENT_NAME: ${{ github.event_name }}
4828
INPUT_VERSION: ${{ inputs.version }}
49-
RELEASE_TAG_NAME: ${{ github.event.release.tag_name }}
50-
RELEASE_TARGET: ${{ github.event.release.target_commitish }}
5129
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5230
run: .github/scripts/release/resolve-version-ref.sh
5331

5432
- name: Validate semver
55-
if: steps.check_changes.outputs.skip != 'true'
5633
env:
5734
VERSION: ${{ steps.resolve.outputs.version }}
5835
run: .github/scripts/release/validate-semver.sh "$VERSION"
5936

6037
- name: Enforce commit SHA target
61-
if: steps.check_changes.outputs.skip != 'true'
6238
env:
6339
REF: ${{ steps.resolve.outputs.ref }}
6440
run: .github/scripts/release/enforce-commit-sha.sh "$REF"
@@ -67,7 +43,6 @@ jobs:
6743
build-and-sign:
6844
name: Build and Sign All Binaries
6945
needs: validate
70-
if: needs.validate.outputs.skip != 'true'
7146
uses: ./.github/workflows/build.yml
7247
with:
7348
version: ${{ needs.validate.outputs.version }}
@@ -83,7 +58,6 @@ jobs:
8358
upload-assets:
8459
name: Upload Release Assets
8560
needs: [validate, build-and-sign]
86-
if: needs.validate.outputs.skip != 'true'
8761
runs-on: ubuntu-latest
8862
permissions:
8963
contents: write

docs/src/content/docs/07-process/03-releases.mdx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ To release a new version of Terragrunt:
3838

3939
4. Set the release title to the version tag (e.g., `v1.0.2`).
4040

41-
5. Click **Save draft**. This automatically triggers the Release workflow via the `release: created` event.
41+
5. Click **Save draft**.
4242

43-
6. Monitor the [GitHub Actions workflow run](https://github.com/gruntwork-io/terragrunt/actions/workflows/release.yml). It will:
43+
6. Trigger the [Release workflow](https://github.com/gruntwork-io/terragrunt/actions/workflows/release.yml) via **Run workflow**, providing the version string you just drafted (e.g., `v1.0.2`). The workflow looks up the draft release, reads its target commit SHA, and will:
4444
- Validate the tag is a valid semantic version
4545
- Verify the target is a commit SHA (not a branch name)
4646
- Build binaries for every supported OS and architecture
@@ -52,8 +52,8 @@ To release a new version of Terragrunt:
5252

5353
8. Write or finalize the release notes.
5454

55-
<Aside type="caution" title="Editing a draft triggers a rebuild">
56-
Editing a draft release (other than just updating the release notes) will re-trigger the build workflow to ensure assets always match the current release configuration. Release note edits alone do not trigger a rebuild.
55+
<Aside type="note" title="Re-running after edits">
56+
If you edit the draft (for example, to retarget a new commit SHA), re-run the Release workflow with the same version to rebuild and overwrite the assets. Editing the draft does not automatically trigger a rebuild.
5757
</Aside>
5858

5959
9. When ready:
@@ -64,10 +64,7 @@ To release a new version of Terragrunt:
6464

6565
### Retrying a Failed Build
6666

67-
If the build workflow fails mid-way:
68-
69-
- **Edit the draft** (e.g., point it at a new commit) to re-trigger the workflow. Assets are automatically overwritten.
70-
- Alternatively, use the **workflow_dispatch** trigger on the Release workflow, providing the version string (e.g., `v1.0.2`). This looks up the existing draft release and rebuilds.
67+
If the build workflow fails mid-way, re-run the Release workflow via **workflow_dispatch** with the same version (e.g., `v1.0.2`). It looks up the existing draft release and rebuilds, overwriting any previously uploaded assets.
7168

7269
## Pre-releases
7370

0 commit comments

Comments
 (0)