Skip to content

Commit bf8e07c

Browse files
Phil Whittakerclaude
andcommitted
Add dynamic npm tagging to Azure DevOps pipeline
- Extract version from package.json in tarball during publish - Automatically determine npm tag based on version string: - *alpha* → alpha tag - *beta* → beta tag - *rc* → rc tag - otherwise → latest tag - Update display name to reflect dynamic tagging behavior 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 70c83ae commit bf8e07c

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

build/azure-pipelines.yml

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,25 @@ stages:
7171
# Setup temp npm project to load in defaults from the local .npmrc
7272
npm init -y
7373
74-
# Find the first .tgz file in the current directory and publish it
74+
# Find the first .tgz file in the current directory
7575
files=( ./*.tgz )
76-
npm publish "${files[0]}"
77-
displayName: Push to npm
76+
77+
# Extract version from package.json in the tarball
78+
tar -tf "${files[0]}" | grep package/package.json | head -1 | xargs tar -xf "${files[0]}" --strip-components=1
79+
version=$(node -p "require('./package.json').version")
80+
81+
# Determine tag based on version
82+
if [[ "${version}" == *"alpha"* ]]; then
83+
tag="alpha"
84+
elif [[ "${version}" == *"beta"* ]]; then
85+
tag="beta"
86+
elif [[ "${version}" == *"rc"* ]]; then
87+
tag="rc"
88+
else
89+
tag="latest"
90+
fi
91+
92+
echo "Publishing version ${version} with tag ${tag}"
93+
npm publish "${files[0]}" --tag $tag
94+
displayName: Push to npm with dynamic tagging
7895
workingDirectory: $(Pipeline.Workspace)/npm-package

0 commit comments

Comments
 (0)