-
Notifications
You must be signed in to change notification settings - Fork 0
225 lines (201 loc) · 7.86 KB
/
Copy pathci.yml
File metadata and controls
225 lines (201 loc) · 7.86 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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
name: Build, verify, and release
on:
pull_request:
push:
branches:
- main
concurrency:
group: sift-${{ github.ref }}
cancel-in-progress: false
env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
jobs:
verify:
name: Verify source and tests
runs-on: windows-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
with:
fetch-depth: 0
persist-credentials: false
- name: Setup .NET
uses: actions/setup-dotnet@26b0ec14cb23fa6904739307f278c14f94c95bf1 # v5
with:
dotnet-version: 10.0.x
cache: true
cache-dependency-path: |
src/Stratus.Sift.Cli/packages.lock.json
src/Stratus.Sift.Core/packages.lock.json
src/Stratus.Sift.Contracts/packages.lock.json
src/Stratus.Sift.FileSystem/packages.lock.json
src/Stratus.Sift.Connectors/packages.lock.json
tests/Stratus.Sift.Cli.Tests/packages.lock.json
- name: Restore locked dependencies
run: dotnet restore Stratus.Sift.slnx --locked-mode
- name: Build
run: dotnet build Stratus.Sift.slnx --configuration Release --no-restore
- name: Test
run: dotnet test Stratus.Sift.slnx --configuration Release --no-build
- name: Verify source boundary
shell: pwsh
run: ./eng/Verify-PublicBoundary.ps1
build-release:
name: Build ${{ matrix.rid }}
needs: verify
runs-on: ${{ matrix.runner }}
permissions:
contents: read
strategy:
fail-fast: false
matrix:
include:
- rid: win-x64
runner: windows-latest
executable: sift.exe
- rid: win-arm64
runner: windows-11-arm
executable: sift-win-arm64.exe
- rid: linux-x64
runner: ubuntu-24.04
executable: sift-linux-x64
- rid: linux-arm64
runner: ubuntu-24.04-arm
executable: sift-linux-arm64
- rid: osx-x64
runner: macos-15-intel
executable: sift-osx-x64
- rid: osx-arm64
runner: macos-15
executable: sift-osx-arm64
steps:
- name: Checkout
uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
with:
fetch-depth: 0
persist-credentials: false
- name: Setup .NET
uses: actions/setup-dotnet@26b0ec14cb23fa6904739307f278c14f94c95bf1 # v5
with:
dotnet-version: 10.0.x
cache: true
cache-dependency-path: |
eng/locks/packages.${{ matrix.rid }}.lock.json
src/Stratus.Sift.Core/packages.lock.json
src/Stratus.Sift.Contracts/packages.lock.json
src/Stratus.Sift.FileSystem/packages.lock.json
src/Stratus.Sift.Connectors/packages.lock.json
- name: Set release version
id: version
shell: pwsh
run: '"version=0.1.${{ github.run_number }}" | Out-File -FilePath $env:GITHUB_OUTPUT -Append'
- name: Build Native AOT release
shell: pwsh
run: ./eng/Build-Release.ps1 -Version '${{ steps.version.outputs.version }}' -RuntimeIdentifier '${{ matrix.rid }}'
- name: Smoke test native executable
shell: pwsh
run: |
$executable = Resolve-Path './artifacts/release/${{ matrix.rid }}/${{ matrix.executable }}'
if (-not $IsWindows) {
chmod 755 $executable
}
$version = (& $executable --version).Trim()
if ($LASTEXITCODE -ne 0 -or -not $version.StartsWith('${{ steps.version.outputs.version }}')) {
throw "Unexpected version: $version"
}
$smokeOutput = Join-Path $env:RUNNER_TEMP 'sift-smoke.json'
& $executable local --path . --enum-only --output $smokeOutput --output-format json
$json = Get-Content -LiteralPath $smokeOutput -Raw | ConvertFrom-Json
if ($LASTEXITCODE -ne 0 -or $json.SchemaVersion -ne '1.0' -or $json.Errors -ne 0) {
throw 'The native scan smoke test failed.'
}
- name: Verify executable boundary
shell: pwsh
run: ./eng/Verify-PublicBoundary.ps1 -ArtifactPath './artifacts/release/${{ matrix.rid }}/${{ matrix.executable }}'
- name: Upload release assets
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: release-${{ matrix.rid }}
path: artifacts/release/${{ matrix.rid }}/*
if-no-files-found: error
retention-days: 7
release:
name: Publish release
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs:
- verify
- build-release
runs-on: ubuntu-24.04
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
with:
fetch-depth: 0
persist-credentials: false
- name: Set release version
id: version
shell: pwsh
run: '"version=0.1.${{ github.run_number }}" | Out-File -FilePath $env:GITHUB_OUTPUT -Append'
- name: Download release assets
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: release-*
path: artifacts/release
merge-multiple: true
- name: Verify assets and write checksums
shell: pwsh
run: |
$releaseRoot = Resolve-Path 'artifacts/release'
$partialChecksums = @(Get-ChildItem $releaseRoot -File -Filter 'SHA256SUMS-*.txt')
if ($partialChecksums.Count -ne 6) {
throw "Expected six platform checksum files, found $($partialChecksums.Count)."
}
foreach ($checksumFile in $partialChecksums) {
$lines = [System.IO.File]::ReadAllLines($checksumFile.FullName)
if ($lines.Count -ne 1) {
throw "Expected one binary checksum in $($checksumFile.Name), found $($lines.Count)."
}
foreach ($line in $lines) {
if ($line -notmatch '^([0-9a-f]{64}) (.+)$') {
throw "Invalid checksum line in $($checksumFile.Name): $line"
}
$asset = Join-Path $releaseRoot $Matches[2]
$actual = (Get-FileHash -LiteralPath $asset -Algorithm SHA256).Hash.ToLowerInvariant()
if ($actual -ne $Matches[1]) {
throw "Checksum mismatch for $($Matches[2])."
}
}
}
$assets = @(Get-ChildItem $releaseRoot -File | Where-Object Name -NotLike 'SHA256SUMS-*.txt' | Sort-Object Name)
if ($assets.Count -ne 6) {
throw "Expected six release binaries, found $($assets.Count)."
}
$checksums = foreach ($asset in $assets) {
$hash = (Get-FileHash -LiteralPath $asset.FullName -Algorithm SHA256).Hash.ToLowerInvariant()
"$hash $($asset.Name)"
}
[System.IO.File]::WriteAllLines(
(Join-Path $releaseRoot 'SHA256SUMS.txt'),
$checksums,
[System.Text.UTF8Encoding]::new($false))
Remove-Item $partialChecksums.FullName -Force
- name: Create GitHub release
shell: pwsh
env:
GH_TOKEN: ${{ github.token }}
RELEASE_VERSION: ${{ steps.version.outputs.version }}
run: |
$tag = "v$env:RELEASE_VERSION"
$assets = @(Get-ChildItem 'artifacts/release' -File | Sort-Object Name | ForEach-Object FullName)
if (gh release view $tag 2>$null) {
gh release upload $tag @assets --clobber
}
else {
gh release create $tag @assets --target $env:GITHUB_SHA --generate-notes --title "Stratus Sift $env:RELEASE_VERSION"
}