From 84fd3c6bec605323c7023e9c33c6c8c79b4a0152 Mon Sep 17 00:00:00 2001 From: vanpho93 Date: Mon, 16 Jan 2023 11:03:38 +0700 Subject: [PATCH] feat: exit pre mode when released Signed-off-by: vanpho93 --- .github/workflows/prerelease.yml | 29 ++++++++++++++++++++++------- .github/workflows/release.yml | 1 + .npmrc | 1 + 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml index 2c42303eebc..1f544f34d31 100644 --- a/.github/workflows/prerelease.yml +++ b/.github/workflows/prerelease.yml @@ -10,7 +10,7 @@ on: permissions: {} jobs: version: - if: github.event_name == 'workflow_dispatch' + 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) @@ -42,7 +42,7 @@ jobs: - name: Enter prerelease mode run: pnpm changeset pre enter next || true - + - name: Check should create release id: should-create-release run: | @@ -51,7 +51,6 @@ jobs: 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' @@ -72,16 +71,14 @@ jobs: 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" + 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: @@ -115,7 +112,6 @@ jobs: 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' @@ -125,3 +121,22 @@ jobs: 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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bc466c45b09..8ff82a4f4fc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 diff --git a/.npmrc b/.npmrc index e3d11dd644f..4dea503f1ea 100644 --- a/.npmrc +++ b/.npmrc @@ -2,3 +2,4 @@ engine-strict=true auto-install-peers=true strict-peer-dependencies=false publish-branch=trunk +prefer-workspace-packages=true