| 1 | name: Publish release preview package |
| 2 | |
| 3 | on: |
| 4 | push: |
| 5 | branches: |
| 6 | - 'release/**' |
| 7 | |
| 8 | jobs: |
| 9 | publish-preview: |
| 10 | runs-on: ubuntu-latest |
| 11 | steps: |
| 12 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 13 | with: |
| 14 | fetch-depth: 0 |
| 15 | |
| 16 | - uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 |
| 17 | |
| 18 | - name: Setup Node.js |
| 19 | uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0 |
| 20 | with: |
| 21 | cache: pnpm |
| 22 | node-version-file: '.node-version' |
| 23 | |
| 24 | - name: Install Packages |
| 25 | run: | |
| 26 | pnpm install --frozen-lockfile |
| 27 | env: |
| 28 | CYPRESS_CACHE_FOLDER: .cache/Cypress |
| 29 | |
| 30 | - name: Install Json |
| 31 | run: npm i json@11.0.0 --global |
| 32 | |
| 33 | - name: Publish |
| 34 | working-directory: ./packages/mermaid |
| 35 | run: | |
| 36 | PREVIEW_VERSION=$(git log --oneline "origin/$GITHUB_REF_NAME" ^"origin/master" | wc -l) |
| 37 | VERSION=$(echo ${{github.ref}} | tail -c +20)-preview.$PREVIEW_VERSION |
| 38 | echo $VERSION |
| 39 | npm version --no-git-tag-version --allow-same-version $VERSION |
| 40 | npm set //npm.pkg.github.com/:_authToken ${{ secrets.GITHUB_TOKEN }} |
| 41 | npm set registry https://npm.pkg.github.com/mermaid-js |
| 42 | 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 |
| 43 | json -I -f package.json -e 'this.repository="git://github.com/mermaid-js/mermaid"' # Repo url needs to have a specific format too |
| 44 | npm publish |
| 45 | |