Skip to content

Commit 5c27c2a

Browse files
AlexLovserclaude
andcommitted
Attach npm provenance only when the repository is public
npm cannot mint a provenance attestation from a private source repository, so `npm publish --provenance` fails outright there. The flag is now added only when the run reports a public repository, and `publishConfig.provenance` no longer forces it regardless. This keeps the release unblocked while the repository is private and needs no follow-up edit: making it public is by itself enough for attestation to come back on the next publish. An unrecognised visibility is treated as private, which costs the attestation rather than the release. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent 3ead1aa commit 5c27c2a

3 files changed

Lines changed: 21 additions & 7 deletions

File tree

.github/workflows/publish.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: Publish
22

3-
# Publishes to npm with provenance attestation (OIDC).
3+
# Publishes to npm. Provenance attestation (OIDC) is added when the repository
4+
# is public — npm cannot mint it from a private source.
45
# Requires either npm Trusted Publishing configured for
56
# SkyLink-API/SkyLink-API-TypeScript-SDK, or an NPM_ACCESS_TOKEN repository secret
67
# (automation token) as a fallback.
@@ -76,6 +77,17 @@ jobs:
7677
7778
- name: Publish to npm
7879
if: steps.npm.outputs.unpublished == 'true'
79-
run: npm publish --provenance --access public
80+
# npm refuses to mint provenance from a private repository. The flag is
81+
# therefore added only when the source is public, so making the repo
82+
# public is the single action needed to get attestation back — nothing
83+
# here has to change. An unknown visibility is treated as private, which
84+
# costs the attestation rather than the release.
85+
run: |
86+
if [ "${{ github.event.repository.visibility }}" = "public" ]; then
87+
npm publish --provenance --access public
88+
else
89+
echo "::warning::Repository is not public — publishing without provenance."
90+
npm publish --access public
91+
fi
8092
env:
8193
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -772,9 +772,12 @@ so it arms only on the direct channel (or an explicit `baseUrl`) and reports as
772772
otherwise. Everything it creates points at an unreachable `example.com` URL and is deleted
773773
afterwards, pass or fail.
774774
775-
Publishing is automated: pushing a `v*` tag builds the package and runs
776-
`npm publish --provenance --access public` via OIDC. The npm trusted publisher must be
777-
configured for `SkyLink-API/SkyLink-API-TypeScript-SDK` beforehand.
775+
Publishing is automated: a push to `main` (or a `v*` tag) lints, type-checks, tests and
776+
builds the package, then publishes it when `package.json` holds a version that is not on
777+
npm yet — so merging a version bump releases it and any other merge is a no-op. Provenance
778+
attestation is attached when the repository is public; npm cannot mint it from a private
779+
source. Authentication comes from the `NPM_ACCESS_TOKEN` secret, or from npm trusted
780+
publishing (OIDC) once it is configured for `SkyLink-API/SkyLink-API-TypeScript-SDK`.
778781
779782
## License
780783

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,7 @@
148148
"url": "https://github.com/SkyLink-API/SkyLink-API-TypeScript-SDK/issues"
149149
},
150150
"publishConfig": {
151-
"access": "public",
152-
"provenance": true
151+
"access": "public"
153152
},
154153
"devDependencies": {
155154
"@biomejs/biome": "^2.0.0",

0 commit comments

Comments
 (0)