Skip to content

Commit 85535be

Browse files
committed
[chore] added init-icon-prerelease script
1 parent cadf771 commit 85535be

File tree

5 files changed

+128
-1
lines changed

5 files changed

+128
-1
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: init-icon-prerelease
2+
on:
3+
workflow_dispatch:
4+
branch:
5+
- master
6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.ref }}
8+
jobs:
9+
check-exist-pr:
10+
runs-on: ubuntu-latest
11+
env:
12+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
13+
steps:
14+
- uses: actions/[email protected]
15+
- name: check-not-merged-pr
16+
run: |
17+
prs=$(gh pr list \
18+
--base 'master' \
19+
--json title \
20+
-A semrush-ci-whale \
21+
-S 'Merge release tag into master' \
22+
--jq 'length')
23+
if ((prs > 0)); then
24+
echo "Merge exist PR with last release to the master first"
25+
exit 1
26+
fi
27+
init-prerelease:
28+
runs-on: ubuntu-latest
29+
needs:
30+
- check-exist-pr
31+
steps:
32+
- uses: actions/[email protected]
33+
with:
34+
token: ${{ secrets.BOT_ACCOUNT_GITHUB_TOKEN }}
35+
fetch-depth: 0
36+
persist-credentials: false
37+
- uses: pnpm/[email protected]
38+
name: Install pnpm
39+
id: pnpm-install
40+
with:
41+
version: 10.11.1
42+
run_install: false
43+
- uses: actions/[email protected]
44+
- name: Get pnpm store directory
45+
id: pnpm-cache
46+
run: |
47+
echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT
48+
- uses: actions/cache@v4
49+
name: Restore pnpm cache
50+
with:
51+
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
52+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
53+
- name: Install restored dependencies
54+
run: |
55+
pnpm install
56+
- name: Github GPG Auth
57+
uses: crazy-max/ghaction-import-gpg@72b6676b71ab476b77e676928516f6982eef7a41
58+
with:
59+
gpg_private_key: ${{ secrets.BOT_ACCOUNT_GPG_PRIVATE_KEY }}
60+
git_user_signingkey: true
61+
git_commit_gpgsign: true
62+
git_committer_name: semrush-ci-whale
63+
git_committer_email: [email protected]
64+
- name: NPM setup
65+
run: |
66+
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> ".npmrc"
67+
echo "strict-peer-dependencies=false" >> ".npmrc"
68+
- name: NPM auth check
69+
run: pnpm whoami
70+
- name: Init prerelease
71+
env:
72+
GITHUB_SECRET: ${{ secrets.BOT_ACCOUNT_GITHUB_TOKEN }}
73+
run: |
74+
git config user.name "semrush-ci-whale"
75+
git config user.email "[email protected]"
76+
git remote set-url origin "https://${GITHUB_SECRET}@github.com/semrush/intergalactic.git"
77+
pnpm init-icon-prerelease
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env tsm
2+
3+
/**
4+
* Options:
5+
* --check
6+
* --dry-run
7+
*/
8+
import { initIconPrerelease } from '../index';
9+
10+
await initIconPrerelease();

tools/continuous-delivery/index.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,33 @@ export const initPrerelease = async () => {
7878
}
7979
};
8080

81+
export const initIconPrerelease = async () => {
82+
const npmData = await fetchFromNpm(['@semcore/icon']);
83+
84+
const packages = await collectPackages(npmData);
85+
const iconPackage = packages.find((pkg) => pkg.name === '@semcore/icon');
86+
87+
if (!iconPackage) {
88+
console.log('No icon package found.');
89+
process.exit();
90+
}
91+
92+
const versionPatches = await makeVersionPatches([iconPackage]);
93+
94+
if (versionPatches.length === 1) {
95+
await updateVersions(
96+
versionPatches.map((patch) => {
97+
return {
98+
name: patch.package.name,
99+
version: patch.to,
100+
};
101+
}),
102+
);
103+
104+
await gitUtils.initNewPrerelease(versionPatches);
105+
}
106+
};
107+
81108
export const uploadStatic = async () => {
82109
const updatedPackages = await gitUtils.getUpdatedPackages();
83110
const prerelease = await gitUtils.getPrerelease();

tools/continuous-delivery/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"main": "index.ts",
55
"bin": {
66
"init-prerelease": "bin/init-prerelease.ts",
7+
"init-icon-prerelease": "bin/init-icon-prerelease.ts",
78
"publish-prerelease": "bin/publish-prerelease.ts",
89
"publish-release": "bin/publish-release.ts",
910
"upload-static": "bin/upload-static.ts",

tools/continuous-delivery/src/utils/gitUtils.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ export const gitUtils = {
2121
await gitUtils.commitNewPrerelease(versionPatches);
2222
const tag = await gitUtils.createPrereleaseTag(semcoreUiPatch);
2323
await gitUtils.push(tag);
24+
} else if (versionPatches.length === 1 && versionPatches[0].package.name === '@semcore/icon') {
25+
const newPrereleaseBranch = `prerelease/icon${versionPatches[0].to}`;
26+
await git.checkout(['-b', newPrereleaseBranch]);
27+
28+
await NpmUtils.updateLockFile();
29+
await gitUtils.commitNewPrerelease(versionPatches);
30+
const tag = await gitUtils.createPrereleaseTag(versionPatches[0]);
31+
await gitUtils.push(tag);
2432
}
2533
},
2634

@@ -88,7 +96,11 @@ export const gitUtils = {
8896
},
8997

9098
createPrereleaseTag: async (patch: VersionPatch) => {
91-
const tagNamePrefix = `v${patch.to}-${prerelaseSuffix}.`;
99+
let tagPrefix = 'v';
100+
if (patch.package.name === '@semcore/icon') {
101+
tagPrefix = 'icon';
102+
}
103+
const tagNamePrefix = `${tagPrefix}${patch.to}-${prerelaseSuffix}.`;
92104

93105
const tag = await gitUtils.getTag(tagNamePrefix);
94106
const prerelease = tag?.split('-')[1] ?? null;

0 commit comments

Comments
 (0)