Skip to content

Commit 5d31082

Browse files
authored
feat: standardize release-please configuration (#106)
* feat: standardize release-please configuration - Simplify workflow to match ECR pattern by removing custom title logic - Add include-component-in-tag: false to config for consistency - Add pull-request-title-pattern for consistent PR titles - Remove tag-separator to use default behavior - Maintain current version 0.17.0 in manifest * fix: pin GitHub Action and Ubuntu versions for security and reliability - Pin googleapis/release-please-action to v4.2.0 commit hash for security - Pin Ubuntu runner to ubuntu-22.04 for reliability - No tag creation or CHANGELOG changes needed (already uses correct format) * fix: update release-please config to prevent v-prefix in release titles - Remove include-component-in-tag (redundant) - Add tag-separator to explicitly control format - Remove pull-request-title-pattern to avoid interference * feat: add automatic v-prefix removal from release titles - Add post-processing step to automatically clean release titles - Ensures consistent format between git tags and GitHub release titles - Only runs when release is actually created - Provides clear logging and smart detection logic * feat: standardize release-please config format - Use consistent terraform-module configuration - Add include-component-in-tag: false for completeness - Add pull-request-title-pattern for consistency - Remove tag-separator in favor of standard config Ensures all repositories follow the same release-please configuration pattern for terraform modules.
1 parent da1f111 commit 5d31082

2 files changed

Lines changed: 27 additions & 56 deletions

File tree

.github/workflows/release-please.yml

Lines changed: 24 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -7,68 +7,38 @@ on:
77

88
jobs:
99
release-please:
10-
runs-on: ubuntu-latest
10+
runs-on: ubuntu-22.04
1111
outputs:
1212
release_created: ${{ steps.release_please.outputs.release_created }}
1313
steps:
14-
- uses: googleapis/release-please-action@v4
14+
- uses: googleapis/release-please-action@a02a34c4d625f9be7cb89156071d8567266a2445 # v4.2.0
1515
id: release_please
1616
with:
1717
token: ${{ secrets.GITHUB_TOKEN }}
1818
config-file: .release-please-config.json
19-
20-
- name: Remove v prefix from release title
19+
20+
- name: Remove v-prefix from release title
2121
if: ${{ steps.release_please.outputs.release_created }}
22+
env:
23+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2224
run: |
23-
# Get the release ID
24-
RELEASE_ID="${{ steps.release_please.outputs.id }}"
25-
26-
if [ -z "$RELEASE_ID" ]; then
27-
echo "Release ID not found, skipping title update"
28-
exit 0
29-
fi
30-
31-
echo "Processing release ID: $RELEASE_ID"
32-
33-
# Get current release data
34-
RELEASE_DATA=$(curl -s \
35-
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
36-
-H "Accept: application/vnd.github.v3+json" \
37-
"https://api.github.com/repos/${{ github.repository }}/releases/${RELEASE_ID}")
38-
39-
# Extract current title
40-
CURRENT_TITLE=$(echo "$RELEASE_DATA" | jq -r '.name')
41-
42-
if [ "$CURRENT_TITLE" = "null" ] || [ -z "$CURRENT_TITLE" ]; then
43-
echo "Could not retrieve release title, skipping update"
44-
exit 0
45-
fi
46-
47-
echo "Current release title: '$CURRENT_TITLE'"
48-
49-
# Remove 'v' prefix if present (case sensitive, only at the beginning, and only if followed by a digit)
50-
NEW_TITLE=$(echo "$CURRENT_TITLE" | sed 's/^v\([0-9]\)/\1/')
51-
52-
# Only update if the title actually changed
53-
if [ "$CURRENT_TITLE" != "$NEW_TITLE" ]; then
54-
echo "Updating release title from '$CURRENT_TITLE' to '$NEW_TITLE'"
55-
# Use jq to safely construct JSON payload to prevent injection vulnerabilities
56-
JSON_PAYLOAD=$(jq -n --arg name "$NEW_TITLE" '{name: $name}')
57-
RESPONSE=$(curl -s \
58-
-X PATCH \
59-
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
60-
-H "Accept: application/vnd.github.v3+json" \
61-
"https://api.github.com/repos/${{ github.repository }}/releases/${RELEASE_ID}" \
62-
-d "$JSON_PAYLOAD")
63-
64-
# Check if update was successful
65-
UPDATED_TITLE=$(echo "$RESPONSE" | jq -r '.name')
66-
if [ "$UPDATED_TITLE" = "$NEW_TITLE" ]; then
67-
echo "Successfully updated release title to '$NEW_TITLE'"
68-
else
69-
echo "Failed to update release title. Response: $RESPONSE"
70-
exit 1
71-
fi
25+
# Get the release tag and current title
26+
RELEASE_TAG="${{ steps.release_please.outputs.tag_name }}"
27+
echo "Release tag: $RELEASE_TAG"
28+
29+
# Get current release info
30+
CURRENT_RELEASE=$(gh release view "$RELEASE_TAG" --json name,tagName --repo ${{ github.repository }})
31+
CURRENT_NAME=$(echo "$CURRENT_RELEASE" | jq -r '.name')
32+
echo "Current release name: $CURRENT_NAME"
33+
34+
# Check if the release title has v-prefix but tag doesn't
35+
if [[ "$CURRENT_NAME" =~ ^v[0-9] ]] && [[ ! "$RELEASE_TAG" =~ ^v[0-9] ]]; then
36+
# Remove v-prefix from release title to match the clean tag
37+
NEW_NAME="${CURRENT_NAME#v}"
38+
echo "Updating release title from '$CURRENT_NAME' to '$NEW_NAME'"
39+
40+
gh release edit "$RELEASE_TAG" --title "$NEW_NAME" --repo ${{ github.repository }}
41+
echo "✅ Release title updated successfully"
7242
else
73-
echo "Release title '$CURRENT_TITLE' does not need updating"
43+
echo "ℹ️ No v-prefix found in release title or tag already has v-prefix - no changes needed"
7444
fi

.release-please-config.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"release-type": "terraform-module",
55
"changelog-path": "CHANGELOG.md",
66
"include-v-in-tag": false,
7-
"tag-separator": ""
7+
"include-component-in-tag": false
88
}
9-
}
9+
},
10+
"pull-request-title-pattern": "chore: release ${version}"
1011
}

0 commit comments

Comments
 (0)