-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use Changesets for changelog and releases (#1)
- Loading branch information
1 parent
1c703bd
commit 88fb5da
Showing
7 changed files
with
1,986 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json", | ||
"changelog": "./format.js", | ||
"commit": false, | ||
"fixed": [], | ||
"linked": [], | ||
"access": "public", | ||
"baseBranch": "main", | ||
"updateInternalDependencies": "patch", | ||
"ignore": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* @type {import('@changesets/types').GetReleaseLine} | ||
*/ | ||
const getReleaseLine = async (changeset, type, changelogOpts) => { | ||
const [firstLine, ...otherLines] = changeset.summary | ||
.trim() | ||
.split('\n') | ||
.map((l) => l.trimEnd()); | ||
|
||
let result = `- ${firstLine}`; | ||
if (otherLines.length > 0) { | ||
result += `\n${otherLines.map((l) => ` ${l}`).join('\n')}`; | ||
} | ||
|
||
return result; | ||
} | ||
|
||
/** | ||
* @type {import('@changesets/types').GetDependencyReleaseLine} | ||
*/ | ||
const getDependencyReleaseLine = async (changesets, dependenciesUpdated, changelogOpts) => { | ||
return ''; | ||
} | ||
|
||
/** | ||
* @type {import('@changesets/types').ChangelogFunctions} | ||
*/ | ||
const changelogFunctions = { | ||
getReleaseLine, | ||
getDependencyReleaseLine, | ||
} | ||
|
||
module.exports = changelogFunctions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const fs = require('node:fs'); | ||
const path = require('node:path'); | ||
|
||
for (const workspace of require('../package.json').workspaces) { | ||
const changelogPath = path.join(__dirname, '..', workspace, 'CHANGELOG.md'); | ||
if (!fs.existsSync(changelogPath)) continue; | ||
let changelog = fs.readFileSync(changelogPath, 'utf8'); | ||
changelog = changelog | ||
.replace(/^### Major Changes/gm, '### 💥 Breaking Changes') | ||
.replace(/^### Minor Changes/gm, '### ✨ Features') | ||
.replace(/^### Patch Changes/gm, '### 🐛 Issues'); | ||
fs.writeFileSync(changelogPath, changelog); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Release | ||
on: | ||
push: | ||
branches: | ||
- main | ||
concurrency: ${{ github.workflow }}-${{ github.ref }} | ||
jobs: | ||
release: | ||
name: Release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v4 | ||
- name: Setup Node.js 20 | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
cache: 'npm' | ||
- name: Install dependencies | ||
run: npm ci --workspaces | ||
- name: Create release PR or publish to npm | ||
id: changesets | ||
uses: changesets/action@v1 | ||
with: | ||
commit: "Release" | ||
title: "Release" | ||
version: npm run changeset:version | ||
publish: npx changeset publish | ||
createGithubReleases: true | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
Oops, something went wrong.