fix: Only try to publish when version has changed (#18) #56
This file contains 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 | ||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- deno.json | ||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
id-token: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: "20.x" | ||
registry-url: "https://registry.npmjs.org" | ||
- uses: denoland/setup-deno@v1 | ||
- run: | | ||
echo "DENO_VERSION=$(cat deno.json | jq \".version\")" >> $GITHUB_ENV | ||
echo "NPM_VERSION=$(npm info @denosaurs/typefetch --json | jq \".['dist-tags'].latest\")" >> $GITHUB_ENV | ||
echo "JSR_VERSION=$(curl -s https://jsr.io/@denosaurs/typefetch/meta.json | jq \".latest\")" >> $GITHUB_ENV | ||
- run: deno publish | ||
if: ${{ env.DENO_VERSION != env.JSR_VERSION }} | ||
- run: deno run -A scripts/npm.ts | ||
if: ${{ env.DENO_VERSION != env.NPM_VERSION }} | ||
- run: npm publish --provenance --access public | ||
if: ${{ env.DENO_VERSION != env.NPM_VERSION }} | ||
working-directory: ./npm | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |