-
-
Notifications
You must be signed in to change notification settings - Fork 22
161 lines (152 loc) · 5.29 KB
/
Copy pathbuild.yml
File metadata and controls
161 lines (152 loc) · 5.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: Build
on: [push, pull_request]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
version:
name: Determine build version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- name: Setup .NET SDK for MinVer
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
with:
dotnet-version: "10.0.x"
- name: Build Version
id: version
shell: bash
run: |
branch=${GITHUB_REF##*/}.
if [[ "$branch" = "main." ]]; then
branch=""
elif [[ "$branch" = "master." ]]; then
branch=""
elif [[ "${GITHUB_REF}" = refs/tags* ]]; then
branch=""
elif [[ "${GITHUB_REF}" = refs/pull* ]]; then
branch=""
fi
dotnet tool install --global minver-cli --version 7.0.0
version=$(minver --tag-prefix v --default-pre-release-identifiers "preview.${branch}0" --minimum-major-minor 3.0)
if [ -n "$branch" ]; then
branch_name="${branch%.}"
if [[ "$version" != *"$branch_name"* ]]; then
version=$(echo "$version" | sed -E "s/\.([0-9]+)$/.${branch}\1/")
fi
fi
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "Version: $version"
echo "### Version: $version" >> "$GITHUB_STEP_SUMMARY"
build:
needs: version
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
node_version:
- 24
name: Node ${{ matrix.node_version }} on ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Setup Node.js environment
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: ${{ matrix.node_version }}
registry-url: "https://registry.npmjs.org"
cache: npm
cache-dependency-path: package-lock.json
- name: Apply Build Version
env:
BUILD_VERSION: ${{ needs.version.outputs.version }}
run: node scripts/set-build-version.mjs
- name: Install Dependencies
run: npm ci
- name: Build
run: npm run build
- name: Lint
run: npm run lint
- name: Run Tests
run: npm test
publish-release:
name: Publish npm release
if: startsWith(github.ref, 'refs/tags/v')
needs: [version, build]
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write # Required for npm trusted publishing.
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Setup Node.js environment
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: 24
registry-url: "https://registry.npmjs.org"
cache: npm
cache-dependency-path: package-lock.json
- name: Apply Build Version
env:
BUILD_VERSION: ${{ needs.version.outputs.version }}
run: node scripts/set-build-version.mjs
- name: Install Dependencies
run: npm ci
- name: Build
run: npm run build
- name: Publish Release Packages
run: npm publish --workspaces --access public
publish-github:
name: Publish GitHub CI packages
if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads/') && contains(needs.version.outputs.version, '-')
needs: [version, build]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write # Required to publish with GITHUB_TOKEN.
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Setup Node.js environment
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: 24
registry-url: "https://registry.npmjs.org"
cache: npm
cache-dependency-path: package-lock.json
- name: Apply Build Version
env:
BUILD_VERSION: ${{ needs.version.outputs.version }}
run: node scripts/set-build-version.mjs
- name: Install Dependencies
run: npm ci
- name: Build
run: npm run build
- name: Setup GitHub Packages registry
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: 24
registry-url: "https://npm.pkg.github.com"
scope: "@exceptionless"
- name: Push GitHub CI Packages
run: node scripts/publish-ci-packages.mjs # zizmor: ignore[use-trusted-publishing] GitHub Packages uses GITHUB_TOKEN.
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}