name: Publish release preview package on: push: branches: - 'release/**' jobs: publish-preview: runs-on: ubuntu-latest steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: fetch-depth: 0 - uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0 - name: Setup Node.js uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 with: cache: pnpm node-version-file: '.node-version' - name: Install Packages run: | pnpm install --frozen-lockfile env: CYPRESS_CACHE_FOLDER: .cache/Cypress - name: Install Json run: npm i json@11.0.0 --global - name: Publish working-directory: ./packages/mermaid run: | PREVIEW_VERSION=$(git log --oneline "origin/$GITHUB_REF_NAME" ^"origin/master" | wc -l) VERSION=$(echo ${{github.ref}} | tail -c +20)-preview.$PREVIEW_VERSION echo $VERSION npm version --no-git-tag-version --allow-same-version $VERSION npm set //npm.pkg.github.com/:_authToken ${{ secrets.GITHUB_TOKEN }} npm set registry https://npm.pkg.github.com/mermaid-js json -I -f package.json -e 'this.name="@mermaid-js/mermaid"' # Package name needs to be set to a scoped one because GitHub registry requires this json -I -f package.json -e 'this.repository="git://github.com/mermaid-js/mermaid"' # Repo url needs to have a specific format too npm publish