Skip to content

🪐 commit

🪐 commit #10

Workflow file for this run

name: Publish
on:
push:
branches:
- '**'
# - main
# concurrency: ${{ github.workflow }}-${{ github.ref }}
permissions:
contents: write
pull-requests: write
jobs:
publish:
# if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: pnpm/action-setup@v3
with:
version: 9
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 23.x
registry-url: 'https://registry.npmjs.org'
cache: 'pnpm'
- name: Test
run: pnpm test
- name: Check the version
id: check
run: |
CURRENT_VERSION=$(jq -r .version package.json)
echo "Current version: $CURRENT_VERSION"
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
echo "Latest tag: $LATEST_TAG"
LATEST_VERSION=${LATEST_TAG#v}
if [ "$LATEST_VERSION" != "$CURRENT_VERSION" ];
then
echo "Version changed"
echo "version_changed=true" >> $GITHUB_OUTPUT
echo "new_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
else
echo "Version not changed"
echo "version_changed=false" >> $GITHUB_OUTPUT
fi
- name: Build
run: pnpm build
if: steps.check.outputs.version_changed == 'true'
- name: Publish
if: steps.check.outputs.version_changed == 'true'
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Tag release
if: steps.check.outputs.version_changed == 'true'
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git tag -a "v${{ steps.check.outputs.new_version }}" -m "v${{ steps.check.outputs.new_version }}"
git push origin "v${{ steps.check.outputs.new_version }}"