Skip to content

Commit 2ef6fdf

Browse files
fix(ci): remove manual npm token setup in favor of trusted publishing and simply user experience (#104)
* fix(ci): remove manual npm token setup in favor of trusted publishing npm trusted publishing via OIDC (id-token: write) handles authentication without requiring a long-lived NPM_PUBLISH_TOKEN secret, eliminating the OTP/2FA requirement that caused EOTP errors in CI. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(ci): auto-parse version from tag in publish workflow When workflow_dispatch is triggered on a datadog-serverless-compat/v<x.y.z> tag, the version is parsed automatically from GITHUB_REF. The version input is required when running on a branch, and the workflow fails with a clear error if omitted. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent f0c5407 commit 2ef6fdf

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

.github/workflows/publish.yml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ on:
1212
- 'Build'
1313
- 'Build and Publish'
1414
version:
15-
description: 'NPM package version (x.y.z)'
16-
required: true
15+
description: 'NPM package version (x.y.z) — required when running on a branch; auto-parsed from tag when running on a datadog-serverless-compat/v<x.y.z> tag'
16+
required: false
1717
type: string
1818

1919
permissions:
@@ -56,9 +56,23 @@ jobs:
5656
name: windows-amd64
5757
path: target/windows-amd64
5858
- run: upx target/windows-amd64/datadog-serverless-compat.exe --lzma
59+
- name: Determine version
60+
id: determine-version
61+
env:
62+
INPUT_VERSION: ${{ inputs.version }}
63+
run: |
64+
if [[ "$GITHUB_REF" == refs/tags/datadog-serverless-compat/v* ]]; then
65+
VERSION="${GITHUB_REF#refs/tags/datadog-serverless-compat/v}"
66+
elif [[ -n "$INPUT_VERSION" ]]; then
67+
VERSION="$INPUT_VERSION"
68+
else
69+
echo "Error: version input is required when not running on a datadog-serverless-compat/v<x.y.z> tag"
70+
exit 1
71+
fi
72+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
5973
- name: Package binaries into npm packages
6074
env:
61-
VERSION: ${{ inputs.version }}
75+
VERSION: ${{ steps.determine-version.outputs.version }}
6276
run: |
6377
mkdir -p npm/datadog-serverless-compat-linux-x64/bin
6478
cp target/linux-amd64/datadog-serverless-compat npm/datadog-serverless-compat-linux-x64/bin/
@@ -91,9 +105,6 @@ jobs:
91105
with:
92106
node-version: "22.x"
93107
registry-url: 'https://registry.npmjs.org'
94-
- run: npm config set //registry.npmjs.org/:_authToken=$NPM_PUBLISH_TOKEN
95-
env:
96-
NPM_PUBLISH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
97108
- name: Publish npm packages
98109
run: |
99110
npm publish ./npm/datadog-serverless-compat-linux-x64 --provenance --access public

0 commit comments

Comments
 (0)