Skip to content

Merge pull request #151 from sota1235/dependabot/npm_and_yarn/microma… #144

Merge pull request #151 from sota1235/dependabot/npm_and_yarn/microma…

Merge pull request #151 from sota1235/dependabot/npm_and_yarn/microma… #144

Workflow file for this run

name: Publishing to npm
on:
push:
branches:
- main
tags:
- "!*"
concurrency: publish-to-npm
env:
NODE_VERSION: 20.x
jobs:
check-version:
name: Checking wheather it can be published or not
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
can-publish: ${{ steps.check-status.outputs.can-publish }}
steps:
- uses: actions/checkout@v4
- name: Setting up Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: "https://registry.npmjs.org"
cache: npm
- name: Executing can-npm-publish
id: check-status
run: |
if npx can-npm-publish --verbose; then
echo "can-publish=1" >> "$GITHUB_OUTPUT"
else
echo "Publishing to npm will be skipped"
echo "can-publish=0" >> "$GITHUB_OUTPUT"
fi
release:
name: Releasing
needs: check-version
if: ${{ needs.check-version.outputs.can-publish == '1' }}
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Setting up Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: "https://registry.npmjs.org"
cache: npm
- name: Installing dependencies
run: |
npm ci --no-audit --no-fund
- name: Extract package-version
run: echo "PACKAGE_VERSION=$(node -p -e 'require("./package.json").version')" >> "$GITHUB_ENV"
- name: package-version-to-git-tag
uses: pkgdeps/git-tag-action@ef111413f44ebe5cc05994e7f5b5b9edaaada08d # v3.0.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
github_repo: ${{ github.repository }}
version: ${{ env.PACKAGE_VERSION }}
git_commit_sha: ${{ github.sha }}
git_tag_prefix: "v"
- name: Publishing to npm
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}