diff --git a/.github/workflows/release-pr.yml b/.github/workflows/release-pr.yml deleted file mode 100644 index a6e77c4..0000000 --- a/.github/workflows/release-pr.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Release - -on: - push: - branches: - - main - -jobs: - release: - name: Release - runs-on: ubuntu-latest - steps: - - name: Checkout Repo - uses: actions/checkout@v3 - with: - # This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits - fetch-depth: 0 - - - name: Setup Node.js 16.x - uses: actions/setup-node@v3 - with: - node-version: 16.x - - - name: Install Dependencies - run: npm i - - - name: Create Release Pull Request / NPM Publish - uses: changesets/action@v1 - with: - publish: npm run publish-changeset - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..e3e1065 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,68 @@ +on: + push: + branches: + - main +name: release +jobs: + release-pr: + runs-on: ubuntu-latest + outputs: + release_created: ${{ steps.release.outputs.release_created }} + steps: + - uses: google-github-actions/release-please-action@v3 + id: release + with: + release-type: node + token: ${{ secrets.RELEASE_PR_TOKEN }} + changelog-types: |- + [ + { "type": "feat", "section": "๐Ÿ”– Features", "hidden": false }, + { "type": "fix", "section": "๐Ÿ› Bug Fixes", "hidden": false }, + { "type": "chore", "section": "๐Ÿงน Miscellaneous", "hidden": false } + ] + + # Format changelog, workaround for https://github.com/google-github-actions/release-please-action/issues/542 + # Taken from https://github.com/remarkablemark/release-please-extra-files-demo/blob/master/.github/workflows/release-please.yml + - uses: actions/checkout@v3 + if: ${{ steps.release.outputs.pr }} + with: + ref: ${{ fromJson(steps.release.outputs.pr).headBranchName }} + + - name: Configure Git user + if: ${{ steps.release.outputs.pr }} + run: | + git config --global user.name 'github-actions[bot]' + git config --global user.email 'github-actions[bot]@users.noreply.github.com' + git --no-pager show --name-only + + - name: Format CHANGELOG.md + if: ${{ steps.release.outputs.pr }} + run: npx prettier --write CHANGELOG.md + + - name: Commit and push + if: ${{ steps.release.outputs.pr }} + run: | + git add CHANGELOG.md + git commit -m 'chore: Format CHANGELOG.md with Prettier' --no-verify + git push + + publish_npm: + name: Publish to npm + runs-on: ubuntu-latest + needs: [release-pr] + if: needs.release-pr.outputs.release_created + steps: + - uses: actions/checkout@v3 + - run: corepack enable + - uses: actions/setup-node@v3 + with: + node-version: 16 + cache: 'pnpm' + - name: Install dependencies + run: pnpm install + - name: Config npm + run: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + - name: Publish to npm + run: pnpm publish --access public --no-git-checks