Skip to content

Improve workflows

Improve workflows #1

Workflow file for this run

name: Publish
on:
push:
branches: main
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: write
environment: production
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 20
cache: "yarn"
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Test
run: yarn test
- name: Get package version
run: node -p -e '`PACKAGE_VERSION=${require("./package.json").version}`' >> $GITHUB_ENV
- name: Check previous tags
uses: mukunku/tag-exists-action@v1.4.0
id: checkTag
with:
tag: v${{ env.PACKAGE_VERSION }}
- name: Build
if: steps.checkTag.outputs.exists == 'false'
run: yarn build && yarn postbuild
- name: Tag new version
if: steps.checkTag.outputs.exists == 'false'
uses: anothrNick/github-tag-action@1.67.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CUSTOM_TAG: v${{ env.PACKAGE_VERSION }}
- name: Publish
if: steps.checkTag.outputs.exists == 'false'
uses: JS-DevTools/npm-publish@v3
with:
token: ${{ secrets.NPM_TOKEN }}