11name : Build
22on : [push, pull_request]
33
4+ concurrency :
5+ group : ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
6+ cancel-in-progress : true
7+
48permissions :
59 contents : read
6- id-token : write
7- packages : write
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 : Determine build version
14+ runs-on : ubuntu-latest
15+ outputs :
16+ version : ${{ steps.version.outputs.version }}
2117 steps :
2218 - name : Checkout
23- uses : actions/checkout@v7
19+ uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
2420 with :
2521 fetch-depth : 0
26- - name : Build Reason
22+ persist-credentials : false
23+ - name : Setup .NET SDK for MinVer
24+ uses : actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
25+ with :
26+ dotnet-version : " 10.0.x"
27+ - name : Build Version
28+ id : version
2729 shell : bash
2830 run : |
2931 branch=${GITHUB_REF##*/}.
@@ -36,68 +38,127 @@ jobs:
3638 elif [[ "${GITHUB_REF}" = refs/pull* ]]; then
3739 branch=""
3840 fi
39- echo "GIT_BRANCH_SUFFIX=$branch" >> $GITHUB_ENV
40- 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') }}
51- - name : Setup .NET SDK for MinVer
52- uses : actions/setup-dotnet@v6
53- with :
54- dotnet-version : " 10.0.x"
55- - name : Build Version
56- id : version
57- shell : bash
58- run : |
41+
5942 dotnet tool install --global minver-cli --version 7.0.0
60- version=$(minver --tag-prefix v --default-pre-release-identifiers "preview.${GIT_BRANCH_SUFFIX }0" --minimum-major-minor 3.0)
43+ version=$(minver --tag-prefix v --default-pre-release-identifiers "preview.${branch }0" --minimum-major-minor 3.0)
6144
62- # If on a non-main branch, insert branch name before the height (last numeric segment)
63- if [ -n "$GIT_BRANCH_SUFFIX" ]; then
64- branch_name="${GIT_BRANCH_SUFFIX%.}"
45+ if [ -n "$branch" ]; then
46+ branch_name="${branch%.}"
6547 if [[ "$version" != *"$branch_name"* ]]; then
66- version=$(echo "$version" | sed -E "s/\.([0-9]+)$/.${GIT_BRANCH_SUFFIX }\1/")
48+ version=$(echo "$version" | sed -E "s/\.([0-9]+)$/.${branch }\1/")
6749 fi
6850 fi
6951
70- echo "version=$version" >> $GITHUB_OUTPUT
52+ echo "version=$version" >> " $GITHUB_OUTPUT"
7153 echo "Version: $version"
72- echo "### Version: $version" >> $GITHUB_STEP_SUMMARY
54+ echo "### Version: $version" >> " $GITHUB_STEP_SUMMARY"
7355
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
56+ build :
57+ needs : version
58+ runs-on : ${{ matrix.os }}
59+ strategy :
60+ matrix :
61+ os :
62+ - ubuntu-latest
63+ - macos-latest
64+ - windows-latest
65+ node_version :
66+ - 24
67+ name : Node ${{ matrix.node_version }} on ${{ matrix.os }}
68+ steps :
69+ - name : Checkout
70+ uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
71+ with :
72+ persist-credentials : false
73+ - name : Setup Node.js environment
74+ uses : actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
75+ with :
76+ node-version : ${{ matrix.node_version }}
77+ registry-url : " https://registry.npmjs.org"
78+ cache : npm
79+ cache-dependency-path : package-lock.json
80+ - name : Apply Build Version
81+ env :
82+ BUILD_VERSION : ${{ needs.version.outputs.version }}
83+ run : node scripts/set-build-version.mjs
84+ - name : Install Dependencies
85+ run : npm ci
7886 - name : Build
7987 run : npm run build
8088 - name : Lint
8189 run : npm run lint
8290 - name : Run Tests
8391 run : npm test
92+
93+ publish-release :
94+ name : Publish npm release
95+ if : startsWith(github.ref, 'refs/tags/v')
96+ needs : [version, build]
97+ runs-on : ubuntu-latest
98+ permissions :
99+ contents : read
100+ id-token : write # Required for npm trusted publishing.
101+ steps :
102+ - name : Checkout
103+ uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
104+ with :
105+ persist-credentials : false
106+ - name : Setup Node.js environment
107+ uses : actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
108+ with :
109+ node-version : 24
110+ registry-url : " https://registry.npmjs.org"
111+ cache : npm
112+ cache-dependency-path : package-lock.json
113+ - name : Apply Build Version
114+ env :
115+ BUILD_VERSION : ${{ needs.version.outputs.version }}
116+ run : node scripts/set-build-version.mjs
117+ - name : Install Dependencies
118+ run : npm ci
119+ - name : Build
120+ run : npm run build
84121 - name : Publish Release Packages
85- if : startsWith(github.ref, 'refs/tags/v') && matrix.os == 'ubuntu-latest'
86122 run : npm publish --workspaces --access public
87- - 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
123+
124+ publish-github :
125+ name : Publish GitHub CI packages
126+ if : github.event_name == 'push' && startsWith(github.ref, 'refs/heads/') && contains(needs.version.outputs.version, '-')
127+ needs : [version, build]
128+ runs-on : ubuntu-latest
129+ permissions :
130+ contents : read
131+ packages : write # Required to publish with GITHUB_TOKEN.
132+ steps :
133+ - name : Checkout
134+ uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
90135 with :
91- node-version : ${{ matrix.node_version }}
136+ persist-credentials : false
137+ - name : Setup Node.js environment
138+ uses : actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
139+ with :
140+ node-version : 24
141+ registry-url : " https://registry.npmjs.org"
142+ cache : npm
143+ cache-dependency-path : package-lock.json
144+ - name : Apply Build Version
145+ env :
146+ BUILD_VERSION : ${{ needs.version.outputs.version }}
147+ run : node scripts/set-build-version.mjs
148+ - name : Install Dependencies
149+ run : npm ci
150+ - name : Build
151+ run : npm run build
152+ - name : Setup GitHub Packages registry
153+ uses : actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
154+ with :
155+ node-version : 24
92156 registry-url : " https://npm.pkg.github.com"
93157 scope : " @exceptionless"
94158 - 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, '-')
96159 shell : bash
97- 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
160+ run : | # zizmor: ignore[use-trusted-publishing] GitHub Packages uses GITHUB_TOKEN.
161+ TAG_BRANCH="${GITHUB_REF##*/}"
162+ npm publish --workspaces --access public --tag "ci-${TAG_BRANCH}"
102163 env :
103- NODE_AUTH_TOKEN : ${{secrets.GITHUB_TOKEN}}
164+ NODE_AUTH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments