chore: release 0.5.0 #2
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 JSR | |
| on: | |
| push: | |
| tags: | |
| - "v*.*.*" | |
| - "*.*.*" | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: "Tag to publish (e.g. v0.3.0)" | |
| required: true | |
| type: string | |
| permissions: | |
| contents: write | |
| id-token: write | |
| concurrency: | |
| group: publish-jsr-${{ github.ref }} | |
| cancel-in-progress: false | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v7 | |
| with: | |
| fetch-depth: 0 | |
| ref: ${{ inputs.tag || github.ref }} | |
| - name: Setup Deno | |
| uses: denoland/setup-deno@v2 | |
| with: | |
| deno-version: v2.x | |
| - name: Verify tag matches deno.json version | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| raw_tag="${{ inputs.tag || github.ref_name }}" | |
| tag="${raw_tag#v}" | |
| version="$(deno eval "console.log(JSON.parse(Deno.readTextFileSync('deno.json')).version)")" | |
| if [[ "${tag}" != "${version}" ]]; then | |
| echo "Tag (${raw_tag}) does not match deno.json version (${version})." | |
| exit 1 | |
| fi | |
| - name: Check | |
| run: deno task check | |
| - name: Publish to JSR | |
| shell: bash | |
| run: | | |
| version="$(deno eval "console.log(JSON.parse(Deno.readTextFileSync('deno.json')).version)")" | |
| if deno eval "const r = await fetch('https://jsr.io/@claudiu-ceia/dhash/${version}_meta.json'); Deno.exit(r.ok ? 0 : 1)"; then | |
| echo "@claudiu-ceia/dhash@${version} is already published to JSR." | |
| else | |
| deno publish | |
| fi | |
| - name: Generate release notes | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| tag="${{ inputs.tag || github.ref_name }}" | |
| prev_tag="$( | |
| git tag --list "v*" --sort=-version:refname \ | |
| | grep -v "^${tag}$" \ | |
| | head -n 1 || true | |
| )" | |
| { | |
| echo "# ${tag}" | |
| echo | |
| if [[ -n "${prev_tag}" ]]; then | |
| echo "Changes since ${prev_tag}:" | |
| echo | |
| git log --no-merges --pretty=format:"- %s (%h)" "${prev_tag}..${tag}" | |
| else | |
| echo "Changes:" | |
| echo | |
| git log --no-merges --pretty=format:"- %s (%h)" "${tag}" | |
| fi | |
| echo | |
| } > RELEASE_NOTES.md | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v3 | |
| with: | |
| tag_name: ${{ inputs.tag || github.ref_name }} | |
| name: ${{ inputs.tag || github.ref_name }} | |
| body_path: RELEASE_NOTES.md |