Skip to content

Commit

Permalink
feat(workflow): support canary pre-release mode
Browse files Browse the repository at this point in the history
  • Loading branch information
wingkwong committed May 5, 2024
1 parent d8c8049 commit a5b28bb
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 45 deletions.
15 changes: 7 additions & 8 deletions .github/workflows/enter-pre-release-mode.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
# this workflow simply adds `pre.json` under `.changeset` for branch `beta/release-*`
# so that commits pushed to `beta/release-*` would create / update version PR
name: Enter pre-release mode
# the create event doesn't support branch filter and tag filter
# hence, we use on create and check in job level
on: create
on: workflow_dispatch

jobs:
enter-pre-release-mode:
# only run this job for branch `beta/release-*`
if: ${{ startsWith(github.ref, 'refs/heads/beta/release-') }}
if: ${{ github.ref == 'refs/heads/beta/release-next' || github.ref == 'refs/heads/canary' }}
runs-on: ubuntu-latest
permissions:
contents: write
Expand All @@ -28,7 +23,11 @@ jobs:
run: |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
pnpm changeset:beta
if [ ${{ github.ref }} == 'refs/heads/canary' ]; then
pnpm changeset:canary
else
pnpm changeset:beta
fi
git add -A
git commit -m 'chore(pre-release): enter pre-release mode'
git push
19 changes: 6 additions & 13 deletions .github/workflows/exit-pre-release.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
name: Exit pre-release mode

on:
workflow_dispatch:
inputs:
branch:
description: "Exit pre-release mode on beta release branch"
type: string
default: "beta/release-"
required: true

on: workflow_dispatch
jobs:
exit_prerelease:
name: exit pre-release
exit-pre-release-mode:
if: ${{ github.ref == 'refs/heads/beta/release-next' || github.ref == 'refs/heads/canary' }}
name: exit pre-release mode
runs-on: ubuntu-latest
permissions:
contents: write
Expand All @@ -30,8 +23,8 @@ jobs:

- name: remove pre.json
# we only remove .changeset/pre.json here
# since we want to keep the changeset files introduced in this beta/release-* branch
# once we merge it to canary, those files will be removed in version PR in canary
# since we want to keep the changeset files introduced in beta/release-next or canary branch
# once we merge it to canary / main, those files will be removed in version PR in canary
# and converted to corresponding changelogs
run: npx rimraf .changeset/pre.json

Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/pre-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ on:
- ".changeset/**"
- "packages/**"
branches:
- "beta/release-*"
- "beta/release-next"
- "canary"

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

Expand Down Expand Up @@ -52,8 +53,8 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish to NPM
id: publish-beta-to-npm
if: "${{ steps.check_if_pre_json_exists.outputs.files_exists == 'true' && contains(github.event.head_commit.message, 'ci(changesets): :package: version packages (beta)') }}"
id: publish-to-npm
if: "${{ steps.check_if_pre_json_exists.outputs.files_exists == 'true' && contains(github.event.head_commit.message, 'ci(changesets): :package: version packages') }}"
uses: changesets/action@v1
with:
publish: pnpm run release
Expand Down
23 changes: 2 additions & 21 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- ".changeset/**"
- "packages/**"
branches:
- canary
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down Expand Up @@ -39,23 +39,4 @@ jobs:
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Sync files from canary to main branch if a publish happens
if: steps.changesets.outputs.published == 'true'
run: |
curl -X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/nextui-org/nextui/dispatches \
-d '{"event_type":"sync-canary-to-main"}'
- name: Create canary release
if: steps.changesets.outputs.published != 'true'
run: |
git checkout canary
pnpm version:canary
pnpm release:canary
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit a5b28bb

Please sign in to comment.