Repository navigation
243 lines (212 loc) · 7.84 KB
/
Copy pathbuild.yml
File metadata and controls
243 lines (212 loc) · 7.84 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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
name: Build and Release
on:
push:
branches:
- master
- develop
- 'feature/**'
- 'release/**'
- 'hotfix/**'
pull_request:
branches:
- master
- develop
workflow_dispatch:
inputs:
push_docker:
description: 'Build and push Docker image'
required: false
type: boolean
default: true
env:
DOTNET_VERSION: '10.0.x'
# The service embeds the Angular UI, so packaging needs node. Kept in step
# with the Dockerfile's node:22-alpine stage -- the container build and the
# Windows build must not compile the UI with different toolchains.
NODE_VERSION: '26.x'
CONFIGURATION: Release
jobs:
build-windows:
name: Build Papercut SMTP
runs-on: windows-2022
permissions:
contents: write
checks: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Required for GitVersion
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
cache-dependency-path: src/Papercut.Service/Web/package-lock.json
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v4.1.0
with:
versionSpec: '6.x'
- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/execute@v4.1.0
with:
configFilePath: GitVersion.yml
- name: Display GitVersion outputs
run: |
echo "SemVer: ${{ steps.gitversion.outputs.semVer }}"
echo "FullSemVer: ${{ steps.gitversion.outputs.fullSemVer }}"
echo "BranchName: ${{ steps.gitversion.outputs.branchName }}"
- name: Run Cake Build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
pwsh .\build.ps1
- name: Check for Test Results
if: always()
run: |
if (Test-Path "TestResults") {
Write-Host "TestResults directory found"
Get-ChildItem -Path TestResults -Recurse -File | ForEach-Object { Write-Host $_.FullName }
} else {
Write-Host "TestResults directory not found"
}
- name: Publish Test Results
uses: dorny/test-reporter@v1
if: always()
with:
name: Test Results
path: 'TestResults/*.trx'
reporter: dotnet-trx
fail-on-error: false
- name: Upload Build Artifacts
uses: actions/upload-artifact@v4
if: github.event_name == 'push' && (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master')
with:
name: papercut-releases-${{ steps.gitversion.outputs.fullSemVer }}
path: releases/*
if-no-files-found: warn
build-macos:
name: Build Papercut SMTP (${{ matrix.rid }})
needs: build-windows
runs-on: ${{ matrix.os }}
permissions:
contents: write
strategy:
fail-fast: false
matrix:
include:
- rid: osx-arm64
os: macos-latest
- rid: osx-x64
os: macos-15-intel
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
cache-dependency-path: src/Papercut.Service/Web/package-lock.json
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v4.1.0
with:
versionSpec: '6.x'
- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/execute@v4.1.0
with:
configFilePath: GitVersion.yml
# same channels as build.cake
- name: Set channel
id: channel
run: |
echo "$HOME/.dotnet/tools" >> "$GITHUB_PATH"
case "$GITHUB_REF_NAME" in
master) echo "postfix=-stable" >> "$GITHUB_OUTPUT" ;;
develop) echo "postfix=-dev" >> "$GITHUB_OUTPUT" ;;
*) echo "postfix=-alpha" >> "$GITHUB_OUTPUT" ;;
esac
- name: Package
run: bash src/Papercut.Desktop/packaging/macos/pack.sh ${{ matrix.rid }} "${{ steps.gitversion.outputs.fullSemVer }}" "${{ steps.channel.outputs.postfix }}"
- name: Smoke test
run: bash src/Papercut.Desktop/packaging/macos/smoke-test.sh "src/Papercut.Desktop/packaging/macos/out/${{ matrix.rid }}/releases"
# adds to the draft release build-windows created
- name: Upload to the release
if: github.event_name == 'push' && (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
vpk upload github \
--outputDir "src/Papercut.Desktop/packaging/macos/out/${{ matrix.rid }}/releases" \
--channel "${{ matrix.rid }}${{ steps.channel.outputs.postfix }}" \
--repoUrl "https://github.com/ChangemakerStudios/Papercut-SMTP" \
--token "$GITHUB_TOKEN" \
--merge \
${{ github.ref == 'refs/heads/master' && ' ' || '--pre' }}
build-docker:
name: Build and Push Docker Image
runs-on: ubuntu-latest
if: |
github.event_name == 'workflow_dispatch' ||
((github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop') && github.event_name == 'push')
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v4.1.0
with:
versionSpec: '6.x'
- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/execute@v4.1.0
with:
configFilePath: GitVersion.yml
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: changemakerstudiosus/papercut-smtp
tags: |
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/master' }}
type=raw,value=dev,enable=${{ github.ref == 'refs/heads/develop' }}
type=raw,value=${{ steps.gitversion.outputs.fullSemVer }},enable=${{ github.ref == 'refs/heads/develop' }}
type=semver,pattern={{version}},value=${{ steps.gitversion.outputs.semVer }},enable=${{ github.ref == 'refs/heads/master' }}
type=semver,pattern={{major}}.{{minor}},value=${{ steps.gitversion.outputs.semVer }},enable=${{ github.ref == 'refs/heads/master' }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: ${{ (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop') && (github.event_name != 'workflow_dispatch' || inputs.push_docker) }}
tags: ${{ steps.meta.outputs.tags || format('changemakerstudiosus/papercut-smtp:test-{0}', github.sha) }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
BUILD_VERSION=${{ steps.gitversion.outputs.fullSemVer }}
BUILD_DATE=${{ github.event.repository.updated_at }}
VCS_REF=${{ github.sha }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max