-
Notifications
You must be signed in to change notification settings - Fork 2
157 lines (139 loc) · 4.96 KB
/
Copy pathbuild.yml
File metadata and controls
157 lines (139 loc) · 4.96 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
name: Build and Release
on:
push:
branches: [ main ]
tags:
- v*.*.*
pull_request:
branches: [ main ]
jobs:
prepare:
name: Prepare versions
runs-on: ubuntu-latest
outputs:
branchName: ${{ steps.version_step.outputs.branchName }}
shortSha: ${{ steps.version_step.outputs.shortSha }}
fullSemVer: ${{ steps.version_step.outputs.fullSemVer }}
assemblySemVer: ${{ steps.version_step.outputs.assemblySemVer }}
commitDate: ${{ steps.version_step.outputs.commitDate }}
artifactVersion: ${{ steps.artifact_version_step.outputs.artifactVersion }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v3.2.1
with:
versionSpec: '6.3.x'
- name: Determine Version
id: version_step # step id used as a reference for output values
uses: gittools/actions/gitversion/execute@v3.2.1
build:
name: Build
runs-on: ${{ matrix.os }}
needs: prepare
if: success()
strategy:
fail-fast: false
matrix:
runtime: [linux-x64, linux-arm64, win-x64, win-arm64, osx-x64, osx-arm64]
configuration: [Release]
include:
- runtime: linux-x64
os: ubuntu-latest
- runtime: linux-arm64
os: ubuntu-latest
- runtime: win-x64
os: windows-latest
- runtime: win-arm64
os: windows-latest
- runtime: osx-x64
os: macos-latest
- runtime: osx-arm64
os: macos-latest
env:
VERSION_SEMVER: ${{ needs.prepare.outputs.assemblySemVer }}
VERSION_FULL_SEMVER: ${{ needs.prepare.outputs.fullSemVer }}
GIT_SHORT_SHA: ${{ needs.prepare.outputs.shortSha }}
LAST_COMMIT_DATE: ${{ needs.prepare.outputs.commitDate }}
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
- name: Restore dependencies
run: dotnet restore
- name: Test
shell: bash
run: |
dotnet test --no-restore --configuration ${{ matrix.configuration }}
- name: Build
shell: bash
run: |
dotnet build --no-restore --configuration ${{ matrix.configuration }} \
-p:Version=${{ env.VERSION_FULL_SEMVER }} \
-p:AssemblyVersion=${{ env.VERSION_SEMVER }} \
-p:FileVersion=${{ env.VERSION_SEMVER }}
- name: Publish
shell: bash
run: |
dotnet publish --configuration ${{ matrix.configuration }} \
-r ${{ matrix.runtime }} \
--self-contained true \
-p:PublishSingleFile=true \
-p:IncludeNativeLibrariesForSelfExtract=true \
-p:Version=${{ env.VERSION_FULL_SEMVER }} \
-p:AssemblyVersion=${{ env.VERSION_SEMVER }} \
-p:FileVersion=${{ env.VERSION_SEMVER }}
- name: Create artifact directory
shell: bash
run: mkdir -p artifacts/${{ matrix.runtime }}/${{ matrix.configuration }}
- name: Copy artifacts
shell: bash
run: |
cp -r PostCodeSerialMonitor/bin/${{ matrix.configuration }}/net9.0/${{ matrix.runtime }}/publish/* artifacts/${{ matrix.runtime }}/${{ matrix.configuration }}/
cp PostCodeSerialMonitor/config.json artifacts/${{ matrix.runtime }}/${{ matrix.configuration }}/
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: XboxPostCodeMonitor_${{ env.GIT_SHORT_SHA }}_${{ env.LAST_COMMIT_DATE }}_${{ matrix.runtime }}
path: artifacts/${{ matrix.runtime }}/${{ matrix.configuration }}
retention-days: 5
release:
name: Release
needs: build
if: success() && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: List dir
run: ls -R
- name: Create release packages
shell: bash
run: |
# Create a directory for release packages
mkdir -p release-packages
# Get the version from the tag
VERSION=${GITHUB_REF#refs/tags/v}
# Create zip files for each platform and configuration
for platform in linux-x64 linux-arm64 win-x64 win-arm64 osx-x64 osx-arm64; do
cd artifacts/XboxPostCodeMonitor_*_$platform
rm *.pdb
zip -r "../../release-packages/XboxPostCodeMonitor-$VERSION-$platform.zip" .
cd ../..
done
- name: Create Release
uses: softprops/action-gh-release@v2
with:
files: |
release-packages/*.zip
generate_release_notes: true
fail_on_unmatched_files: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}