Skip to content

Commit 41d9d3b

Browse files
chore: Fix npm ci (#1621)
1 parent 7f3854b commit 41d9d3b

File tree

5 files changed

+67
-120
lines changed

5 files changed

+67
-120
lines changed

.github/workflows/nightly.yml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@ on:
55
# Runs every day at 4AM
66
- cron: '0 4 * * *'
77
workflow_dispatch:
8-
9-
permissions:
10-
id-token: write
11-
contents: write
12-
8+
139
jobs:
1410
wdio-smoke:
1511
name: 'WDIO: Smoke Test'
@@ -89,12 +85,7 @@ jobs:
8985
internal/eu-prod-released.js \
9086
internal/eu-prod-postamble.js
9187
92-
deprecate-old-versions:
93-
name: Deprecate Unsupported Versions
94-
uses: ./.github/workflows/npm-operations.yml
95-
with:
96-
operation: deprecate-old-versions
97-
secrets:
98-
NR_API_KEY_PRODUCTION: ${{ secrets.NR_API_KEY_PRODUCTION }}
88+
# Note: NPM deprecation of old versions is now handled by npm-operations.yml
89+
# on its own schedule (daily at 4AM)
9990

10091
# TODO: Need to add a job for cleaning up experiments to run nightly

.github/workflows/npm-operations.yml

Lines changed: 57 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,25 @@
11
name: NPM Operations
22

33
permissions:
4-
# In order to create the git tag, we must have write permissions.
5-
contents: write
6-
# This is important. Trusted Publishing requires this for the OIDC exchange.
74
id-token: write
5+
contents: write
86

97
on:
10-
# Triggered by other workflows for specific NPM operations
11-
workflow_call:
12-
inputs:
13-
operation:
14-
description: 'NPM operation to perform'
15-
required: true
16-
type: string
17-
# Valid values: publish-release, publish-prerelease, deprecate-old-versions
18-
preid:
19-
description: 'Prerelease identifier (e.g., rc, alpha, beta)'
20-
required: false
21-
type: string
22-
default: 'rc'
23-
version-override:
24-
description: 'Override version for prerelease operations'
25-
required: false
26-
type: string
27-
dry_run:
28-
description: 'Dry run mode for testing'
29-
required: false
30-
type: boolean
31-
default: false
32-
secrets:
33-
GITHUB_LOGIN:
34-
required: false
35-
GITHUB_EMAIL:
36-
required: false
37-
NR_API_KEY_PRODUCTION:
38-
required: false
39-
outputs:
40-
operation:
41-
description: 'The operation that was performed'
42-
value: ${{ jobs.npm-operations.outputs.operation }}
43-
success:
44-
description: 'Whether the operation was successful'
45-
value: ${{ jobs.npm-operations.outputs.success }}
8+
# 1. Pull request merge - triggers prerelease operation
9+
push:
10+
branches:
11+
- main
4612

47-
# Manual trigger for testing/emergency operations
13+
# 2. Release - triggers release operations
14+
release:
15+
types: [published]
16+
17+
# 3. Scheduled deprecation (keeping existing nightly schedule)
18+
schedule:
19+
# Runs every day at 4AM
20+
- cron: '0 4 * * *'
21+
22+
# 4. Manual trigger for testing/manual/emergency operations
4823
workflow_dispatch:
4924
inputs:
5025
operation:
@@ -71,7 +46,37 @@ on:
7146
default: false
7247

7348
jobs:
49+
# Determine which operations to run based on trigger
50+
determine-operations:
51+
runs-on: ubuntu-latest
52+
outputs:
53+
operations: ${{ steps.determine.outputs.operations }}
54+
steps:
55+
- name: Determine operations based on trigger
56+
id: determine
57+
run: |
58+
case "${{ github.event_name }}" in
59+
"push")
60+
echo "operations=[\"publish-prerelease\"]" >> $GITHUB_OUTPUT
61+
;;
62+
"release")
63+
echo "operations=[\"publish-release\"]" >> $GITHUB_OUTPUT
64+
;;
65+
"schedule")
66+
echo "operations=[\"deprecate-old-versions\"]" >> $GITHUB_OUTPUT
67+
;;
68+
"workflow_dispatch")
69+
echo "operations=[\"${{ inputs.operation }}\"]" >> $GITHUB_OUTPUT
70+
;;
71+
*)
72+
echo "operations=[]" >> $GITHUB_OUTPUT
73+
;;
74+
esac
75+
76+
# Execute NPM operations based on determined operations
7477
npm-operations:
78+
needs: determine-operations
79+
if: needs.determine-operations.outputs.operations != '[]'
7580
runs-on: ubuntu-latest
7681
timeout-minutes: 30
7782
defaults:
@@ -80,6 +85,7 @@ jobs:
8085
env:
8186
GITHUB_LOGIN: ${{ secrets.GITHUB_LOGIN || secrets.BROWSER_GITHUB_BOT_NAME }}
8287
GITHUB_EMAIL: ${{ secrets.GITHUB_EMAIL || secrets.BROWSER_GITHUB_BOT_EMAIL }}
88+
OPERATION: ${{ fromJson(needs.determine-operations.outputs.operations)[0] }}
8389

8490
steps:
8591
- uses: actions/checkout@v5
@@ -104,31 +110,34 @@ jobs:
104110
105111
# Install dependencies for publish operations
106112
- name: Install project dependencies
107-
if: inputs.operation == 'publish-release' || inputs.operation == 'publish-prerelease'
113+
if: env.OPERATION == 'publish-release' || env.OPERATION == 'publish-prerelease'
108114
run: npm ci
109115

110116
# Build NPM package for release
111117
- name: Build npm package
112-
if: inputs.operation == 'publish-release'
118+
if: env.OPERATION == 'publish-release'
113119
run: npm run build:npm
114120

115121
# Publish release version
116122
- name: Publish npm package (release)
117-
if: inputs.operation == 'publish-release'
123+
if: env.OPERATION == 'publish-release'
118124
run: npm publish
119125

120126
# Publish prerelease version
121127
- name: Publish prerelease version
122-
if: inputs.operation == 'publish-prerelease'
128+
if: env.OPERATION == 'publish-prerelease'
123129
uses: ./.github/actions/prerelease-npm-version
124130
with:
125131
version-override: ${{ inputs.version-override }}
126-
preid: ${{ inputs.preid }}
127-
dry_run: ${{ inputs.dry_run }}
132+
preid: ${{ inputs.preid || 'rc' }}
133+
dry_run: ${{ inputs.dry_run || false }}
128134

129135
# Deprecate old versions
130136
- name: Deprecate old versions
131-
if: inputs.operation == 'deprecate-old-versions'
137+
if: env.OPERATION == 'deprecate-old-versions'
138+
env:
139+
# Ensure npm uses the registry URL for authentication
140+
NPM_CONFIG_REGISTRY: https://registry.npmjs.org/
132141
run: |
133142
# Get agent EoL table from NRQL
134143
response=$(curl -X POST https://api.newrelic.com/graphql \
@@ -166,5 +175,5 @@ jobs:
166175
done
167176
168177
outputs:
169-
operation: ${{ inputs.operation }}
178+
operation: ${{ env.OPERATION }}
170179
success: ${{ job.status == 'success' }}

.github/workflows/prerelease-npm-version.yml

Lines changed: 0 additions & 38 deletions
This file was deleted.

.github/workflows/publish-release.yml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# This workflow is used to build and publish a github release
22
# to all platforms. This workflow cannot be manually ran to
33
# prevent the same release from being published more than once.
4+
#
5+
# Note: NPM publishing and deprecation are now handled automatically by npm-operations.yml
6+
# when a GitHub release is published
47

58
name: Publish Release
69

@@ -225,17 +228,6 @@ jobs:
225228
# loader_version: ${{ steps.agent-loader-version.outputs.results }}
226229
# environment: stage
227230

228-
# Publish the agent to npmjs.org
229-
call-npm-operations:
230-
name: Call NPM Operations
231-
uses: ./.github/workflows/npm-operations.yml
232-
with:
233-
action: publish-release
234-
secrets:
235-
GITHUB_LOGIN: ${{ secrets.BROWSER_GITHUB_BOT_NAME }}
236-
GITHUB_EMAIL: ${{ secrets.BROWSER_GITHUB_BOT_EMAIL }}
237-
NR_API_KEY_PRODUCTION: ${{ secrets.NR_API_KEY_PRODUCTION }}
238-
239231
# Raise the release notes pr on the docs website repo
240232
raise-release-notes-pr:
241233
needs: [publish-prod-to-s3]
@@ -262,7 +254,7 @@ jobs:
262254

263255
# Notify the release repo of the new release
264256
notify-release-repo:
265-
needs: [publish-to-nr-prod, call-npm-operations]
257+
needs: [publish-to-nr-prod]
266258
runs-on: ubuntu-latest
267259
timeout-minutes: 30
268260
defaults:

.github/workflows/release-please.yml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
# When the release PR is merged, this action will create a Github release. Our docs-site PR workflow will use the
44
# contents of the changelog.json file and PR headers to generate release notes for the public docs website.
55
# See https://github.com/google-github-actions/release-please-action
6+
#
7+
# Note: NPM prerelease publishing is now handled automatically by npm-operations.yml when this workflow
8+
# pushes to the main branch (triggering automatic RC version publishing)
69

710
on:
811
push:
@@ -32,13 +35,3 @@ jobs:
3235
{"type":"fix","section":"Bug Fixes"},
3336
{"type":"security","section":"Security Fixes"}
3437
]
35-
# Bump a new prerelease version and publish to NPM.
36-
prerelease-npm-version:
37-
needs: release-please
38-
uses: ./.github/workflows/npm-operations.yml
39-
with:
40-
operation: publish-prerelease
41-
preid: rc
42-
secrets:
43-
GITHUB_LOGIN: ${{ secrets.BROWSER_GITHUB_BOT_NAME }}
44-
GITHUB_EMAIL: ${{ secrets.BROWSER_GITHUB_BOT_EMAIL }}

0 commit comments

Comments
 (0)