Skip to content

3.1.0

3.1.0 #30

Workflow file for this run

name: Publish Package

Check failure on line 1 in .github/workflows/publish.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/publish.yml

Invalid workflow file

(Line: 63, Col: 21): The expression is not closed. An unescaped ${{ sequence was found, but the closing }} sequence was not found., (Line: 64, Col: 25): The expression is not closed. An unescaped ${{ sequence was found, but the closing }} sequence was not found.
on:
push:
branches:
- main
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run test
run: npm test
- name: Build
run: npm run build --if-present
- name: Version check
id: check-version
run: |
PACKAGE_NAME=$(node -p "require('./package.json').name")
CURRENT_VERSION=$(node -p "require('./package.json').version")
NPM_VERSION=$(npm view $PACKAGE_NAME) versions --json
if $NPM_VERSION | grep -q "\"$CURRENT_VERSION\""; then
echo "version_exists=true" >> $GITHUB_OUTPUT
echo "Version $CURRENT_VERSION already exists on npm"
else
echo "version_exists=false" >> $GITHUB_OUTPUT
echo "Version $CURRENT_VERSION is new and will be published"
fi
- name: Publish
if: steps.check-version.outputs.version_exists == 'false'
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Get package version
id: package-version
run: echo "version=$(jq -r .version package.json)" >> $GITHUB_OUTPUT
- name: Create release
if: steps.check-version.outputs.version_exists == 'false'
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
tag_name: v${{ steps.check-version.outputs.version
release_name: Release ${{ steps.check-version.outputs.version