name: publish # Publishes the version of a pushed version tag to npm through npm's trusted # publishing: npm trusts this workflow, so no tokens are needed. The dist-tag # comes from `publishConfig.tag` of the tagged commit: `latest` for releases, # `next` for prereleases. on: push: tags: ['v*'] permissions: contents: read jobs: publish: runs-on: ubuntu-latest permissions: contents: read id-token: write steps: - uses: actions/checkout@v7 # Trusted publishing needs npm 11.5.1 or later, which comes with Node 24. - uses: actions/setup-node@v7 with: node-version: 24.x registry-url: https://registry.npmjs.org - run: npm publish # Creates the GitHub release with the version's section of the changelog as # its notes. Only versions on the `latest` dist-tag become the latest release. release: needs: publish runs-on: ubuntu-latest permissions: contents: write steps: - uses: actions/checkout@v7 - env: GH_TOKEN: ${{ github.token }} run: | version="${GITHUB_REF_NAME#v}" tag="$(node -p "require('./package.json').publishConfig.tag")" # The section of the version, with the docs links made absolute: awk -v heading="## ${version%%-*}" ' $0 == heading { found = 1; next } found && /^## / { exit } found { print } ' doc/release-notes/changelog.md | sed -E -e 's#\]\(/#](https://ditojs.github.io/objection/#g' \ -e 's#(ditojs\.github\.io/objection/[^)#]*)\.md#\1.html#g' > notes.md if ! grep -q . notes.md; then echo "No changelog section for ${version%%-*}" >&2 exit 1 fi gh release create "$GITHUB_REF_NAME" --title "$GITHUB_REF_NAME" \ --notes-file notes.md --verify-tag \ $([ "$tag" = latest ] && echo --latest || echo --latest=false) \ $([[ "$version" == *-* ]] && echo --prerelease)