npm: only the tip of the mirror's main writes to npm (#27)
jonas, 2026-11-27 17:54 UTC · 088d9575c87a191edc645ec6bc03bbf0427d6733 · parent 7454b19
1 file changed
M .github/workflows/npm-publish.yml
@@ -116,7 +116,14 @@ with: name: tarball path: ${{ runner.temp }}/tarball - - run: node .github/npm-publish.mjs publish --tarball "$(ls "$RUNNER_TEMP"/tarball/*.tgz)" --dist-tag "$DIST_TAG" + # Only main's tip writes to npm. A run of an older commit (one that waited, or a rerun) stops + # here, so that no tag moves back; the tip's own run publishes what both changed. + - id: tip + run: | + tip="$(git ls-remote "https://github.com/$GITHUB_REPOSITORY" refs/heads/main | cut -f1)" + if [ "$tip" = "$GITHUB_SHA" ]; then echo "is=true" >> "$GITHUB_OUTPUT"; else echo "main is at $tip, not at $GITHUB_SHA: not published" | tee -a "$GITHUB_STEP_SUMMARY"; fi + - if: steps.tip.outputs.is == 'true' + run: node .github/npm-publish.mjs publish --tarball "$(ls "$RUNNER_TEMP"/tarball/*.tgz)" --dist-tag "$DIST_TAG" env: DIST_TAG: ${{ inputs.action || 'main' }} check: