-
Notifications
You must be signed in to change notification settings - Fork 0
186 lines (154 loc) · 5.14 KB
/
ci.yml
File metadata and controls
186 lines (154 loc) · 5.14 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
name: CI/CD Pipeline
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
release:
types: [ created ]
env:
DOTNET_VERSION: '8.0.x'
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_NOLOGO: true
jobs:
build-and-test:
name: Build and Test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Run tests
run: dotnet test --configuration Release --no-build --verbosity normal --collect:"XPlat Code Coverage"
- name: Upload coverage reports
uses: codecov/codecov-action@v4
with:
files: '**/coverage.cobertura.xml'
fail_ci_if_error: false
publish-binaries:
name: Publish Release Binaries
runs-on: ubuntu-latest
needs: build-and-test
if: github.event_name == 'release'
strategy:
matrix:
runtime: [linux-x64, linux-arm64]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Publish CLI (${{ matrix.runtime }})
run: |
dotnet publish src/BenchLab.Cli/BenchLab.Cli.csproj \
-c Release \
-r ${{ matrix.runtime }} \
--self-contained true \
-p:PublishSingleFile=true \
-p:PublishTrimmed=true \
-p:EnableCompressionInSingleFile=true \
-o artifacts/cli-${{ matrix.runtime }}
- name: Publish Service (${{ matrix.runtime }})
run: |
dotnet publish src/BenchLab.Service/BenchLab.Service.csproj \
-c Release \
-r ${{ matrix.runtime }} \
--self-contained true \
-p:PublishSingleFile=true \
-p:PublishTrimmed=true \
-p:EnableCompressionInSingleFile=true \
-o artifacts/service-${{ matrix.runtime }}
- name: Create tarball
run: |
cd artifacts
tar czf benchlab-${{ matrix.runtime }}.tar.gz cli-${{ matrix.runtime }} service-${{ matrix.runtime }}
- name: Upload release artifacts
uses: actions/upload-artifact@v4
with:
name: benchlab-${{ matrix.runtime }}
path: artifacts/benchlab-${{ matrix.runtime }}.tar.gz
- name: Upload to release
uses: softprops/action-gh-release@v1
with:
files: artifacts/benchlab-${{ matrix.runtime }}.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-debian-package:
name: Build Debian Package
runs-on: ubuntu-latest
needs: build-and-test
if: github.event_name == 'release'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Install packaging tools
run: sudo apt-get update && sudo apt-get install -y dpkg-dev debhelper
- name: Publish binaries for packaging
run: |
dotnet publish src/BenchLab.Cli/BenchLab.Cli.csproj -c Release -r linux-x64 --self-contained true -p:PublishSingleFile=true -o packaging/deb/usr/bin
dotnet publish src/BenchLab.Service/BenchLab.Service.csproj -c Release -r linux-x64 --self-contained true -p:PublishSingleFile=true -o packaging/deb/usr/bin
- name: Build .deb package
run: |
cd packaging/deb
dpkg-deb --build . ../../benchlab_1.0.0_amd64.deb || echo "Note: dpkg-deb may show warnings, check if .deb was created"
- name: Upload Debian package
uses: actions/upload-artifact@v4
with:
name: benchlab-deb
path: benchlab_*.deb
- name: Upload to release
uses: softprops/action-gh-release@v1
with:
files: benchlab_*.deb
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
docker-build:
name: Build Docker Images
runs-on: ubuntu-latest
needs: build-and-test
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
if: github.event_name == 'release'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name == 'release' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max