Skip to content

Commit

Permalink
feat: pre-release workflow (#2910)
Browse files Browse the repository at this point in the history
* feat(workflow): pre-release

* feat(workflow): exit pre-release

* chore(workflow): update version & publish commands

* fix(workflow): add missing attributes and use schangeset:beta cmd

* feat(root): add changeset:beta

* fix(workflows): revise pre-release logic

* fix(workflows): add missing run

* fix(workflows): use changeset:exit with version instead

* feat(root): add changeset:exit cmd

* refactor(workflows): add pths, id, and format

* feat(workflows): enter pre-release mode

* chore(workflows): remove pre.json only

* refactor(workflows): remove enter-pre-release-mode

* fix(workflows): incorrect url

* refactor(root): remove unused exit command

* refactor(workflows): add comments

* feat(changeset): change to main branch as baseBranch

* feat(root): add changeset:canary

* refactor(workflows): remove unused workflow

* feat(workflow): support canary pre-release mode

* refactor(docs): change to canary
  • Loading branch information
wingkwong authored Nov 4, 2024
1 parent 7c2c9c4 commit 80f6cf5
Show file tree
Hide file tree
Showing 9 changed files with 144 additions and 70 deletions.
2 changes: 1 addition & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"fixed": [],
"linked": [],
"access": "public",
"baseBranch": "canary",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH": {
"onlyUpdatePeerDependentsWhenOutOfRange": true
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/enter-pre-release-mode.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Enter pre-release mode
on: workflow_dispatch

jobs:
enter-pre-release-mode:
if: ${{ github.ref == 'refs/heads/beta/release-next' || github.ref == 'refs/heads/canary' }}
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
id-token: write
steps:
- name: Checkout branch
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install
uses: ./.github/common-actions/install

- name: Enter pre-release mode
id: enter-pre-release-mode
run: |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
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
37 changes: 37 additions & 0 deletions .github/workflows/exit-pre-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Exit pre-release mode

on: workflow_dispatch
jobs:
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
pull-requests: write
id-token: write

steps:
- name: Checkout branch
uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.branch }}
fetch-depth: 0

- name: Install
uses: ./.github/common-actions/install

- name: remove pre.json
# we only remove .changeset/pre.json here
# 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

- name: Commit and push changes
run: |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
git add -A
git commit -m "ci(changesets): exit pre-release mode"
git push
64 changes: 64 additions & 0 deletions .github/workflows/pre-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Pre-release

on:
push:
paths:
- ".changeset/**"
- "packages/**"
branches:
- "beta/release-next"
- "canary"

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

jobs:
prerelease:
name: changesets pre-release
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
id-token: write
steps:
- name: Checkout branch
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install
uses: ./.github/common-actions/install

- name: Check if pre.json exists
id: check_if_pre_json_exists
uses: andstor/[email protected]
with:
files: ".changeset/pre.json"

- name: Get pre-release changesets
id: get-pre-release-changesets
uses: notiz-dev/github-action-json-property@release
with:
path: ".changeset/pre.json"
prop_path: "changesets"

- name: Create pre-release PR
id: create-pre-release-pr
if: "${{ steps.check_if_pre_json_exists.outputs.files_exists == 'true' && !startsWith(github.event.head_commit.message, 'ci(changesets): version packages') }}"
uses: changesets/action@v1
with:
version: pnpm run version
title: "ci(changesets): :package: version packages"
commit: "ci(changesets): version packages"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish to NPM
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
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
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/owner/repo/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 }}
43 changes: 0 additions & 43 deletions .github/workflows/sync-canary-to-main.yaml

This file was deleted.

8 changes: 4 additions & 4 deletions apps/docs/components/sandpack/use-sandpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,14 @@ export const useSandpack = ({

// if (hasComponents) {
// let deps = {
// "@nextui-org/theme": "dev-v2",
// "@nextui-org/system": "dev-v2",
// "@nextui-org/theme": "canary",
// "@nextui-org/system": "canary",
// };

// nextUIComponents.forEach((component) => {
// deps = {
// ...deps,
// [`@nextui-org/${component}`]: "dev-v2",
// [`@nextui-org/${component}`]: "canary",
// };
// });

Expand All @@ -164,7 +164,7 @@ export const useSandpack = ({

// return {
// ...deps,
// "@nextui-org/react": "dev-v2",
// "@nextui-org/react": "canary",
// };
// }, [hasComponents, nextUIComponents, component]);

Expand Down
2 changes: 1 addition & 1 deletion apps/docs/preinstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fs.readFile("./package.json", "utf8", function (err, data) {
// Check if the package is in the @nextui-org namespace and has "workspace:*" as its version
if (pkg.startsWith("@nextui-org/") && packageJson.dependencies[pkg] === "workspace:*") {
// Get the latest version of the package under the specified tag
const latestVersion = execSync(`npm show ${pkg}@dev-v2 version`, {encoding: "utf8"}).trim();
const latestVersion = execSync(`npm show ${pkg}@canary version`, {encoding: "utf8"}).trim();

// Replace the version in the package.json file
packageJson.dependencies[pkg] = latestVersion;
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
"create:cmp": "plop component",
"create:pkg": "plop package",
"create:hook": "plop hook",
"changeset:canary": "changeset pre enter canary",
"changeset:beta": "changeset pre enter beta",
"version": "changeset version",
"release": "changeset publish",
"version:canary": "changeset version --snapshot canary",
Expand Down

0 comments on commit 80f6cf5

Please sign in to comment.