Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 23 additions & 14 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@ name: Release
# GitHub Release. Triggered by pushing a version tag (e.g. v0.6.0); also runnable
# manually, which runs every gate plus `npm publish --dry-run` and publishes nothing.
#
# npm auth: trusted publishing (OIDC) first. If no trusted publisher is configured on
# npmjs.com, npm falls back to the NPM_TOKEN repository secret (if set).
# npm auth: trusted publishing (OIDC) only. No token is passed to npm, so a
# misconfigured trusted publisher fails the publish instead of silently using a token.
#
# Release candidates: set package.json and src/constants.ts to a prerelease version
# (e.g. 0.6.0-rc.0) and push the matching tag (v0.6.0-rc.0). Any version containing
# "-" is published under the "next" dist-tag (so "latest" is untouched) and its GitHub
# Release is marked as a prerelease. Its notes come from a "## [0.6.0-rc.0]" CHANGELOG
# section if there is one, otherwise from the base version's "## [0.6.0]" section.
# Live tests are deliberately NOT run here; see live-tests.yml.
on:
push:
Expand Down Expand Up @@ -65,7 +71,12 @@ jobs:
VERSION: ${{ steps.version.outputs.version }}
run: |
set -euo pipefail
if ! grep -qF "## [${VERSION}]" CHANGELOG.md; then
# A prerelease (0.6.0-rc.0) may reuse its base version's section (0.6.0).
if grep -qF "## [${VERSION}]" CHANGELOG.md; then
echo "Found '## [${VERSION}]'."
elif [ "${VERSION%%-*}" != "${VERSION}" ] && grep -qF "## [${VERSION%%-*}]" CHANGELOG.md; then
echo "Prerelease ${VERSION}: using the '## [${VERSION%%-*}]' section."
else
echo "::error::CHANGELOG.md has no '## [${VERSION}]' section."
exit 1
fi
Expand Down Expand Up @@ -138,7 +149,6 @@ jobs:
- name: Publish
env:
VERSION: ${{ needs.verify.outputs.version }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
set -euo pipefail
name=$(node -p 'require("./package.json").name')
Expand All @@ -159,14 +169,8 @@ jobs:
exit 0
fi

# npm tries OIDC trusted publishing first and only falls back to this
# token when no trusted publisher matches. Never echo it.
if [ -n "${NPM_TOKEN}" ]; then
export NODE_AUTH_TOKEN="${NPM_TOKEN}"
echo "NPM_TOKEN secret present (used only if trusted publishing is not configured)."
else
echo "No NPM_TOKEN secret; relying on npm trusted publishing."
fi
# Trusted publishing (OIDC) only; no token is exported.
echo "Publishing ${name}@${VERSION} with dist-tag ${dist_tag} via npm trusted publishing."
npm publish --access public --provenance --tag "$dist_tag"

release:
Expand All @@ -186,8 +190,13 @@ jobs:
VERSION: ${{ needs.verify.outputs.version }}
run: |
set -euo pipefail
# Everything after "## [VERSION]" up to the next "## " heading.
awk -v hdr="## [${VERSION}]" '
# Everything after "## [VERSION]" up to the next "## " heading. A prerelease
# without its own section uses its base version's section.
hdr_version="${VERSION}"
if ! grep -qF "## [${VERSION}]" CHANGELOG.md; then
hdr_version="${VERSION%%-*}"
fi
awk -v hdr="## [${hdr_version}]" '
index($0, hdr) == 1 { found = 1; next }
found && /^## / { exit }
found { print }
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@diffbot/typescript",
"version": "0.6.0",
"version": "0.6.0-rc.0",
"description": "TypeScript client library for Diffbot APIs",
"type": "module",
"packageManager": "pnpm@10.33.0",
Expand Down
2 changes: 1 addition & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const VERSION = "0.6.0";
export const VERSION = "0.6.0-rc.0";

export const DEFAULT_TIMEOUT = 30_000;

Expand Down
Loading