From 8ebb1c2bc9677d20cfa576e9651c8c609b64e506 Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Fri, 12 Dec 2025 11:41:57 +0100 Subject: [PATCH] NPM: Remove dist-tag code (#115209) remove dist-tag --- scripts/publish-npm-packages.sh | 57 --------------------------------- 1 file changed, 57 deletions(-) diff --git a/scripts/publish-npm-packages.sh b/scripts/publish-npm-packages.sh index 3131c791d36..5f05800969b 100755 --- a/scripts/publish-npm-packages.sh +++ b/scripts/publish-npm-packages.sh @@ -59,60 +59,3 @@ if (( ${#failed_packages[@]} > 0 )); then exit 1 fi -# Check if any files in packages/grafana-e2e-selectors were changed. If so, add a 'modified' tag to the package -CHANGES_COUNT=$(git show --name-only --format= HEAD -- packages/grafana-e2e-selectors | awk 'END{print NR}') -if (( CHANGES_COUNT > 0 )); then - # Wait a little bit to allow the package to be published to the registry - sleep 5s - regex_pattern="canary: ([0-9.-]+)" - TAGS=$(npm dist-tag ls @grafana/e2e-selectors) - if [[ $TAGS =~ $regex_pattern ]]; then - echo "$CHANGES_COUNT file(s) in packages/grafana-e2e-selectors were changed. Adding 'modified' tag to @grafana/e2e-selectors@${BASH_REMATCH[1]}" - - # If using OIDC, exchange token for npm auth (npm publish handles OIDC internally, - # but dist-tag requires explicit authentication) - # Reference: https://github.com/electron/npm-trusted-auth-action - if [ -n "$ACTIONS_ID_TOKEN_REQUEST_URL" ] && [ -n "$ACTIONS_ID_TOKEN_REQUEST_TOKEN" ]; then - echo "Fetching GitHub OIDC token..." - OIDC_TOKEN=$(curl -sS -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \ - "${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=npm:registry.npmjs.org" | jq -r '.value // empty') - - if [ -z "$OIDC_TOKEN" ]; then - echo "Warning: Failed to fetch OIDC token, dist-tag operation may fail" - else - # Mask the OIDC token so it won't appear in logs - echo "::add-mask::$OIDC_TOKEN" - echo "Exchanging OIDC token for npm auth token..." - ENCODED_PACKAGE=$(printf "%s" "@grafana/e2e-selectors" | jq -Rr @uri) - RESPONSE=$(curl -sS -X POST \ - -H "Authorization: Bearer $OIDC_TOKEN" \ - -H "Accept: application/json" \ - -w "\n%{http_code}" \ - "https://registry.npmjs.org/-/npm/v1/oidc/token/exchange/package/$ENCODED_PACKAGE") - - HTTP_CODE=$(echo "$RESPONSE" | tail -n1) - BODY=$(echo "$RESPONSE" | sed '$d') - - if [ "$HTTP_CODE" != "201" ]; then - echo "Warning: Failed to exchange token. Status: $HTTP_CODE" - else - NPM_AUTH_TOKEN=$(echo "$BODY" | jq -r '.token // empty') - if [ -n "$NPM_AUTH_TOKEN" ]; then - # Mask the token so it won't appear in logs - echo "::add-mask::$NPM_AUTH_TOKEN" - echo "Configuring npm auth via NPM_TOKEN env var" - export NPM_TOKEN="$NPM_AUTH_TOKEN" - # Reference the env var in npmrc (single quotes intentional - npm expands it at runtime) - # shellcheck disable=SC2016 - echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' >> ~/.npmrc - else - echo "Warning: No token in response, dist-tag operation may fail" - fi - fi - fi - fi - - npm dist-tag add @grafana/e2e-selectors@"${BASH_REMATCH[1]}" modified - fi -fi -