Skip to content

Commit da69ac8

Browse files
authored
feat: New changelog-build (#454)
Signed-off-by: Pablo Garay <[email protected]>
1 parent f28af73 commit da69ac8

File tree

1 file changed

+123
-0
lines changed

1 file changed

+123
-0
lines changed
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
name: 'Changelog Build (Release)'
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
last-release-tag:
7+
description: Last Git tag to start from (exclusive) (e.g. `v2.0.0`)
8+
type: string
9+
required: true
10+
release-branch:
11+
description: Release branch to build changelog on (e.g. `r2.1.0`)
12+
type: string
13+
required: true
14+
changelog-main-content:
15+
description: Custom changelog content to include before detailed changelogs
16+
type: string
17+
required: false
18+
default: ''
19+
20+
jobs:
21+
changelog:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout branch
25+
uses: actions/checkout@v4
26+
with:
27+
ref: main
28+
fetch-depth: 0
29+
30+
- name: Build Changelog
31+
id: github_tag
32+
uses: mikepenz/[email protected]
33+
env:
34+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
with:
36+
# Configuration file is setup with filters for domains
37+
# owner:repo must point to current repo
38+
# fromTag: Auto resolved from historical tag order (previous tag compared to current tag)
39+
# toTag: Current tag reference
40+
configuration: ".github/workflows/config/changelog-config.json"
41+
owner: ${{ github.repository_owner }}
42+
repo: ${{ github.event.repository.name }}
43+
ignorePreReleases: "false"
44+
failOnError: "false"
45+
fromTag: ${{ inputs.last-release-tag }}
46+
toTag: ${{ inputs.release-branch }}
47+
48+
- name: Update changelog file
49+
env:
50+
RELEASE_BRANCH: ${{ inputs.release-branch }}
51+
CHANGELOG: ${{ steps.github_tag.outputs.changelog }}
52+
MAIN_CONTENT: ${{ inputs.changelog-main-content }}
53+
shell: bash -x -e -u -o pipefail {0}
54+
run: |
55+
RELEASE_VERSION=${RELEASE_BRANCH#r}
56+
CHANGELOG=$(echo "$CHANGELOG" | sed '/^[[:blank:]]*#/s/#/###/')
57+
58+
# Build release notes starting with version header
59+
RELEASE_NOTES="## NVIDIA Export-Deploy $RELEASE_VERSION"
60+
61+
# Add custom content if provided
62+
if [ -n "$MAIN_CONTENT" ]; then
63+
RELEASE_NOTES="$RELEASE_NOTES
64+
65+
$MAIN_CONTENT"
66+
fi
67+
68+
# Add detailed changelogs section
69+
RELEASE_NOTES="$RELEASE_NOTES
70+
71+
### Detailed Changelogs:
72+
73+
$CHANGELOG"
74+
75+
printf "%s\n" "$RELEASE_NOTES" | sed '/<!-- Next changelog -->/r /dev/stdin' CHANGELOG.md > CHANGELOG.tmp.md
76+
77+
mv CHANGELOG.tmp.md CHANGELOG.md
78+
79+
- name: Inspect new changelog file
80+
run: cat CHANGELOG.md
81+
82+
- name: Create or update label
83+
uses: actions/github-script@v6
84+
with:
85+
script: |
86+
const labelName = '${{ inputs.release-branch }}';
87+
const labelColor = '0366d6'; // Blue color
88+
const labelDescription = `Release ${labelName}`;
89+
90+
try {
91+
// Try to get the label
92+
await github.rest.issues.getLabel({
93+
owner: context.repo.owner,
94+
repo: context.repo.repo,
95+
name: labelName
96+
});
97+
console.log(`Label '${labelName}' already exists`);
98+
} catch (error) {
99+
if (error.status === 404) {
100+
// Label doesn't exist, create it
101+
await github.rest.issues.createLabel({
102+
owner: context.repo.owner,
103+
repo: context.repo.repo,
104+
name: labelName,
105+
color: labelColor,
106+
description: labelDescription
107+
});
108+
console.log(`Created label '${labelName}'`);
109+
} else {
110+
throw error;
111+
}
112+
}
113+
114+
- name: Create Pull Request
115+
uses: peter-evans/create-pull-request@v7
116+
with:
117+
commit-message: "beep boop: Update changelog"
118+
title: "Update changelog for `${{ inputs.release-branch }}`"
119+
signoff: true
120+
sign-commits: true
121+
base: main
122+
branch: bot/chore/update-changelog-into-${{ inputs.release-branch }}
123+
labels: ${{ inputs.release-branch }}

0 commit comments

Comments
 (0)