Apply changesets (v0.0.16) (#12) #43
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Tag and Publish | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
changed: | |
runs-on: ubuntu-latest | |
outputs: | |
pkg: ${{ steps.changes.outputs.pkg }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dorny/paths-filter@v3 | |
id: changes | |
with: | |
filters: | | |
pkg: | |
- 'package.json' | |
check-version: | |
name: publish | |
needs: changed | |
runs-on: ubuntu-latest | |
if: needs.changed.outputs.pkg == 'true' | |
steps: | |
- name: Install Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 | |
sparse-checkout-cone-mode: false | |
sparse-checkout: | | |
package.json | |
- id: current_version | |
name: Read current version | |
run: | | |
PACKAGE_VERSION=$(node -e "console.log(JSON.parse(require('fs').readFileSync('package.json').toString()).version)") | |
echo "value=${PACKAGE_VERSION}" > $GITHUB_OUTPUT | |
- name: Checkout previous commit | |
run: git checkout HEAD^ | |
- id: previous_version | |
name: Read previous version | |
run: | | |
PACKAGE_VERSION=$(node -e "console.log(JSON.parse(require('fs').readFileSync('package.json').toString()).version)") | |
echo "value=${PACKAGE_VERSION}" > $GITHUB_OUTPUT | |
- name: Install PNPM | |
uses: pnpm/action-setup@v3 | |
with: | |
version: 8 | |
- name: Install Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
- name: Install PNPM | |
run: corepack enable pnpm | |
- name: Tag and publish | |
if: steps.current_version.outputs.value != steps.previous_version.outputs.value | |
env: | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
CURRENT_VERSION: ${{ steps.current_version.outputs.value}} | |
run: | | |
git config --global user.name "Black Rabbit" | |
git config --global user.email "[email protected]" | |
git tag -a v${CURRENT_VERSION} -m "v${CURRENT_VERSION}" | |
git push origin v${CURRENT_VERSION} | |
npm config set //registry.npmjs.org/:_authToken "${NPM_TOKEN}" | |
pnpm publish -r --no-git-checks |