Publish Package #100
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish Package | |
| on: | |
| push: | |
| tags: | |
| - "plugin-*" | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # for ArnaudBarre/github-release to create a release | |
| id-token: write # for provenance generation | |
| environment: Release | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0 | |
| - name: Set node version | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 22 | |
| registry-url: https://registry.npmjs.org/ | |
| # disable cache, to avoid cache poisoning (https://docs.zizmor.sh/audits/#cache-poisoning) | |
| package-manager-cache: false | |
| - name: Disallow installation scripts | |
| run: yq '.onlyBuiltDependencies = []' -i pnpm-workspace.yaml | |
| - name: Install deps | |
| run: pnpm install | |
| env: | |
| PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "1" | |
| - name: Get pkgName for tag | |
| id: tag | |
| run: | | |
| # Check if the tag contains "alpha" | |
| if [[ $GITHUB_REF_NAME =~ alpha ]]; then | |
| echo "isAlpha=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "isAlpha=false" >> $GITHUB_OUTPUT | |
| fi | |
| # `%@*` truncates @ and version number from the right side. | |
| # https://stackoverflow.com/questions/9532654/expression-after-last-specific-character | |
| pkgName=${GITHUB_REF_NAME%@*} | |
| echo "pkgName=$pkgName" >> $GITHUB_OUTPUT | |
| - if: steps.tag.outputs.pkgName == 'plugin-react-swc' | |
| working-directory: packages/plugin-react-swc | |
| run: pnpm build | |
| - name: Publish package | |
| run: npm i -g npm@^11.5.2 && pnpm run ci-publish ${{ github.ref_name }} | |
| - if: steps.tag.outputs.isAlpha == 'false' && steps.tag.outputs.pkgName != 'plugin-rsc' | |
| uses: ArnaudBarre/github-release@4fa6eafe8e2449c7c1c5a91ae50de4ee34db0b40 # v1.5.0 | |
| with: | |
| path: packages/${{ steps.tag.outputs.pkgName }}/CHANGELOG.md | |
| tag-name: ${{ github.ref_name }} | |
| - if: steps.tag.outputs.isAlpha == 'false' && steps.tag.outputs.pkgName == 'plugin-rsc' | |
| uses: yyx990803/release-tag@8cccf7c5aa332d71d222df46677f70f77a8d2dc0 # v1.0.0 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: ${{ github.ref }} | |
| body: | | |
| Please refer to [CHANGELOG.md](https://github.com/vitejs/vite-plugin-react/blob/${{ github.ref_name }}/packages/${{ steps.tag.outputs.pkgName }}/CHANGELOG.md) for details. |