-
-
Notifications
You must be signed in to change notification settings - Fork 7
162 lines (141 loc) · 5.86 KB
/
docker-publish.yml
File metadata and controls
162 lines (141 loc) · 5.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
name: Docker
on:
push:
tags:
- v*
branches:
- develop
pull_request:
env:
IMAGE_NAME: OpenAlprWebhookProcessor
jobs:
docker-build:
runs-on: ubuntu-latest
if: github.event_name != 'push' || !contains(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v2
- name: Run build
run: docker build . --file ./OpenAlprWebhookProcessor.Server/Dockerfile
build-test-analyze:
runs-on: ubuntu-latest
if: github.event_name != 'push' || !contains(github.ref, 'refs/tags/')
steps:
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'zulu'
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 10.x
- name: Install SonarQube Cloud scanner
run: |
dotnet tool install --global dotnet-sonarscanner
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Start SonarQube Analysis
run: |
dotnet-sonarscanner begin \
/k:"mlapaglia_OpenAlprWebhookProcessor" \
/o:"openalprwebhookprocessor" \
/d:sonar.token="${{ secrets.SONAR_TOKEN }}" \
/d:sonar.cs.opencover.reportsPaths="coverage/**/coverage.opencover.xml" \
/d:sonar.javascript.lcov.reportPaths="**/lcov.info" \
/d:sonar.exclusions="**/Data/Migrations/**,**/Infrastructure/Extensions/ServiceCollectionExtensions.cs"
- name: Build and Test Backend
run: |
dotnet restore
dotnet build --no-restore
dotnet test --no-build --collect:"XPlat Code Coverage;Format=opencover" --results-directory ./coverage
- name: Build and Test Frontend
working-directory: ./openalprwebhookprocessor.client
run: |
npm ci
npm run test:prod
- name: End SonarQube Analysis
run: |
dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
front-end-lint:
runs-on: ubuntu-latest
if: github.event_name != 'push' || !contains(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v2
- name: Run frontend lint
working-directory: ./openalprwebhookprocessor.client
run: |
npm ci
npm run lint
windows-build-push:
runs-on: ubuntu-latest
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
steps:
- name: Check out the repo
uses: actions/checkout@main
- name: Setup Buildx
uses: actions/setup-dotnet@v1
with:
dotnet-version: '10.x'
include-prerelease: true
- name: Build Artifact
run: |
tag=$(git describe --tags --abbrev=0)
version=${tag#v} # Remove 'v' prefix (e.g., 6.0.0-alpha25)
numeric_version=$(echo "$version" | sed 's/-.*//') # Extract numeric part (e.g., 6.0.0)
assembly_version="${numeric_version}.0" # Make it 4-part numeric (e.g., 6.0.0.0)
release_name="OpenAlprWebHookProcessor-${tag}-windows64"
dotnet restore "OpenAlprWebhookProcessor.Server/OpenAlprWebhookProcessor.Server.csproj"
dotnet build "OpenAlprWebhookProcessor.Server/OpenAlprWebhookProcessor.Server.csproj" -c Release \
-p:GitVersion="$version" \
-p:GitAssemblyVersion="$assembly_version" \
-p:GitFileVersion="$assembly_version"
dotnet publish "OpenAlprWebhookProcessor.Server/OpenAlprWebhookProcessor.Server.csproj" -c Release -o "$release_name" \
-r win-x64 --self-contained false \
-p:GitVersion="$version" \
-p:GitAssemblyVersion="$assembly_version" \
-p:GitFileVersion="$assembly_version"
tar czvf "${release_name}.tar.gz" "$release_name"
- name: Publish
uses: softprops/action-gh-release@v1
with:
files: "OpenAlprWebHookProcessor*"
prerelease: ${{ contains(github.ref, 'alpha') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
docker-build-push:
runs-on: ubuntu-latest
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Setup Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Get git tag and version
id: get_version
run: |
tag=${GITHUB_REF/refs\/tags\//}
version=${tag#v} # Remove 'v' prefix (e.g., 6.0.0-alpha25)
numeric_version=$(echo "$version" | sed 's/-.*//') # Extract numeric part (e.g., 6.0.0)
assembly_version="${numeric_version}.0" # Make it 4-part numeric (e.g., 6.0.0.0)
echo "VERSION=$tag" >> $GITHUB_OUTPUT
echo "GIT_VERSION=$version" >> $GITHUB_OUTPUT
echo "ASSEMBLY_VERSION=$assembly_version" >> $GITHUB_OUTPUT
- name: Push to Docker Hub
uses: docker/build-push-action@v5
with:
build-args: |
GIT_VERSION=${{ steps.get_version.outputs.GIT_VERSION }}
GIT_ASSEMBLY_VERSION=${{ steps.get_version.outputs.ASSEMBLY_VERSION }}
GIT_FILE_VERSION=${{ steps.get_version.outputs.ASSEMBLY_VERSION }}
file: ./OpenAlprWebhookProcessor.Server/Dockerfile
push: true
tags: |
mlapaglia/openalprwebhookprocessor:${{ steps.get_version.outputs.VERSION }}
${{ contains(github.ref, 'alpha') && 'mlapaglia/openalprwebhookprocessor:alpha' || 'mlapaglia/openalprwebhookprocessor:latest' }}