Release 3.21.15 #51
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: Publish to npm | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build-and-publish: | |
name: Build and Publish | |
runs-on: ubuntu-latest | |
env: | |
valid_commit: false | |
steps: | |
- name: Checkout repository | |
uses: actions/[email protected] | |
- name: Check commit message | |
id: check_commit | |
run: | | |
COMMIT_MESSAGE=$(git log --format=%B -n 1 $GITHUB_SHA) | |
if [[ $COMMIT_MESSAGE =~ ^Release\ [0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
echo "Commit message is valid. Proceeding with build and publish." | |
echo "valid_commit=true" >> $GITHUB_ENV | |
else | |
echo "Commit message does not match the pattern. Skipping build and publish." | |
echo "valid_commit=false" >> $GITHUB_ENV | |
fi | |
- name: Set up pnpm | |
uses: pnpm/action-setup@v3 | |
with: | |
version: 8 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
registry-url: "https://registry.npmjs.org" | |
- name: Install dependencies | |
run: pnpm install --frozen-lockfile | |
if: env.valid_commit == 'true' | |
- name: Build the project | |
run: pnpm run build | |
if: env.valid_commit == 'true' | |
- name: Publish to npm | |
run: pnpm publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
if: env.valid_commit == 'true' |