remirror/remirror

View on GitHub
.github/workflows/publish.yml

Summary

Maintainability
Test Coverage
name: publish

on:
  workflow_run:
    workflows: [ci]
    branches: [main]
    types: [completed]

env:
  PNPM_CACHE_FOLDER: .pnpm-store

jobs:
  # Publish the public packages to npm
  npm:
    if: github.event.workflow_run.conclusion == 'success'
    timeout-minutes: 10
    runs-on: ubuntu-latest

    steps:
      - name: checkout code repository
        uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - name: setup caching
        uses: actions/cache@v3
        with:
          path: ${{ env.PNPM_CACHE_FOLDER }}
          key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}

      - name: setup node.js
        uses: actions/setup-node@v3
        with:
          node-version: 14

      - name: install and audit
        uses: ./support/actions/pnpm
        with:
          cache: ${{ env.PNPM_CACHE_FOLDER }}

      - name: build project
        run: pnpm build

      - name: publish npm release
        run: |
          echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > $HOME/.npmrc
          pnpm release
          rm $HOME/.npmrc
        env:
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

      - name: parse changelog for @remirror/react
        id: changelog_remirror_react
        uses: ocavue/changelog-parser-action@v1
        with:
          filePath: 'packages/remirror__react/CHANGELOG.md'

      - name: create release for @remirror/react
        uses: ncipollo/release-action@v1
        with:
          commit: main
          tag: '@remirror/react@${{ fromJSON(steps.changelog_remirror_react.outputs.parsed).versions[0].version }}'
          body: '${{ fromJSON(steps.changelog_remirror_react.outputs.parsed).versions[0].body }}'
          token: ${{ secrets.GITHUB_TOKEN }}
        continue-on-error: true

      - name: parse changelog for @remirror/pm
        id: changelog_remirror_pm
        uses: ocavue/changelog-parser-action@v1
        with:
          filePath: 'packages/remirror__pm/CHANGELOG.md'

      - name: create release for @remirror/pm
        uses: ncipollo/release-action@v1
        with:
          commit: main
          tag: '@remirror/pm@${{ fromJSON(steps.changelog_remirror_pm.outputs.parsed).versions[0].version }}'
          body: '${{ fromJSON(steps.changelog_remirror_pm.outputs.parsed).versions[0].body }}'
          token: ${{ secrets.GITHUB_TOKEN }}
        continue-on-error: true

      # make sure that `remirror` is the last one so that it can at the top of the release list
      - name: parse changelog for remirror
        id: changelog_remirror
        uses: ocavue/changelog-parser-action@v1
        with:
          filePath: 'packages/remirror/CHANGELOG.md'

      - name: create release for remirror
        uses: ncipollo/release-action@v1
        with:
          commit: main
          tag: 'remirror@${{ fromJSON(steps.changelog_remirror.outputs.parsed).versions[0].version }}'
          body: '${{ fromJSON(steps.changelog_remirror.outputs.parsed).versions[0].body }}'
          token: ${{ secrets.GITHUB_TOKEN }}
        continue-on-error: true