Skip to content

Commit c5ef215

Browse files
Introduce Changesets 🎉 (#338)
* add changesets cli and init * install plugin for better changelog format and modify config * add scripts and configure gh action * spacing fixes after rebase
1 parent a1a40a3 commit c5ef215

File tree

5 files changed

+806
-138
lines changed

5 files changed

+806
-138
lines changed

.changeset/README.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Changesets
2+
3+
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4+
with multi-package repos, or single-package repos to help you version and publish your code. You can
5+
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
6+
7+
We have a quick list of common questions to get you started engaging with this project in
8+
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)

.changeset/config.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/config@3.0.5/schema.json",
3+
"changelog": [
4+
"@changesets/changelog-github",
5+
{
6+
"repo": "ngrok-oss/mantle"
7+
}
8+
],
9+
"commit": false,
10+
"fixed": [],
11+
"linked": [],
12+
"access": "public",
13+
"baseBranch": "main",
14+
"updateInternalDependencies": "patch",
15+
"ignore": ["@cfg/*", "www"]
16+
}

.github/workflows/publish-npm.yml

+14-10
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
name: npmjs
2+
23
on:
3-
release:
4-
types: [published]
5-
workflow_dispatch:
4+
push:
5+
branches:
6+
- main
67

78
jobs:
89
publish:
910
runs-on: ubuntu-latest
11+
if: github.repository == 'ngrok-oss/mantle'
1012
env:
1113
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
1214
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
@@ -24,17 +26,19 @@ jobs:
2426

2527
- run: pnpm install
2628

27-
- run: cd packages/mantle && pnpm publish --access public --no-git-checks
29+
- name: Create Release Pull Request or Publish to npm
30+
uses: changesets/action@v1
31+
with:
32+
publish: pnpm release
33+
version: pnpm version
2834
env:
29-
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
30-
31-
- name: Grab the released version and store it in an env variable
32-
run: |
33-
VERSION=$(jq -r '.version' ./packages/mantle/package.json)
34-
echo "MANTLE_VERSION=$VERSION" >> $GITHUB_ENV
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36+
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
3537

3638
- name: Post to slack
39+
if: steps.changesets.outputs.published == 'true'
3740
env:
3841
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_PUBLISH_WEBHOOK_URL }}
42+
MANTLE_VERSION: ${{ steps.changesets.outputs.publishedPackages[0].version }}
3943
run: |
4044
curl -X POST -H 'Content-type: application/json' --data '{"text":"`@ngrok/mantle@${{ env.MANTLE_VERSION }}` published to npm!\nInstall with: `pnpm add -E @ngrok/mantle@${{ env.MANTLE_VERSION }}`\n<https://github.com/ngrok-oss/mantle/releases/tag/v${{ env.MANTLE_VERSION }}|Release Notes>"}' $SLACK_WEBHOOK_URL

package.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,14 @@
1919
"test": "turbo run test",
2020
"test:watch": "turbo run test:watch",
2121
"test:ui": "turbo run test:ui",
22-
"typecheck": "turbo run typecheck"
22+
"typecheck": "turbo run typecheck",
23+
"changeset": "changeset",
24+
"version": "changeset version",
25+
"release": "turbo run build --filter=@ngrok/mantle && changeset publish"
2326
},
2427
"devDependencies": {
28+
"@changesets/changelog-github": "0.5.0",
29+
"@changesets/cli": "2.27.11",
2530
"@ianvs/prettier-plugin-sort-imports": "4.4.1",
2631
"prettier": "3.4.2",
2732
"prettier-plugin-tailwindcss": "0.6.11",

0 commit comments

Comments
 (0)