diff --git a/.github/actions/publish-npm/action.yaml b/.github/actions/publish-npm/action.yaml new file mode 100644 index 000000000..2c0f0d490 --- /dev/null +++ b/.github/actions/publish-npm/action.yaml @@ -0,0 +1,28 @@ +name: 'Publishes package to npm registry' + +inputs: + project-name: + description: 'Name of the npm package to publish' + required: true + +runs: + using: 'composite' + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup antlr4 + uses: ./.github/actions/setup-antlr4 + + - name: Install dependencies with frozen lock file and generate parser + run: npm ci + + - name: Build project + run: npm run build + + - name: Publish on updated version number + uses: JS-DevTools/npm-publish@v2 + with: + token: ${{ secrets.NPM_TOKEN }} + package: 'packages/${{inputs.project-name}}/package.json' + access: 'public' diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 520c3baa7..7f1c6886c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,3 +1,4 @@ +name: Run Tests on: push: branches: diff --git a/.github/workflows/publish-cypher-codemirror.yaml b/.github/workflows/publish-cypher-codemirror.yaml deleted file mode 100644 index d87f07ba9..000000000 --- a/.github/workflows/publish-cypher-codemirror.yaml +++ /dev/null @@ -1,40 +0,0 @@ -name: Publish react-codemirror package to npm - -on: - # Runs on pushes targeting the default branch - # push: - # branches: ['main'] - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -env: - NODE_OPTIONS: '--max_old_space_size=4096' - -jobs: - deploy: - environment: publish-npm - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - - uses: actions/setup-node@v3 - with: - node-version: '18' - - - name: Setup antlr4 - uses: ./.github/actions/setup-antlr4 - - - name: Install dependencies with frozen lock file and generate parser - run: npm ci - - - name: Build project - run: npm run build - - - name: Publish on updated version number - uses: JS-DevTools/npm-publish@v2 - with: - token: ${{ secrets.NPM_TOKEN }} - package: 'packages/react-codemirror/package.json' - access: 'restricted' diff --git a/.github/workflows/publish-packages.yaml b/.github/workflows/publish-packages.yaml new file mode 100644 index 000000000..68e3ca120 --- /dev/null +++ b/.github/workflows/publish-packages.yaml @@ -0,0 +1,32 @@ +name: Publish react-codemirror package to npm + +on: + # Runs on pushes targeting the default branch + # push: + # branches: ['main'] + + # Run the workflow on push only after the unit tests have passed + workflow_run: + workflows: ['Run Tests'] + branches: [main] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +env: + NODE_OPTIONS: '--max_old_space_size=4096' + +jobs: + publish: + strategy: + fail-fast: false + matrix: + project: ['language-support', 'language-server', 'react-codemirror'] + + environment: publish-npm + runs-on: ubuntu-latest + steps: + - name: Publish ${{ matrix.project }} to npm + uses: ./.github/actions/publish-npm + with: + project-name: ${{ matrix.project }}