Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 23 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,43 @@ name: CI

on:
push:
workflow_dispatch:

permissions:
contents: read
id-token: write

jobs:
CI:
name: CI flow
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "16.13.1"
node-version: "20"
cache: "yarn"
registry-url: "https://registry.npmjs.org"

- name: Install dependencies
run: yarn install --immutable --immutable-cache

- name: Build
run: yarn build

- name: Lint
run: yarn lint
- name: Check if version exists on npm
if: github.ref == 'refs/heads/master'
id: check-version
run: |
VERSION=$(node -p "require('./package.json').version")
if npm view @questdb/sql-grammar@$VERSION version 2>/dev/null; then
echo "Version $VERSION already exists on npm"
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "Version $VERSION does not exist on npm"
echo "exists=false" >> $GITHUB_OUTPUT
fi

- name: Publish @questdb/sql-grammar to npm
if: github.ref == 'refs/heads/master'
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
access: public
check-version: true
package: ./package.json
if: github.ref == 'refs/heads/master' && steps.check-version.outputs.exists == 'false'
run: npm publish --provenance --access public