Skip to content

Commit

Permalink
Merge branch 'trunk' into remove-encode
Browse files Browse the repository at this point in the history
Signed-off-by: Sujith <[email protected]>
  • Loading branch information
sujithvn committed Feb 7, 2023
2 parents 3e64a83 + c82c593 commit f7c2834
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 0 deletions.
142 changes: 142 additions & 0 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
name: PRERELEASE
on:
workflow_dispatch:
branches:
- prerelease
pull_request:
types:
- closed

permissions: {}
jobs:
version:
if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/prerelease'
permissions:
contents: write # to create release (changesets/action)
pull-requests: write # to create pull request (changesets/action)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Cache node modules
id: cache-npm
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
key: reaction-v6-node-modules-${{ hashFiles('package.json') }}-${{ hashFiles('pnpm-lock.yaml') }}
path: "**/node_modules"

- name: Use Node.js 14.x
uses: actions/setup-node@v2
with:
node-version: 14

- name: Install pnpm
run: npm i -g pnpm@latest

- name: Install dependencies
run: pnpm install --ignore-scripts

- name: Enter prerelease mode
run: pnpm changeset pre enter next || true

- name: Check should create release
id: should-create-release
run: |
if [[ $(cat ./.changeset/pre.json | grep -m 1 mode | sed 's/[^a-z]//g') == *"pre"* ]]; then
echo "RESULT=true" >> $GITHUB_OUTPUT
else
echo "RESULT=false" >> $GITHUB_OUTPUT
fi
- name: Create Release Pull Request or Publish to npm
id: changesets
if: steps.should-create-release.outputs.RESULT == 'true'
uses: changesets/action@v1
with:
publish: pnpm changeset publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Update pnpm-lock.yaml
id: update-lock-file
if: github.event_name == 'workflow_dispatch'
run: |
pnpm install --ignore-scripts --lockfile-only
if [[ $(git status --porcelain | grep -m 1 pnpm-lock.yaml | sed 's/[^a-z]\-//g') == *"pnpm-lock.yaml"* ]]; then
echo "IS_CHANGED=true" >> $GITHUB_OUTPUT
else
echo "IS_CHANGED=false" >> $GITHUB_OUTPUT
fi
- name: Commit pnpm-lock.yaml
if: steps.update-lock-file.outputs.IS_CHANGED == 'true'
run: |
git config --global user.name "$(git --no-pager log --format=format:'%an' -n 1)"
git config --global user.email "$(git --no-pager log --format=format:'%ae' -n 1)"
git add pnpm-lock.yaml
git commit -m "chore: update pnpm-lock.yaml" -s
git push -u origin changeset-release/prerelease
release:
if: github.event.pull_request.merged == true && github.base_ref == 'prerelease' && github.head_ref == 'changeset-release/prerelease'
permissions:
contents: write # to create release (changesets/action)
pull-requests: write # to create pull request (changesets/action)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Use Node.js 14.x
uses: actions/setup-node@v2
with:
node-version: 14

- name: Install pnpm
run: npm i -g pnpm@latest

- name: Install dependencies
run: pnpm install --ignore-scripts

- name: Enter prerelease mode
run: pnpm changeset pre enter next || true

- name: Check should create release
id: should-create-release
run: |
if [[ $(cat ./.changeset/pre.json | grep -m 1 mode | sed 's/[^a-z]//g') == *"pre"* ]]; then
echo "RESULT=true" >> $GITHUB_OUTPUT
else
echo "RESULT=false" >> $GITHUB_OUTPUT
fi
- name: Create Release Pull Request or Publish to npm
id: changesets
if: steps.should-create-release.outputs.RESULT == 'true'
uses: changesets/action@v1
with:
publish: pnpm changeset publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Exit prerelease mode
id: exit-prerelease-mode
run: |
rm ./.changeset/pre.json
if [[ $(git status --porcelain | grep -m 1 pre.json | sed 's/[^a-z]\-//g') == *"pre.json"* ]]; then
echo "IS_CHANGED=true" >> $GITHUB_OUTPUT
else
echo "IS_CHANGED=false" >> $GITHUB_OUTPUT
fi
- name: Commit pre.json
if: steps.exit-prerelease-mode.outputs.IS_CHANGED == 'true'
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add .changeset/pre.json
git commit -m "chore: exit prerelease mode" -s
git push origin prerelease
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,4 @@ jobs:
committer_name: github-actions[bot]
committer_email: 41898282+github-actions[bot]@users.noreply.github.com
pathspec_error_handling: ignore
commit: --signoff
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ engine-strict=true
auto-install-peers=true
strict-peer-dependencies=false
publish-branch=trunk
prefer-workspace-packages=true
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@ pnpm run start:dev
1. Run `release` action to create `Version PR`. This PR will remove all changeset files, bump up packages versions, update CHANGELOG files.
2. Merge `Version PR` into trunk, CircleCI will publish all the packages into npm.

## Prerelease flows
1. All PRs will be merged into `prerelease` branch before triggering `PRERELEASE` action.
2. Before merging PRs into `prerelease` branch, please make sure that all the changesets are added.
3. Manually trigger `PRERELEASE` action to create `Version Packages (next)` PR. After merged, the changeset/action will bump up packages versions as `{next-version}-next.{number}`, update CHANGELOG files.
4. Merge `Version Packages (next)` PR into `prerelease` branch, action will publish all the packages into npm.

# Get involved
## Contribute

Expand Down

0 comments on commit f7c2834

Please sign in to comment.