-
Notifications
You must be signed in to change notification settings - Fork 6
191 lines (174 loc) · 9.24 KB
/
docker-teamcityagent-image.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
183
184
185
186
187
188
189
190
191
name: Build teamcity-agent image
on:
push:
branches: ["main", "dev*"]
tags: ["*.*.*", "*.*", "!minver-*.*.*", "!minver-*.*"]
pull_request:
branches: [main]
jobs:
docker:
strategy:
fail-fast: false
matrix:
runs-on: [ubuntu-latest]
name: build-${{ matrix.runs-on }}
runs-on: ${{ matrix.runs-on }}
env:
IS_SEMVER_TAG: ${{ false }}
IS_TAG: ${{ null }}
steps:
- uses: actions/checkout@v4
- name: Check Tag Ref
shell: pwsh
run: |
$isTag='${{ startsWith(github.ref, 'refs/tags/') }}'
Write-Output "IS_TAG=$isTag" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
if ($true -eq $isTag) {
if ($Env:GITHUB_REF_NAME -match '^(\d+\.\d+(\.\d+)?(-.+)?)$') {
Write-Output "IS_SEMVER_TAG=true" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
}
}
# https://github.com/orgs/community/discussions/26351
# https://github.com/jens-maus/RaspberryMatic/blob/d5044bef3307bc61166377c162569de1a61cf332/.github/workflows/ci.yml#L34-L40
- name: Free disk space
run: |
sudo swapoff -a
sudo rm -f /swapfile
sudo apt clean
docker rmi $(docker image ls -aq)
df -h
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ secrets.DOCKER_HUB_REPOS }}
name=teslaconsulting/teamcity-agent,enable=${{ env.IS_SEMVER_TAG == 'true' }}
flavor: |
latest=false
tags: |
type=match,enable=true,priority=900,prefix=,suffix=,pattern=^(\d+\.\d+(\.\d+)?(-.+)?)$,group=1
type=match,enable=true,priority=890,prefix=,suffix=,pattern=^(\d+\.\d+(\.\d+)?)(-.+)?$,group=1
type=match,enable=true,priority=880,prefix=,suffix=,pattern=^(\d+\.\d+)(\.\d+)?(-.+)?$,group=1
type=match,enable=false,priority=870,prefix=,suffix=,pattern=^(\d+)\.\d+(\.\d+)?(-.+)?$,group=1
type=ref,enable=true,priority=600,event=branch
type=sha,enable=true,priority=500,prefix=sha-,suffix=,format=short
# - name: Set up QEMU
# uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Get MinVer version
id: minver_version
shell: pwsh
run: |
$minver_help=$(docker run --rm teslaconsulting/minver-cli:latest minver --help)
Write-Output "Minver help:`n$minver_help"
$minver_version=$minver_help[0] -Replace '^[^0-9]+([0-9.]+)[^0-9].*$','$1'
Write-Output "Minver version: $minver_version"
Write-Output "version=$minver_version" >> $env:GITHUB_OUTPUT
- name: Get Docker Compose version
id: docker_compose_version
run: |
DOCKER_COMPOSE_VERSION=$(docker run --rm docker:cli docker compose version)
echo "Docker compose version raw: $DOCKER_COMPOSE_VERSION"
DOCKER_COMPOSE_VERSION=${DOCKER_COMPOSE_VERSION#Docker Compose version v}
echo "Docker compose version only: '$DOCKER_COMPOSE_VERSION'"
echo "version=$DOCKER_COMPOSE_VERSION" >> $GITHUB_OUTPUT
#- name: Get .NETCore 3.1 Versions
# id: dotnetcore31_vers
# shell: pwsh
# run: |
# $dotnet_info_raw=$(docker run --rm mcr.microsoft.com/dotnet/sdk:3.1-focal dotnet --info) -join ' '
# $dotnet_sdk_version=$dotnet_info_raw -replace '^.+\.NET Core SDKs installed:[^0-9]+([0-9.]+)[^0-9].*$','$1'
# $aspnetcore_version=$dotnet_info_raw -replace '^.+Microsoft.AspNetCore.App\s+([0-9.]+)[^0-9.].*$','$1'
# $dotnet_version=$dotnet_info_raw -replace '^.+Microsoft.NETCore.App\s+([0-9.]+)[^0-9.].*$','$1'
# Write-Output "Version SDK:$dotnet_sdk_version ASP.NET:$aspnetcore_version .NETCore:$dotnet_version"
# Write-Output "sdk=$dotnet_sdk_version" >> $env:GITHUB_OUTPUT
# Write-Output "aspnet=$aspnetcore_version" >> $env:GITHUB_OUTPUT
# Write-Output "dotnet=$dotnet_version" >> $env:GITHUB_OUTPUT
#- name: Get .NET 5.0 Versions
# id: dotnet5_vers
# shell: pwsh
# run: |
# $dotnet_vers=$(docker run --rm mcr.microsoft.com/dotnet/sdk:5.0-focal sh -c 'echo $DOTNET_SDK_VERSION;echo $ASPNET_VERSION;echo $DOTNET_VERSION')
# Write-Output "Version SDK:$($dotnet_vers[0]) ASP.NET:$($dotnet_vers[1]) .NETCore:$($dotnet_vers[2])"
# Write-Output "sdk=$($dotnet_vers[0])" >> $env:GITHUB_OUTPUT
# Write-Output "aspnet=$($dotnet_vers[1])" >> $env:GITHUB_OUTPUT
# Write-Output "dotnet=$($dotnet_vers[2])" >> $env:GITHUB_OUTPUT
#- name: Get .NET 6.0 Versions
# id: dotnet6_vers
# shell: pwsh
# run: |
# $dotnet_vers=$(docker run --rm mcr.microsoft.com/dotnet/sdk:6.0-focal sh -c 'echo $DOTNET_SDK_VERSION;echo $ASPNET_VERSION;echo $DOTNET_VERSION')
# Write-Output "Version SDK:$($dotnet_vers[0]) ASP.NET:$($dotnet_vers[1]) .NETCore:$($dotnet_vers[2])"
# Write-Output "sdk=$($dotnet_vers[0])" >> $env:GITHUB_OUTPUT
# Write-Output "aspnet=$($dotnet_vers[1])" >> $env:GITHUB_OUTPUT
# Write-Output "dotnet=$($dotnet_vers[2])" >> $env:GITHUB_OUTPUT
- name: Get .NET 7.0 Versions
id: dotnet7_vers
shell: pwsh
run: |
$dotnet_vers=$(docker run --rm mcr.microsoft.com/dotnet/sdk:7.0-jammy sh -c 'echo $DOTNET_SDK_VERSION;echo $ASPNET_VERSION;echo $DOTNET_VERSION')
Write-Output "Version SDK:$($dotnet_vers[0]) ASP.NET:$($dotnet_vers[1]) .NETCore:$($dotnet_vers[2])"
Write-Output "sdk=$($dotnet_vers[0])" >> $env:GITHUB_OUTPUT
Write-Output "aspnet=$($dotnet_vers[1])" >> $env:GITHUB_OUTPUT
Write-Output "dotnet=$($dotnet_vers[2])" >> $env:GITHUB_OUTPUT
- name: Get .NET 8.0 Versions
id: dotnet8_vers
shell: pwsh
run: |
$dotnet_vers=$(docker run --rm mcr.microsoft.com/dotnet/sdk:8.0-jammy sh -c 'echo $DOTNET_SDK_VERSION;echo $ASPNET_VERSION;echo $DOTNET_VERSION;pwsh --version')
Write-Output "Version SDK:$($dotnet_vers[0]) ASP.NET:$($dotnet_vers[1]) .NETCore:$($dotnet_vers[2])"
Write-Output "sdk=$($dotnet_vers[0])" >> $env:GITHUB_OUTPUT
Write-Output "aspnet=$($dotnet_vers[1])" >> $env:GITHUB_OUTPUT
Write-Output "dotnet=$($dotnet_vers[2])" >> $env:GITHUB_OUTPUT
Write-Output "pwsh=$($dotnet_vers[3].SubString(11))" >> $env:GITHUB_OUTPUT
- name: Get .NET 9.0 Versions
id: dotnet9_vers
shell: pwsh
run: |
$dotnet_vers=$(docker run --rm mcr.microsoft.com/dotnet/sdk:9.0-preview-jammy sh -c 'echo $DOTNET_SDK_VERSION;echo $ASPNET_VERSION;echo $DOTNET_VERSION;pwsh --version')
Write-Output "Version SDK:$($dotnet_vers[0]) ASP.NET:$($dotnet_vers[1]) .NETCore:$($dotnet_vers[2])"
Write-Output "sdk=$($dotnet_vers[0])" >> $env:GITHUB_OUTPUT
Write-Output "aspnet=$($dotnet_vers[1])" >> $env:GITHUB_OUTPUT
Write-Output "dotnet=$($dotnet_vers[2])" >> $env:GITHUB_OUTPUT
Write-Output "pwsh=$($dotnet_vers[3].SubString(11))" >> $env:GITHUB_OUTPUT
- name: Build and push
id: docker_build
uses: docker/build-push-action@v4
with:
context: ./teamcity-agent
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
MINVER_VERSION=${{ steps.minver_version.outputs.version }}
DOCKER_COMPOSE_VERSION=${{ steps.docker_compose_version.outputs.version }}
DOTNET_SDK_VERSION7=${{ steps.dotnet7_vers.outputs.sdk }}
ASPNET_VERSION7=${{ steps.dotnet7_vers.outputs.aspnet }}
DOTNET_VERSION7=${{ steps.dotnet7_vers.outputs.dotnet }}
DOTNET_SDK_VERSION8=${{ steps.dotnet8_vers.outputs.sdk }}
ASPNET_VERSION8=${{ steps.dotnet8_vers.outputs.aspnet }}
DOTNET_VERSION8=${{ steps.dotnet8_vers.outputs.dotnet }}
DOTNET_SDK_VERSION9=${{ steps.dotnet9_vers.outputs.sdk }}
ASPNET_VERSION9=${{ steps.dotnet9_vers.outputs.aspnet }}
DOTNET_VERSION9=${{ steps.dotnet9_vers.outputs.dotnet }}
POWERSHELL_VERSION=${{ steps.dotnet9_vers.outputs.pwsh }}
unused: |
DOTNET_SDK_VERSION31=${{ steps.dotnetcore31_vers.outputs.sdk }}
ASPNET_VERSION31=${{ steps.dotnetcore31_vers.outputs.aspnet }}
DOTNET_VERSION31=${{ steps.dotnetcore31_vers.outputs.dotnet }}
DOTNET_SDK_VERSION5=${{ steps.dotnet5_vers.outputs.sdk }}
ASPNET_VERSION5=${{ steps.dotnet5_vers.outputs.aspnet }}
DOTNET_VERSION5=${{ steps.dotnet5_vers.outputs.dotnet }}
DOTNET_SDK_VERSION6=${{ steps.dotnet6_vers.outputs.sdk }}
ASPNET_VERSION6=${{ steps.dotnet6_vers.outputs.aspnet }}
DOTNET_VERSION6=${{ steps.dotnet6_vers.outputs.dotnet }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}