Skip to content

Commit 6390721

Browse files
committed
chore: update release workflow - build after version bump (#13034)
**Summary** Fixes incorrect version in VersionInfo.js during releases. Previously, the build ran before version bump, causing the published packages to contain the old version (e.g., 2.19.0-rc.3 instead of 2.19.0). **Changes** Reordered release workflow steps to: 1. Version Bump (local only) - Uses --no-push to update versions locally without pushing 2. Build - Now runs after version bump, so VersionInfo.js has the correct version 3. Push and Create GitHub Release - Pushes commit/tags and creates release using changelog content
1 parent a926cd9 commit 6390721

2 files changed

Lines changed: 121 additions & 16 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { promises as fs } from 'node:fs';
2+
3+
/**
4+
* Extracts the changelog section for a specific version from CHANGELOG.md
5+
* @param {string} changelog - The full changelog content
6+
* @param {string} version - The version to extract (e.g., "2.19.0")
7+
* @returns {string} The changelog section for that version
8+
*/
9+
const extractVersionChangelog = (changelog, version) => {
10+
const escapedVersion = version.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
11+
const regex = new RegExp(`^# \\[${escapedVersion}\\].*?\\n([\\s\\S]*?)(?=^# \\[|$)`, 'm');
12+
const match = changelog.match(regex);
13+
14+
if (match) {
15+
return match[1].trim();
16+
}
17+
18+
return `Release v${version}`;
19+
};
20+
21+
export default async function run() {
22+
const lerna = await fs.readFile(new URL('../../lerna.json', import.meta.url), 'utf8');
23+
const { version } = JSON.parse(lerna);
24+
25+
try {
26+
const changelog = await fs.readFile(new URL('../../CHANGELOG.md', import.meta.url), 'utf8');
27+
const body = extractVersionChangelog(changelog, version);
28+
29+
console.log(body);
30+
return body;
31+
} catch (error) {
32+
console.error('Error extracting changelog:', error);
33+
return `Release v${version}`;
34+
}
35+
}

.github/workflows/release.yaml

Lines changed: 86 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -51,21 +51,44 @@ jobs:
5151
- name: Install Dependencies
5252
run: yarn --immutable
5353

54-
- name: Build
55-
run: yarn ci:releasebuild
56-
5754
- name: Version Bump
5855
env:
5956
GH_TOKEN: ${{ secrets.UI5_WEBCOMP_BOT_GH_TOKEN }}
6057
run: |
6158
git config user.name "${{ secrets.UI5_WEBCOMP_BOT_NAME }}"
6259
git config user.email "${{ secrets.UI5_WEBCOMP_BOT_EMAIL }}"
63-
yarn lerna version ${{ github.event.inputs.new_version || '' }} \
60+
yarn lerna version ${{ github.event.inputs.new_version || '' }} \
6461
--conventional-graduate \
6562
--force-conventional-graduate \
6663
--yes \
6764
--exact \
68-
--create-release github
65+
--no-push
66+
67+
- name: Build
68+
run: yarn ci:releasebuild
69+
70+
- name: Push Changes
71+
run: |
72+
git push origin HEAD
73+
git push origin --tags
74+
75+
- name: Create GitHub Release
76+
uses: actions/github-script@v7
77+
env:
78+
GH_TOKEN: ${{ secrets.UI5_WEBCOMP_BOT_GH_TOKEN }}
79+
with:
80+
github-token: ${{ secrets.UI5_WEBCOMP_BOT_GH_TOKEN }}
81+
script: |
82+
const extractChangelog = (await import('${{ github.workspace }}/.github/actions/extractChangelog.mjs')).default;
83+
const changelog = await extractChangelog();
84+
const version = require('./lerna.json').version;
85+
await github.rest.repos.createRelease({
86+
owner: context.repo.owner,
87+
repo: context.repo.repo,
88+
tag_name: `v${version}`,
89+
name: `v${version}`,
90+
body: changelog,
91+
});
6992
7093
- name: Publish
7194
run: |
@@ -135,9 +158,6 @@ jobs:
135158
- name: Install Dependencies
136159
run: yarn --immutable
137160

138-
- name: Build
139-
run: yarn ci:releasebuild
140-
141161
- name: Version Bump
142162
env:
143163
GH_TOKEN: ${{ secrets.UI5_WEBCOMP_BOT_GH_TOKEN }}
@@ -149,7 +169,34 @@ jobs:
149169
--force-publish \
150170
--yes \
151171
--exact \
152-
--create-release github
172+
--no-push
173+
174+
- name: Build
175+
run: yarn ci:releasebuild
176+
177+
- name: Push Changes
178+
run: |
179+
git push origin HEAD
180+
git push origin --tags
181+
182+
- name: Create GitHub Release
183+
uses: actions/github-script@v7
184+
env:
185+
GH_TOKEN: ${{ secrets.UI5_WEBCOMP_BOT_GH_TOKEN }}
186+
with:
187+
github-token: ${{ secrets.UI5_WEBCOMP_BOT_GH_TOKEN }}
188+
script: |
189+
const extractChangelog = (await import('${{ github.workspace }}/.github/actions/extractChangelog.mjs')).default;
190+
const changelog = await extractChangelog();
191+
const version = require('./lerna.json').version;
192+
await github.rest.repos.createRelease({
193+
owner: context.repo.owner,
194+
repo: context.repo.repo,
195+
tag_name: `v${version}`,
196+
name: `v${version}`,
197+
body: changelog,
198+
prerelease: true,
199+
});
153200
154201
- name: Publish
155202
run: |
@@ -203,9 +250,6 @@ jobs:
203250
- name: Install Dependencies
204251
run: yarn --immutable
205252

206-
- name: Build
207-
run: yarn ci:releasebuild
208-
209253
- name: Version Bump
210254
env:
211255
GH_TOKEN: ${{ secrets.UI5_WEBCOMP_BOT_GH_TOKEN }}
@@ -217,7 +261,33 @@ jobs:
217261
--force-conventional-graduate \
218262
--yes \
219263
--exact \
220-
--create-release github
264+
--no-push
265+
266+
- name: Build
267+
run: yarn ci:releasebuild
268+
269+
- name: Push Changes
270+
run: |
271+
git push origin HEAD
272+
git push origin --tags
273+
274+
- name: Create GitHub Release
275+
uses: actions/github-script@v7
276+
env:
277+
GH_TOKEN: ${{ secrets.UI5_WEBCOMP_BOT_GH_TOKEN }}
278+
with:
279+
github-token: ${{ secrets.UI5_WEBCOMP_BOT_GH_TOKEN }}
280+
script: |
281+
const extractChangelog = (await import('${{ github.workspace }}/.github/actions/extractChangelog.mjs')).default;
282+
const changelog = await extractChangelog();
283+
const version = require('./lerna.json').version;
284+
await github.rest.repos.createRelease({
285+
owner: context.repo.owner,
286+
repo: context.repo.repo,
287+
tag_name: `v${version}`,
288+
name: `v${version}`,
289+
body: changelog,
290+
});
221291
222292
- name: Publish
223293
run: |
@@ -247,9 +317,6 @@ jobs:
247317
- name: Install Dependencies
248318
run: yarn --immutable
249319

250-
- name: Build
251-
run: yarn ci:releasebuild
252-
253320
- name: Version Bump
254321
env:
255322
GH_TOKEN: ${{ secrets.UI5_WEBCOMP_BOT_GH_TOKEN }}
@@ -266,6 +333,9 @@ jobs:
266333
--ignore-changes @ui5/webcomponents-cypress-internal \
267334
--ignore-changes @ui5/webcomponents-cypress-ct
268335
336+
- name: Build
337+
run: yarn ci:releasebuild
338+
269339
- name: Publish
270340
run: |
271341
yarn lerna publish from-git --yes --dist-tag experimental --pre-dist-tag experimental

0 commit comments

Comments
 (0)