Skip to content

Commit 6c0e209

Browse files
committed
ci: setup semantic release
1 parent 8404a00 commit 6c0e209

File tree

12 files changed

+1757
-6
lines changed

12 files changed

+1757
-6
lines changed

.github/workflows/publish.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Publish Packages
2+
3+
on: workflow_dispatch
4+
5+
permissions:
6+
contents: read
7+
8+
jobs:
9+
checks:
10+
uses: ./.github/workflows/checks.yml
11+
secrets: inherit
12+
13+
unit_tests:
14+
uses: ./.github/workflows/unit-tests.yml
15+
secrets: inherit
16+
17+
release:
18+
runs-on: ubuntu-latest
19+
permissions:
20+
contents: write # to be able to publish a GitHub release
21+
issues: write # to be able to comment on released issues
22+
id-token: write # to enable use of OIDC for npm provenance
23+
attestations: write # necessary to persist the attestation
24+
needs: [checks, unit_tests]
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
29+
- name: Install pnpm
30+
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda
31+
32+
- name: Setup node
33+
uses: actions/setup-node@v4
34+
with:
35+
node-version-file: .nvmrc
36+
cache: pnpm
37+
38+
- name: Install Dependencies
39+
run: pnpm install --frozen-lockfile --ignore-scripts
40+
41+
# - name: Configure .npmrc
42+
# run: echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" >> .npmrc
43+
44+
- name: Bump version, add tag, and publish github release
45+
env:
46+
BRANCH: ${{github.ref_name}}
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
49+
NPM_CONFIG_PROVENANCE: true
50+
run: pnpm recursive run release
51+
52+
- name: Remove node_modules
53+
run: |
54+
rm -rf packages/**/node_modules/
55+
56+
- uses: actions/attest-build-provenance@v3
57+
with:
58+
subject-path: packages

.releaserc.mjs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { env } from 'node:process'
2+
3+
const config = {
4+
extends: 'semantic-release-monorepo',
5+
branches: [
6+
'main',
7+
{
8+
name: 'alpha',
9+
channel: 'alpha',
10+
prerelease: true,
11+
},
12+
{
13+
name: 'beta',
14+
channel: 'beta',
15+
prerelease: true,
16+
},
17+
],
18+
preset: 'conventionalcommits',
19+
plugins: [
20+
'@semantic-release/commit-analyzer',
21+
'@semantic-release/release-notes-generator',
22+
// '@sebbo2002/semantic-release-jsr',
23+
'@anolilab/semantic-release-pnpm',
24+
],
25+
}
26+
27+
// NOTE: add BRANCH env in the workflow
28+
if (env.BRANCH === 'main') {
29+
config.plugins.push('@semantic-release/github')
30+
}
31+
32+
export default config

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@
3232
"rollup-plugin-json-map-keys": "workspace:*"
3333
},
3434
"devDependencies": {
35+
"@anolilab/semantic-release-pnpm": "^2.0.4",
3536
"@commitlint/cli": "^19.8.1",
3637
"@commitlint/config-conventional": "^20.0.0",
38+
"@sebbo2002/semantic-release-jsr": "^3.0.1",
3739
"@stryker-mutator/core": "^9.1.1",
3840
"@stryker-mutator/typescript-checker": "^9.1.1",
3941
"@stryker-mutator/vitest-runner": "^9.1.1",
@@ -53,6 +55,8 @@
5355
"remark": "^15.0.1",
5456
"remark-cli": "^12.0.1",
5557
"rollup": "^4.52.4",
58+
"semantic-release": "^24.2.9",
59+
"semantic-release-monorepo": "github:tiagoporto/semantic-release-monorepo",
5660
"vitest": "^3.2.4",
5761
"webpack": "^5.102.0",
5862
"webpack-cli": "^6.0.1"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from '../../.releaserc.mjs'

packages/jest-transformer/package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "json-map-keys-jest",
3-
"version": "1.0.0-beta.1",
3+
"version": "0.0.0-development",
44
"description": "Jest transformer to replace json values with the key path.",
55
"homepage": "https://github.com/tiagoporto/json-map-keys/tree/main/packages/jest-transformer#readme",
66
"keywords": [
@@ -20,6 +20,10 @@
2020
"license": "MIT",
2121
"type": "module",
2222
"main": "./index.mjs",
23+
"scripts": {
24+
"release": "semantic-release",
25+
"release:dry-run": "semantic-release --dry-run"
26+
},
2327
"dependencies": {
2428
"json-map-keys": "^1.0.0-beta.1",
2529
"loader-utils": "^3.3.1"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from '../../.releaserc.mjs'

packages/json-map-keys/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "json-map-keys",
3-
"version": "1.0.0-beta.1",
3+
"version": "0.0.0-development",
44
"type": "module",
55
"description": "Replace json values with the key path.",
66
"homepage": "https://github.com/tiagoporto/json-map-keys/tree/main/packages/json-map-keys#readme",
@@ -30,7 +30,9 @@
3030
],
3131
"scripts": {
3232
"prepack": "pnpm build",
33-
"build": "rm -rf dist && rollup --config"
33+
"build": "rm -rf dist && rollup --config",
34+
"release": "semantic-release",
35+
"release:dry-run": "semantic-release --dry-run"
3436
},
3537
"devDependencies": {
3638
"@rollup/plugin-terser": "^0.4.4",
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from '../../.releaserc.mjs'

packages/rollup-plugin/package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rollup-plugin-json-map-keys",
3-
"version": "1.0.0-beta.1",
3+
"version": "0.0.0-development",
44
"description": "Rollup plugin to replace json values with the key path.",
55
"homepage": "https://github.com/tiagoporto/json-map-keys/tree/main/packages/rollup-plugin#readme",
66
"keywords": [
@@ -20,6 +20,10 @@
2020
"type": "module",
2121
"license": "MIT",
2222
"main": "./index.mjs",
23+
"scripts": {
24+
"release": "semantic-release",
25+
"release:dry-run": "semantic-release --dry-run"
26+
},
2327
"dependencies": {
2428
"@rollup/pluginutils": "^5.3.0",
2529
"json-map-keys": "^1.0.0-beta.1",
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from '../../.releaserc.mjs'

0 commit comments

Comments
 (0)