@@ -3,26 +3,24 @@ on: [push, pull_request]
33
44permissions :
55 contents : read
6- id-token : write
7- packages : write
6+
7+ concurrency :
8+ group : ${{ github.workflow }}-${{ github.ref }}
9+ cancel-in-progress : ${{ github.event_name == 'pull_request' }}
810
911jobs :
10- build :
11- runs-on : ${{ matrix.os }}
12- strategy :
13- matrix :
14- os :
15- - ubuntu-latest
16- - macos-latest
17- - windows-latest
18- node_version :
19- - 24
20- name : Node ${{ matrix.node_version }} on ${{ matrix.os }}
12+ version :
13+ name : Version
14+ runs-on : ubuntu-latest
15+ outputs :
16+ version : ${{ steps.version.outputs.version }}
17+ ci_tag : ${{ steps.version.outputs.ci_tag }}
2118 steps :
2219 - name : Checkout
23- uses : actions/checkout@v7
20+ uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
2421 with :
2522 fetch-depth : 0
23+ persist-credentials : false
2624 - name : Build Reason
2725 shell : bash
2826 run : |
@@ -36,20 +34,10 @@ jobs:
3634 elif [[ "${GITHUB_REF}" = refs/pull* ]]; then
3735 branch=""
3836 fi
39- echo "GIT_BRANCH_SUFFIX=$branch" >> $GITHUB_ENV
37+ echo "GIT_BRANCH_SUFFIX=$branch" >> " $GITHUB_ENV"
4038 echo "ref: $GITHUB_REF event: $GITHUB_EVENT_NAME branch_suffix: $branch"
41- - name : Setup Node.js environment
42- uses : actions/setup-node@v7
43- with :
44- node-version : ${{ matrix.node_version }}
45- registry-url : " https://registry.npmjs.org"
46- - name : Cache node_modules
47- uses : actions/cache@v6
48- with :
49- path : node_modules
50- key : ${{ matrix.node_version }}-${{ runner.os }}-node-modules-${{ hashFiles('package-lock.json') }}
5139 - name : Setup .NET SDK for MinVer
52- uses : actions/setup-dotnet@v6
40+ uses : actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0
5341 with :
5442 dotnet-version : " 10.0.x"
5543 - name : Build Version
@@ -67,37 +55,137 @@ jobs:
6755 fi
6856 fi
6957
70- echo "version=$version" >> $GITHUB_OUTPUT
58+ ci_tag="${GIT_BRANCH_SUFFIX%.}"
59+ ci_tag="${ci_tag:-main}"
60+ ci_tag="ci-${ci_tag//\//-}"
61+
62+ echo "version=$version" >> "$GITHUB_OUTPUT"
63+ echo "ci_tag=$ci_tag" >> "$GITHUB_OUTPUT"
7164 echo "Version: $version"
72- echo "### Version: $version" >> $GITHUB_STEP_SUMMARY
65+ echo "### Version: $version" >> " $GITHUB_STEP_SUMMARY"
7366
74- npm install --global replace-in-files-cli
75- replace-in-files --string="3.0.0-dev" --replacement=$version packages/core/src/configuration/Configuration.ts
76- replace-in-files --string="3.0.0-dev" --replacement=$version **/package*.json
77- npm ci
67+ build :
68+ needs : version
69+ runs-on : ${{ matrix.os }}
70+ strategy :
71+ matrix :
72+ os :
73+ - ubuntu-latest
74+ - macos-latest
75+ - windows-latest
76+ node_version :
77+ - 24
78+ include :
79+ - os : ubuntu-latest
80+ node_version : 22
81+ name : Node ${{ matrix.node_version }} on ${{ matrix.os }}
82+ steps :
83+ - name : Checkout
84+ uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
85+ with :
86+ persist-credentials : false
87+ - name : Setup Node.js environment
88+ uses : actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
89+ with :
90+ node-version : ${{ matrix.node_version }}
91+ cache : npm
92+ - name : Set Version
93+ shell : bash
94+ run : node scripts/set-version.mjs "$VERSION"
95+ env :
96+ VERSION : ${{ needs.version.outputs.version }}
97+ - name : Install Dependencies
98+ run : npm ci
7899 - name : Build
79100 run : npm run build
80101 - name : Lint
102+ if : matrix.os == 'ubuntu-latest' && matrix.node_version == 24
81103 run : npm run lint
82104 - name : Run Tests
83105 run : npm test
106+
107+ # Publish jobs rebuild from a clean checkout so elevated permissions are only
108+ # granted to the job that needs them. They skip dependency caching on purpose.
109+ publish-npm :
110+ name : Publish Release Packages
111+ if : startsWith(github.ref, 'refs/tags/v')
112+ needs : [version, build]
113+ runs-on : ubuntu-latest
114+ environment : npm-release
115+ permissions :
116+ contents : read
117+ id-token : write
118+ steps :
119+ - name : Checkout
120+ uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
121+ with :
122+ persist-credentials : false
123+ - name : Setup Node.js environment
124+ uses : actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
125+ with :
126+ node-version : 24
127+ registry-url : " https://registry.npmjs.org"
128+ package-manager-cache : false
129+ - name : Set Version
130+ run : node scripts/set-version.mjs "$VERSION"
131+ env :
132+ VERSION : ${{ needs.version.outputs.version }}
133+ - name : Install Dependencies
134+ run : npm ci
135+ - name : Build
136+ run : npm run build
84137 - name : Publish Release Packages
85- if : startsWith(github.ref, 'refs/tags/v') && matrix.os == 'ubuntu-latest'
86138 run : npm publish --workspaces --access public
139+
140+ publish-github :
141+ name : Push GitHub CI Packages
142+ if : github.event_name != 'pull_request' && startsWith(github.ref, 'refs/heads/') && contains(needs.version.outputs.version, '-')
143+ needs : [version, build]
144+ runs-on : ubuntu-latest
145+ permissions :
146+ contents : read
147+ packages : write
148+ steps :
149+ - name : Checkout
150+ uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
151+ with :
152+ persist-credentials : false
153+ - name : Setup Node.js environment
154+ uses : actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
155+ with :
156+ node-version : 24
157+ package-manager-cache : false
158+ - name : Set Version
159+ run : node scripts/set-version.mjs "$VERSION"
160+ env :
161+ VERSION : ${{ needs.version.outputs.version }}
162+ - name : Install Dependencies
163+ run : npm ci
164+ - name : Build
165+ run : npm run build
87166 - name : Setup GitHub CI Node.js environment
88- if : github.event_name != 'pull_request' && startsWith(github.ref, 'refs/heads/') && matrix.os == 'ubuntu-latest' && contains(steps.version.outputs.version, '-')
89- uses : actions/setup-node@v7
167+ uses : actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
90168 with :
91- node-version : ${{ matrix.node_version }}
169+ node-version : 24
92170 registry-url : " https://npm.pkg.github.com"
93171 scope : " @exceptionless"
172+ package-manager-cache : false
94173 - name : Push GitHub CI Packages
95- if : github.event_name != 'pull_request' && startsWith(github.ref, 'refs/heads/') && matrix.os == 'ubuntu-latest' && contains(steps.version.outputs.version, '-')
96174 shell : bash
97175 run : |
98- TAG_BRANCH="${GIT_BRANCH_SUFFIX%.}"
99- TAG_BRANCH="${TAG_BRANCH:-main}"
100- TAG_BRANCH="${TAG_BRANCH//\//-}"
101- npm publish --workspaces --access public --tag "ci-${TAG_BRANCH}" || true
176+ # Re-runs of the same commit produce the same version; skip packages
177+ # that already exist and let every other publish failure fail the job.
178+ for dir in packages/*/; do
179+ dir="${dir%/}"
180+ name=$(node -p "require('./$dir/package.json').name")
181+ existing=$(npm view "$name@$VERSION" version 2>/dev/null || true)
182+ if [ "$existing" = "$VERSION" ]; then
183+ echo "::notice::$name@$VERSION already exists in GitHub Packages; skipping."
184+ continue
185+ fi
186+ npm publish --workspace "$dir" --access public --tag "$CI_TAG"
187+ done
102188 env :
103- NODE_AUTH_TOKEN : ${{secrets.GITHUB_TOKEN}}
189+ VERSION : ${{ needs.version.outputs.version }}
190+ CI_TAG : ${{ needs.version.outputs.ci_tag }}
191+ NODE_AUTH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments