example: rm * #189
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
name: Release | |
on: | |
push: | |
branches: | |
- main # This makes the workflow only runs by push to branch, not pushed git tag | |
paths-ignore: | |
- '.devbots/**' | |
- '.husky/**' | |
- '.vscode/**' | |
- .editorconfig | |
- commitlint.config.js | |
- license | |
- docs/urls.json | |
pull_request: | |
paths-ignore: | |
- '.devbots/**' | |
- '.husky/**' | |
- '.vscode/**' | |
- .editorconfig | |
- commitlint.config.js | |
- license | |
- docs/urls.json | |
# for `concurrency`, release should be an independent workflow. (e.g. from test, lint, etc) | |
concurrency: ${{ github.workflow }}-${{ github.ref }} | |
jobs: | |
release: | |
name: Release | |
timeout-minutes: 10 | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up pnpm | |
uses: pnpm/action-setup@v2 | |
with: | |
version: 8.6.2 | |
run_install: false # For cache | |
- name: Read .nvmrc | |
id: nvmrc | |
run: echo "version=$(cat .nvmrc)" >> $GITHUB_OUTPUT | |
# pnpm should be installed before the setup-node action. REF: https://github.com/actions/setup-node/issues/530 | |
- name: Set Up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ steps.nvmrc.outputs.version }} | |
cache: pnpm | |
- name: Install Dependencies | |
# rollback to --frozen-lockfile when the issue is fixed | |
# REF: https://github.com/pnpm/pnpm/issues/5144 | |
# run: pnpm install --frozen-lockfile | |
run: pnpm install --no-frozen-lockfile | |
- name: Create Release PR or Publish | |
uses: changesets/action@v1 | |
id: changesets | |
with: | |
commit: 'chore: release' | |
title: 'chore: release' | |
version: pnpm changeset version | |
# Why `pnpm -r publish` instead of `changeset publish`? => For topological publish - REF: https://github.com/changesets/changesets/issues/238 | |
# Why `rm packages/docs/package.json`? => Workaround of REF: https://github.com/changesets/changesets/issues/916 | |
publish: pnpm run changeset:publish | |
createGithubReleases: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
HUSKY: 0 # For changesets/action to commit, let's ignore husky | |
- name: Add deployed docs url | |
# Vercel GitHub bot automatically deploy docs pushed to production branch (`main`), regardless of GitHub Actions. | |
# This step finds out the deployed docs "Preview URL". | |
# Note that Vercel's "Preview URL" is static and permanent unless deleted manually. | |
if: steps.changesets.outputs.published == 'true' | |
run: pnpm --filter '@haetae/docs' run add-url | |
env: | |
VERCEL_ACCESS_TOKEN: ${{ secrets.VERCEL_ACCESS_TOKEN }} | |
VERCEL_DEPLOYMENT_NAME: haetae | |
- uses: stefanzweifel/git-auto-commit-action@v4 | |
if: steps.changesets.outputs.published == 'true' | |
with: | |
commit_message: 'docs: add url' | |
token: ${{ secrets.GITHUB_PERSONAL_ACCESS_TOKEN }} # For Protected branch. REF: https://github.com/stefanzweifel/git-auto-commit-action#push-to-protected-branches | |
env: | |
HUSKY: 0 # To commit, let's ignore husky |