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-
84permissions :
95 contents : read
6+ id-token : write
7+ packages : write
108
119jobs :
12- version :
13- name : Determine build version
14- runs-on : ubuntu-latest
15- outputs :
16- version : ${{ steps.version.outputs.version }}
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 }}
1721 steps :
1822 - name : Checkout
19- uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
23+ uses : actions/checkout@v7
2024 with :
2125 fetch-depth : 0
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
26+ - name : Build Reason
2927 shell : bash
3028 run : |
3129 branch=${GITHUB_REF##*/}.
@@ -38,124 +36,68 @@ jobs:
3836 elif [[ "${GITHUB_REF}" = refs/pull* ]]; then
3937 branch=""
4038 fi
41-
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 : |
4259 dotnet tool install --global minver-cli --version 7.0.0
43- version=$(minver --tag-prefix v --default-pre-release-identifiers "preview.${branch }0" --minimum-major-minor 3.0)
60+ version=$(minver --tag-prefix v --default-pre-release-identifiers "preview.${GIT_BRANCH_SUFFIX }0" --minimum-major-minor 3.0)
4461
45- if [ -n "$branch" ]; then
46- branch_name="${branch%.}"
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%.}"
4765 if [[ "$version" != *"$branch_name"* ]]; then
48- version=$(echo "$version" | sed -E "s/\.([0-9]+)$/.${branch }\1/")
66+ version=$(echo "$version" | sed -E "s/\.([0-9]+)$/.${GIT_BRANCH_SUFFIX }\1/")
4967 fi
5068 fi
5169
52- echo "version=$version" >> " $GITHUB_OUTPUT"
70+ echo "version=$version" >> $GITHUB_OUTPUT
5371 echo "Version: $version"
54- echo "### Version: $version" >> " $GITHUB_STEP_SUMMARY"
72+ echo "### Version: $version" >> $GITHUB_STEP_SUMMARY
5573
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
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
8678 - name : Build
8779 run : npm run build
8880 - name : Lint
8981 run : npm run lint
9082 - name : Run Tests
9183 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
12184 - name : Publish Release Packages
85+ if : startsWith(github.ref, 'refs/tags/v') && matrix.os == 'ubuntu-latest'
12286 run : npm publish --workspaces --access public
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
135- with :
136- persist-credentials : false
137- - name : Setup Node.js environment
138- uses : actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
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
13990 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
91+ node-version : ${{ matrix.node_version }}
15692 registry-url : " https://npm.pkg.github.com"
15793 scope : " @exceptionless"
15894 - name : Push GitHub CI Packages
159- run : node scripts/publish-ci-packages.mjs # zizmor: ignore[use-trusted-publishing] GitHub Packages uses GITHUB_TOKEN.
95+ if : github.event_name != 'pull_request' && startsWith(github.ref, 'refs/heads/') && matrix.os == 'ubuntu-latest' && contains(steps.version.outputs.version, '-')
96+ 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
160102 env :
161- NODE_AUTH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
103+ NODE_AUTH_TOKEN : ${{secrets.GITHUB_TOKEN}}
0 commit comments