Skip to content

Commit 4e324a7

Browse files
Ci/cicd for semver (#81)
* Feat: Added semver for sdk package via CI/CD * fix: replaced setup-node's built-in cache: 'pnpm' (which fails with custom checkout paths) with manual caching via actions/cache@v4. * fix: added lock file and updated .npmrc * fix: changed everything to npm and fix the .npmrc --------- Co-authored-by: Kratos2k7 <umernadeem321@gmail.com>
1 parent 242c36c commit 4e324a7

File tree

7 files changed

+133
-7
lines changed

7 files changed

+133
-7
lines changed

.github/dependabot.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "npm"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
allow:
8+
- dependency-name: "@shotstack/schemas"
9+
- dependency-name: "@shotstack/shotstack-canvas"
10+
commit-message:
11+
prefix: "chore"
12+
include: "scope"

.github/workflows/ci.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
name: CI
2-
32
on:
4-
push:
5-
branches: [main]
63
pull_request:
74
branches: [main]
85

@@ -20,6 +17,7 @@ jobs:
2017
steps:
2118
- uses: actions/checkout@v4
2219
with:
20+
fetch-depth: 0
2321
path: shotstack-studio-sdk
2422

2523
- uses: actions/setup-node@v4
@@ -30,7 +28,7 @@ jobs:
3028
working-directory: shotstack-studio-sdk
3129
run: npm install
3230

33-
- name: Run public verification suite
31+
- name: Run verification suite
3432
working-directory: shotstack-studio-sdk
3533
run: npm run verify:ci
3634

@@ -42,7 +40,6 @@ jobs:
4240
path: shotstack-studio-sdk/coverage/
4341
retention-days: 14
4442

45-
# ── Extended regression suite (skipped on forks) ─────────────
4643
- name: "[Extended] Set up SSH for regression suite"
4744
if: env.HAS_EXTENDED_TESTS == 'true'
4845
uses: webfactory/ssh-agent@v0.9.0
@@ -62,3 +59,9 @@ jobs:
6259
if: env.HAS_EXTENDED_TESTS == 'true'
6360
working-directory: shotstack-studio-extended-regression-suite
6461
run: npm test
62+
63+
- name: Dry run release
64+
working-directory: shotstack-studio-sdk
65+
env:
66+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67+
run: npx semantic-release --dry-run

.github/workflows/release.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Release
2+
on:
3+
push:
4+
branches: [main]
5+
6+
permissions:
7+
contents: read
8+
9+
jobs:
10+
release:
11+
name: Verify & Release
12+
runs-on: ubuntu-latest
13+
14+
permissions:
15+
contents: write
16+
issues: write
17+
pull-requests: write
18+
id-token: write
19+
20+
env:
21+
HAS_EXTENDED_TESTS: ${{ secrets.EXTENDED_REGRESSION_SSH_KEY != '' }}
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 0
27+
path: shotstack-studio-sdk
28+
29+
- uses: actions/setup-node@v4
30+
with:
31+
node-version: 22
32+
33+
- name: Install dependencies
34+
working-directory: shotstack-studio-sdk
35+
run: npm install
36+
37+
- name: Run verification suite
38+
working-directory: shotstack-studio-sdk
39+
run: npm run verify:ci
40+
41+
- name: Upload coverage report
42+
if: always()
43+
uses: actions/upload-artifact@v4
44+
with:
45+
name: coverage-report
46+
path: shotstack-studio-sdk/coverage/
47+
retention-days: 14
48+
49+
- name: "[Extended] Set up SSH for regression suite"
50+
if: env.HAS_EXTENDED_TESTS == 'true'
51+
uses: webfactory/ssh-agent@v0.9.0
52+
with:
53+
ssh-private-key: ${{ secrets.EXTENDED_REGRESSION_SSH_KEY }}
54+
55+
- name: "[Extended] Clone regression suite"
56+
if: env.HAS_EXTENDED_TESTS == 'true'
57+
run: git clone git@github.com:shotstack/shotstack-studio-extended-regression-suite.git
58+
59+
- name: "[Extended] Install test dependencies"
60+
if: env.HAS_EXTENDED_TESTS == 'true'
61+
working-directory: shotstack-studio-extended-regression-suite
62+
run: npm install
63+
64+
- name: "[Extended] Run behavioural regression tests"
65+
if: env.HAS_EXTENDED_TESTS == 'true'
66+
working-directory: shotstack-studio-extended-regression-suite
67+
run: npm test
68+
69+
- name: Release
70+
working-directory: shotstack-studio-sdk
71+
env:
72+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
73+
run: npx semantic-release

.npmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
package-lock=false
1+
package-lock=false

.releaserc.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"branches": ["main"],
3+
"plugins": [
4+
"@semantic-release/commit-analyzer",
5+
"@semantic-release/release-notes-generator",
6+
"@semantic-release/changelog",
7+
["@semantic-release/npm", {
8+
"pkgRoot": "."
9+
}],
10+
["@semantic-release/git", {
11+
"assets": ["package.json", "CHANGELOG.md"],
12+
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
13+
}],
14+
"@semantic-release/github"
15+
]
16+
}

package.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,16 @@
6565
"format": "prettier --ignore-path .gitignore --write .",
6666
"verify:ci": "npm run lint && npm run typecheck && npm run test:coverage && npm run build && npm run test:package",
6767
"release:check": "npm run verify:ci && npm run test:extended && npm pack --dry-run --json",
68-
"prepublishOnly": "npm run release:check",
68+
"prepublishOnly": "node scripts/publish-guard.cjs",
6969
"generate:fonts": "npx tsx scripts/fetch-google-fonts.ts"
7070
},
7171
"devDependencies": {
72+
"@semantic-release/changelog": "^6.0.3",
73+
"@semantic-release/commit-analyzer": "^13.0.1",
74+
"@semantic-release/git": "^10.0.1",
75+
"@semantic-release/github": "^12.0.6",
76+
"@semantic-release/npm": "^13.1.5",
77+
"@semantic-release/release-notes-generator": "^14.1.0",
7278
"@types/howler": "^2.2.12",
7379
"@types/jest": "^30.0.0",
7480
"@types/node": "^22.9.0",
@@ -83,6 +89,7 @@
8389
"jest": "^30.2.0",
8490
"jest-environment-jsdom": "^30.2.0",
8591
"prettier": "^3.6.2",
92+
"semantic-release": "^25.0.3",
8693
"ts-jest": "^29.4.5",
8794
"typescript": "^5.6.2",
8895
"vite": "^5.4.10",
@@ -97,5 +104,9 @@
97104
"pixi-filters": "^6.0.5",
98105
"pixi.js": "^8.15.0",
99106
"zod": "^4.0.0"
107+
},
108+
"publishConfig": {
109+
"access": "public",
110+
"registry": "https://registry.npmjs.org/"
100111
}
101112
}

scripts/publish-guard.cjs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
if (!process.env.CI) {
2+
console.error(
3+
"\n" +
4+
"========================================\n" +
5+
" Do not run npm/pnpm publish locally.\n" +
6+
" Releases are managed by CI pipeline.\n" +
7+
" Push to main to trigger a release.\n" +
8+
"========================================\n"
9+
);
10+
process.exit(1);
11+
}

0 commit comments

Comments
 (0)