-
Notifications
You must be signed in to change notification settings - Fork 2
272 lines (229 loc) · 10.2 KB
/
build_and_release_all.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
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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
name: Build and Release OpenIPC Config App
permissions:
contents: write
actions: read
on:
workflow_dispatch:
push:
tags:
- 'release-v*' # Trigger for tags that start with 'v', e.g., v1.0.0, v2.1.3
# branches:
# - release-notes
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
arch: [x64, arm64]
# os: [ubuntu-latest]
# arch: [arm64]
# os: [ macos-latest ]
# arch: [arm64]
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'
- name: Read Version from VERSION File
id: get_version
run: |
VERSION=${GITHUB_REF#refs/tags/}
VERSION=${VERSION#release-v} # Remove "release-v" prefix
echo "VERSION=$VERSION" >> $GITHUB_ENV
shell: bash
- name: Restore dependencies
run: dotnet restore OpenIPC_Config.Desktop/OpenIPC_Config.Desktop.csproj
- name: Build project
run: dotnet build OpenIPC_Config.Desktop/OpenIPC_Config.Desktop.csproj --configuration Release
- name: Run Tests
if: matrix.os == 'ubuntu-latest' && matrix.arch == 'x64'
run: dotnet test OpenIPC_Config.Tests/OpenIPC_Config.Tests.csproj --configuration Release --logger "trx;LogFileName=test-results.trx"
- name: Publish Project
run: |
if [[ "${{ runner.os }}" == "Windows" ]]; then
dotnet publish OpenIPC_Config.Desktop/OpenIPC_Config.Desktop.csproj -c Release -r win-x64 --self-contained
dotnet publish OpenIPC_Config.Desktop/OpenIPC_Config.Desktop.csproj -c Release -r win-arm64 --self-contained
elif [[ "${{ runner.os }}" == "macOS" ]]; then
dotnet publish OpenIPC_Config.Desktop/OpenIPC_Config.Desktop.csproj -c Release -r osx-x64 --self-contained
dotnet publish OpenIPC_Config.Desktop/OpenIPC_Config.Desktop.csproj -c Release -r osx-arm64 --self-contained
else
dotnet publish OpenIPC_Config.Desktop/OpenIPC_Config.Desktop.csproj -c Release -r linux-x64 --self-contained
dotnet publish OpenIPC_Config.Desktop/OpenIPC_Config.Desktop.csproj -c Release -r linux-arm64 --self-contained
fi
shell: bash
# Packaging macOS .app bundle
- name: Package macOS .app
if: matrix.os == 'macos-latest'
run: |
APP_NAME="OpenIPC_Config"
PUBLISH_DIR="./OpenIPC_Config.Desktop/bin/Release/net8.0/osx-${{ matrix.arch }}/publish"
APP_DIR="${APP_NAME}.app"
mkdir -p "${APP_DIR}/Contents/MacOS"
mkdir -p "${APP_DIR}/Contents/Resources"
cp -R "${PUBLISH_DIR}/"* "${APP_DIR}/Contents/MacOS/"
cp ./OpenIPC_Config/Assets/Icons/OpenIPC.icns "${APP_DIR}/Contents/Resources/${APP_NAME}.icns"
cat << EOF > "${APP_DIR}/Contents/Info.plist"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key>
<string>${APP_NAME}</string>
<key>CFBundleExecutable</key>
<string>${APP_NAME}.Desktop</string>
<key>CFBundleIdentifier</key>
<string>com.openipc.${APP_NAME}</string>
<key>CFBundleVersion</key>
<string>${{ env.VERSION }}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>LSMinimumSystemVersion</key>
<string>10.13</string>
<key>CFBundleIconFile</key>
<string>${APP_NAME}.icns</string>
</dict>
</plist>
EOF
chmod +x "${APP_DIR}/Contents/MacOS/${APP_NAME}.Desktop"
# - name: Debug Signature Before Signing
# if: matrix.os == 'macos-latest'
# run: codesign -dvvv OpenIPC_Config.app || echo "No signature found"
# - name: Import Signing Certificate
# if: matrix.os == 'macos-latest'
# env:
# APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
# APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
# run: |
# echo "$APPLE_CERTIFICATE" | base64 --decode > signing_certificate.p12
# ls -l signing_certificate.p12
# md5 signing_certificate.p12
# security import signing_certificate.p12 -P "$APPLE_CERTIFICATE_PASSWORD" -A
# security find-identity -p codesigning -v
# - name: Code Sign Nested Components
# if: matrix.os == 'macos-latest'
# run: |
# find OpenIPC_Config.app -type f -name "*.dll" -exec codesign --force --options runtime --sign "Developer ID Application: Mike Carr (EQKLR945TW)" {} \;
# codesign --force --options runtime --deep --sign "Developer ID Application: Mike Carr (EQKLR945TW)" OpenIPC_Config.app
# - name: Remove Quarantine Flag (macOS only)
# if: matrix.os == 'macos-latest'
# run: xattr -cr OpenIPC_Config.app
# Linux Icon and Packaging
- name: Set up Icon and .desktop file
if: matrix.os == 'ubuntu-latest'
run: |
APP_NAME="OpenIPC-Config"
PUBLISH_DIR="./OpenIPC_Config.Desktop/bin/Release/net8.0/linux-x64/publish"
ICON_PATH="${PUBLISH_DIR}/Assets/OpenIPC.png"
DESKTOP_FILE="${PUBLISH_DIR}/${APP_NAME}.desktop"
# Ensure the icon is in the publish directory
cp ./OpenIPC_Config/Assets/Icons/OpenIPC.png "$ICON_PATH"
# Create .desktop file
cat << EOF > "$DESKTOP_FILE"
[Desktop Entry]
Name=OpenIPC Config
Exec=$PUBLISH_DIR/OpenIPC-Config.Desktop
Icon=$ICON_PATH
Type=Application
Terminal=false
Categories=Utility;
EOF
# Windows Icon and Packaging
- name: Set Windows Icon and Package
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
$PUBLISH_DIR = "./OpenIPC_Config.Desktop/bin/Release/net8.0/win-${{ matrix.arch }}/publish"
$ICON_PATH = "./OpenIPC_Config/Assets/Icons/OpenIPC.ico"
# Install rcedit to modify the Windows executable icon
choco install rcedit -y
rcedit "$PUBLISH_DIR/OpenIPC_Config.Desktop.exe" --set-icon "$ICON_PATH"
# Zip the Windows build
Compress-Archive -Path "$PUBLISH_DIR\*" -DestinationPath "OpenIPC-Config-windows-${{ matrix.arch }}.zip"
env:
DOTNET_ROOT: C:\Program Files\dotnet
VERSION: 0.0.1
- name: Zip .app Bundle for MacOS and Linux
run: |
echo "Runner OS: ${{ runner.os }}"
if [[ "${{ runner.os }}" == "macOS" ]]; then
DMG_NAME="OpenIPC-Config-macos-${{ matrix.arch }}.dmg"
APP_NAME="OpenIPC_Config.app"
BUILD_DIR="OpenIPC-Config-macos-${{ matrix.arch }}-dmg-build"
# Create a temporary folder for the .dmg contents
mkdir -p "${BUILD_DIR}"
cp -R "${APP_NAME}" "${BUILD_DIR}/"
# Create an alias to the Applications folder
ln -s /Applications "${BUILD_DIR}/Applications"
# Create the .dmg with the Applications alias
hdiutil create -volname "OpenIPC Config" -srcfolder "${BUILD_DIR}" -ov -format UDZO "${DMG_NAME}"
# Clean up the temporary build folder
rm -rf "${BUILD_DIR}"
elif [[ "${{ runner.os }}" == "Linux" ]]; then
mkdir -p OpenIPC-Config-linux-${{ matrix.arch }}
cp -r ./OpenIPC_Config.Desktop/bin/Release/net8.0/linux-${{ matrix.arch }}/publish/* OpenIPC-Config-linux-${{ matrix.arch }}/
zip -r OpenIPC-Config-linux-${{ matrix.arch }}.zip OpenIPC-Config-linux-${{ matrix.arch }}
echo "directory created"
ls -al
# zip -r OpenIPC-Config-linux-${{ matrix.arch }}.zip ./OpenIPC_Config.Desktop/bin/Release/net8.0/linux-${{ matrix.arch }}/publish/*
fi
shell: bash
# Upload Artifacts
- name: Upload macOS Artifact
if: matrix.os == 'macos-latest'
uses: actions/upload-artifact@v4
with:
name: OpenIPC-Config-macos-${{ matrix.arch }}.dmg
path: OpenIPC-Config-macos-${{ matrix.arch }}.dmg
- name: Upload Windows Artifact
if: matrix.os == 'windows-latest'
uses: actions/upload-artifact@v4
with:
name: OpenIPC-Config-windows-${{ matrix.arch }}
path: OpenIPC-Config-windows-${{ matrix.arch }}.zip
- name: Upload Ubuntu Artifact
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: OpenIPC-Config-linux-${{ matrix.arch }}
path: OpenIPC-Config-linux-${{ matrix.arch }}.zip
release:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Read Version from VERSION File
id: get_version
run: |
#VERSION=$(cat VERSION)
VERSION=${GITHUB_REF#refs/tags/}
echo "VERSION=$VERSION" >> $GITHUB_ENV
shell: bash
- name: Download All Artifacts
uses: actions/download-artifact@v4
with:
path: .
- name: List Downloaded Files
run: ls -R .
- name: Generate latest.json
run: |
cat << EOF > latest.json
{
"version": "${{ env.VERSION }}",
"release_notes": "This is a dynamically generated release note. Update as needed.",
"download_url": "https://github.com/${{ github.repository }}/releases/"
}
EOF
- name: Create GitHub Release and Upload Assets
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
draft: true
generate_release_notes: true
files: |
./OpenIPC-Config-*/OpenIPC-Config-*.zip
./OpenIPC-Config-*/OpenIPC-Config-*.dmg
./latest.json