name: Publish to npm on: release: types: [published] jobs: publish: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 - name: Enable Corepack run: corepack enable - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: 20 registry-url: 'https://registry.npmjs.org/' - name: Install dependencies with Yarn run: yarn install --immutable - name: Run type check run: yarn type-check - name: Build library run: yarn build - name: Determine npm tag based on release type id: determine_tag run: | # Access the prerelease flag from the Gitea release event payload # ${{ github.event.release.prerelease }} is the standard GitHub Actions syntax # Gitea Actions aims for compatibility, so this should work. if [[ "${{ github.event.release.prerelease }}" == "true" ]]; then echo "NPM_TAG=dev" >> $GITHUB_OUTPUT echo "::notice::Release is a pre-release. Publishing with 'dev' tag." else echo "NPM_TAG=latest" >> $GITHUB_OUTPUT echo "::notice::Release is stable. Publishing with 'latest' tag." fi - name: Publish to npm run: npm publish --access public --tag ${{ steps.determine_tag.outputs.NPM_TAG }} env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}