-
Notifications
You must be signed in to change notification settings - Fork 1
183 lines (168 loc) · 5.04 KB
/
ci.yml
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
name: Build and Test
on:
push:
branches:
- main
tags:
- v*
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.gitversion.outputs.nuGetVersionV2 }}
branchName: ${{ steps.gitversion.outputs.branchName }}
commitsSinceVersionSource: ${{ steps.gitversion.outputs.commitsSinceVersionSource }}
defaults:
run:
shell: bash
working-directory: src/cert-manager-acme-httphook
steps:
-
name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
-
name: Setup .NET
uses: actions/setup-dotnet@v2
with:
dotnet-version: 5.0.x
-
name: Problem Matcher for dotnet-format
uses: xt0rted/dotnet-format-problem-matcher@v1.2.0
-
name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0.9.13
with:
versionSpec: '5.x'
-
name: Install dotnet-format
run: dotnet tool install -g dotnet-format
-
name: Create AssemblyVersionInfo
run: |
echo '
using System.Reflection;
[assembly: AssemblyFileVersion("0.0.0.0")]
[assembly: AssemblyVersion("0.0.0.0")]
[assembly: AssemblyInformationalVersion("0.0.0.0")]
' > ../AssemblyVersionInfo.cs
-
name: Generate assembly info
uses: gittools/actions/gitversion/execute@v0.9.13
with:
updateAssemblyInfo: true
updateAssemblyInfoFilename: src/AssemblyVersionInfo.cs
-
name: Restore dependencies
run: dotnet restore
-
name: Dotnet Format
run: dotnet format --check
-
name: Build
run: dotnet build -c Release --no-restore
# -
# name: Test
# run: dotnet test --no-build --verbosity normal
docker:
runs-on: ubuntu-latest
needs: build
outputs:
version: ${{ steps.gitversion.outputs.nuGetVersionV2 }}
branchName: ${{ steps.gitversion.outputs.branchName }}
commitsSinceVersionSource: ${{ steps.gitversion.outputs.commitsSinceVersionSource }}
defaults:
run:
shell: bash
working-directory: src/cert-manager-acme-httphook
steps:
-
name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
-
name: Docker meta
id: docker_meta
uses: docker/metadata-action@v4.0.1
with:
images: mpoettgen/cert-manager-acme-httphook
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2.0.0
-
name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2.0.0
-
name: Setup .NET
uses: actions/setup-dotnet@v2
with:
dotnet-version: 5.0.x
-
name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0.9.13
with:
versionSpec: '5.x'
-
name: Cache Docker layers
uses: actions/cache@v3.0.3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
-
name: Create AssemblyVersionInfo
run: |
echo '
using System.Reflection;
[assembly: AssemblyFileVersion("0.0.0.0")]
[assembly: AssemblyVersion("0.0.0.0")]
[assembly: AssemblyInformationalVersion("0.0.0.0")]
' > ../AssemblyVersionInfo.cs
-
name: Generate assembly info
uses: gittools/actions/gitversion/execute@v0.9.13
with:
updateAssemblyInfo: true
updateAssemblyInfoFilename: src/AssemblyVersionInfo.cs
-
name: Available platforms
run: echo ${{ steps.buildx.outputs.platforms }}
-
name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2.0.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push Docker images
uses: docker/build-push-action@v3.0.0
with:
context: src
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: ${{ github.event_name != 'pull_request' }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
-
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache