-
-
Notifications
You must be signed in to change notification settings - Fork 9
166 lines (148 loc) · 5.11 KB
/
Copy pathpublish.yml
File metadata and controls
166 lines (148 loc) · 5.11 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
# Build, test, and publish release packages on version tags (v*).
# Manual run: Actions → Publish → Run workflow.
name: Publish
on:
workflow_dispatch:
push:
tags:
- "v*"
permissions:
contents: write
env:
DOTNET_VERSION: "10.0.x"
PROJECT: OscarWatch/OscarWatch.csproj
jobs:
validate:
name: Build and test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- run: dotnet build OscarWatch.slnx -c Release
- run: dotnet test OscarWatch.slnx -c Release --no-build
publish:
name: ${{ matrix.display_name }}
needs: validate
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- rid: win-x64
os: windows-latest
display_name: Windows x64
archive_ext: zip
publish_single_file: true
- rid: win-arm64
os: windows-latest
display_name: Windows ARM64
archive_ext: zip
publish_single_file: true
- rid: osx-arm64
os: macos-latest
display_name: macOS Apple Silicon
archive_ext: tar.gz
publish_single_file: false
- rid: osx-x64
os: macos-latest
display_name: macOS Intel
archive_ext: tar.gz
publish_single_file: false
- rid: linux-x64
os: ubuntu-latest
display_name: Linux x64
archive_ext: tar.gz
publish_single_file: false
- rid: linux-arm64
os: ubuntu-latest
display_name: Linux ARM64 (Raspberry Pi 64-bit)
archive_ext: tar.gz
publish_single_file: false
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Resolve version
id: version
shell: bash
run: |
if [[ "${{ github.ref_type }}" == "tag" ]]; then
ver="${GITHUB_REF_NAME#v}"
echo "version=${ver}" >> "$GITHUB_OUTPUT"
echo "assembly_version=${ver}" >> "$GITHUB_OUTPUT"
else
short="${GITHUB_SHA::7}"
echo "version=0.0.0-ci.${short}" >> "$GITHUB_OUTPUT"
# AssemblyVersion/FileVersion must be numeric (major.minor.build.revision).
echo "assembly_version=0.0.0.0" >> "$GITHUB_OUTPUT"
fi
- name: Publish (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$out = "${{ runner.temp }}/publish-${{ matrix.rid }}"
$singleFile = "${{ matrix.publish_single_file }}"
dotnet publish "${{ env.PROJECT }}" `
-c Release `
-r "${{ matrix.rid }}" `
--self-contained true `
-p:Version="${{ steps.version.outputs.version }}" `
-p:AssemblyVersion="${{ steps.version.outputs.assembly_version }}" `
-p:FileVersion="${{ steps.version.outputs.assembly_version }}" `
-p:InformationalVersion="${{ steps.version.outputs.version }}" `
-p:PublishSingleFile=$singleFile `
-p:IncludeNativeLibrariesForSelfExtract=$singleFile `
-o $out
- name: Publish (Unix)
if: runner.os != 'Windows'
shell: bash
run: |
out="${{ runner.temp }}/publish-${{ matrix.rid }}"
dotnet publish "${{ env.PROJECT }}" \
-c Release \
-r "${{ matrix.rid }}" \
--self-contained true \
-p:Version="${{ steps.version.outputs.version }}" \
-p:AssemblyVersion="${{ steps.version.outputs.assembly_version }}" \
-p:FileVersion="${{ steps.version.outputs.assembly_version }}" \
-p:InformationalVersion="${{ steps.version.outputs.version }}" \
-o "$out"
- name: Archive
id: archive
shell: pwsh
run: |
$src = "${{ runner.temp }}/publish-${{ matrix.rid }}"
$version = "${{ steps.version.outputs.value }}"
$rid = "${{ matrix.rid }}"
if ("${{ matrix.archive_ext }}" -eq "zip") {
$dest = "${{ runner.temp }}/OscarWatch-${version}-${rid}.zip"
Compress-Archive -Path "$src/*" -DestinationPath $dest -Force
} else {
$dest = "${{ runner.temp }}/OscarWatch-${version}-${rid}.tar.gz"
tar -czf $dest -C $src .
}
echo "path=$dest" >> $env:GITHUB_OUTPUT
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: OscarWatch-${{ matrix.rid }}
path: ${{ steps.archive.outputs.path }}
if-no-files-found: error
release:
name: GitHub Release
needs: publish
if: github.ref_type == 'tag'
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Create release
uses: softprops/action-gh-release@v2
with:
files: artifacts/**
generate_release_notes: true