Skip to content

Commit

Permalink
ci: enhance monorepo release flow with changesets (#884)
Browse files Browse the repository at this point in the history
ci: enhance monorepo release flow with changesets
  • Loading branch information
cheton authored Jul 5, 2024
1 parent 7baee21 commit 8ab8835
Show file tree
Hide file tree
Showing 5 changed files with 694 additions and 15 deletions.
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
11 changes: 11 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": ["@changesets/changelog-github", { "repo": "trendmicro-frontend/tonic-ui" }],
"commit": false,
"fixed": [],
"linked": [],
"access": "public",
"baseBranch": "v2",
"updateInternalDependencies": "patch",
"ignore": []
}
56 changes: 56 additions & 0 deletions .github/workflows/changesets-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# This workflow will release the packages with Changesets

name: Release

on:
push:
branches:
- v2
workflow_dispatch:

concurrency: ${{ github.workflow }}-${{ github.ref }}

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

permissions: {}

jobs:
release:
# [IMPORTANT] Prevent this action from running on forks
if: github.repository == 'trendmicro-frontend/tonic-ui'
permissions:
contents: write # to create release (changesets/action)
issues: write # to post issue comments (changesets/action)
pull-requests: write # to create pull request (changesets/action)
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
with:
# Ensure the full git history is available so that `changesets` can generate changelogs with the correct commits
fetch-depth: 0
- name: Setup Node
id: setup-node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install Dependencies
id: install-dependencies
run: yarn install
- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@master
with:
title: "chore(release): version packages"
commit: "chore(release): version packages [skip ci]"
# This expects you to have a script called release which does a build for your packages and calls `changeset publish`
# publish: yarn ci-publish
# This expects you to have a script called version that runs some logic and then calls `changeset version`.
# version: yarn changeset version
env:
GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }}
#NPM_TOKEN: ${{ env.NPM_TOKEN }}
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
"scripts": {
"build": "lerna exec -- yarn build",
"clean": "lerna exec --parallel -- yarn clean && lerna clean --yes",
"lerna-publish": "lerna publish --no-private",
"lerna-publish-from-git": "lerna publish from-git --no-private",
"lerna-publish-from-package": "lerna publish from-package --no-private",
"changeset": "changeset",
"ci-publish": "yarn build && lerna publish from-package --y --no-private",
"lerna-publish": "yarn build && lerna publish --no-private",
"lerna-publish-from-git": "yarn build && lerna publish from-git --no-private",
"lerna-publish-from-package": "yarn build && lerna publish from-package --no-private",
"lint": "lerna exec -- yarn lint",
"pre-push": "lerna exec -- yarn pre-push",
"prepare": "husky install",
"version": "yarn install && git stage yarn.lock",
"test": "lerna exec -- yarn test"
},
"author": "Cheton Wu",
Expand All @@ -28,6 +29,8 @@
"url": "https://github.com/trendmicro-frontend/tonic-ui/issues"
},
"devDependencies": {
"@changesets/changelog-github": "^0.5.0",
"@changesets/cli": "^2.27.7",
"@commitlint/cli": "17.x",
"@commitlint/config-conventional": "17.x",
"husky": "8.x",
Expand Down
Loading

0 comments on commit 8ab8835

Please sign in to comment.