-
-
Notifications
You must be signed in to change notification settings - Fork 4
219 lines (186 loc) · 8.42 KB
/
build.yml
File metadata and controls
219 lines (186 loc) · 8.42 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
name: Build and Release
on:
push:
tags:
- 'v[0-9]*.[0-9]*.[0-9]*'# Trigger only on version tags like v1.2.3
jobs:
# --- JOB 1: BUILD ---
# This job runs in a matrix to build for all target platforms in parallel.
build:
name: Build for ${{ matrix.target }}
runs-on: ubuntu-latest
strategy:
matrix:
include:
- target: linux-x64
asset_name: OpenSSH-GUI-linux-x64
asset_extension: ''
- target: win-x64
asset_name: OpenSSH-GUI-win-x64
asset_extension: '.exe'
- target: osx-x64
asset_name: OpenSSH-GUI-osx-x64
asset_extension: ''
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Determine .NET version from project
id: dotnet-version
run: |
TFM=$(grep -oPm1 '(?<=<TargetFramework>net)[0-9.]+' Directory.Build.props)
echo "version=${TFM}.x" >> "$GITHUB_OUTPUT"
echo "Detected TargetFramework: net${TFM} → installing SDK ${TFM}.x"
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ steps.dotnet-version.outputs.version }}
- name: Cache dependencies
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-dotnet-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-dotnet-
# Restore, build, and publish the application for the specific target
- name: Publish application
run: |
dotnet publish OpenSSH_GUI/OpenSSH_GUI.csproj \
--configuration Release \
--runtime ${{ matrix.target }} \
--output "./publish" \
-p:PublishSingleFile=true \
-p:PublishReadyToRun=true \
-p:IncludeNativeLibrariesForSelfExtract=true \
-p:Version="${GITHUB_REF_NAME#v}"
# Rename the output file to the desired asset name
- name: Rename artifact
run: mv ./publish/OpenSSH_GUI${{ matrix.asset_extension }} ./publish/${{ matrix.asset_name }}${{ matrix.asset_extension }}
# --- AppImage (Linux only) ---
- name: Build AppImage
if: matrix.target == 'linux-x64'
run: |
# Download appimagetool
wget -q https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage -O appimagetool
chmod +x appimagetool
# Create AppDir structure
mkdir -p AppDir/usr/bin
mkdir -p AppDir/usr/share/icons/hicolor/256x256/apps
mkdir -p AppDir/usr/share/applications
mkdir -p AppDir/usr/share/metainfo
cp ./publish/${{ matrix.asset_name }} AppDir/usr/bin/openssh-gui
chmod +x AppDir/usr/bin/openssh-gui
cp OpenSSH_GUI/Assets/appicon.png AppDir/usr/share/icons/hicolor/256x256/apps/openssh-gui.png
cp OpenSSH_GUI/Assets/appicon.png AppDir/openssh-gui.png
cp appimage/io.github.frequency403.openssh_gui.metainfo.xml AppDir/usr/share/metainfo/io.github.frequency403.openssh_gui.metainfo.xml
sed -i "s|<release version=\"0.0.0\" date=\"1970-01-01\"/>|<release version=\"${APPSTREAM_VERSION}\" date=\"$(date +%Y-%m-%d)\"/>|" \
AppDir/usr/share/metainfo/io.github.frequency403.openssh_gui.metainfo.xml
appstreamcli make-desktop-file \
AppDir/usr/share/metainfo/io.github.frequency403.openssh_gui.metainfo.xml \
AppDir/usr/share/applications/io.github.frequency403.openssh_gui.desktop
cp AppDir/usr/share/applications/io.github.frequency403.openssh_gui.desktop \
AppDir/io.github.frequency403.openssh_gui.desktop
cp appimage/AppRun AppDir/AppRun
chmod +x AppDir/AppRun
# Build AppImage
ARCH=x86_64 ./appimagetool --appimage-extract-and-run AppDir OpenSSH-GUI-x86_64.AppImage
- name: Upload AppImage artifact
if: matrix.target == 'linux-x64'
uses: actions/upload-artifact@v4
with:
name: OpenSSH-GUI-x86_64.AppImage
path: OpenSSH-GUI-x86_64.AppImage
- name: Upload generated desktop file
if: matrix.target == 'linux-x64'
uses: actions/upload-artifact@v4
with:
name: io.github.frequency403.openssh_gui.desktop
path: AppDir/usr/share/applications/io.github.frequency403.openssh_gui.desktop
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.asset_name }}${{ matrix.asset_extension }}
path: ./publish/${{ matrix.asset_name }}${{ matrix.asset_extension }}
# --- JOB 2: RELEASE ---
# This job runs only ONCE after all build jobs have successfully completed.
release:
name: Create GitHub Release
runs-on: ubuntu-latest
# The 'needs' keyword ensures that this job waits for the 'build' job to finish
needs: build
permissions:
contents: write # Required to create a release and upload assets
# Ensure this job only runs for tag pushes, not for manual dispatches that should only build
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout repository
uses: actions/checkout@v4
# Download all artifacts (from the matrix builds) into a single directory
- name: Download all build artifacts
uses: actions/download-artifact@v4
with:
path: artifacts/
- name: Display structure of downloaded files
run: ls -R artifacts
- name: Prepare extra assets
run: |
cp OpenSSH_GUI/Assets/appicon.png artifacts/
cp LICENSE artifacts/
# Create a single release and upload all files from the 'artifacts' directory
- name: Create Release and Upload Assets
uses: softprops/action-gh-release@v2
with:
# The release will be created from the pushed tag
tag_name: ${{ github.ref_name }}
# All files downloaded into the 'artifacts' directory will be uploaded
files: "artifacts/**/*"
# Automatically generate the release body from commits since the last tag
generate_release_notes: true
deploy-aur:
name: Update AUR Packages
runs-on: ubuntu-latest
needs: release
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download Linux Artifact
uses: actions/download-artifact@v4
with:
name: OpenSSH-GUI-linux-x64
path: ./
- name: Download generated desktop file
uses: actions/download-artifact@v4
with:
name: io.github.frequency403.openssh_gui.desktop
path: ./
- name: Update PKGBUILD for openssh-gui-bin
run: |
VERSION=${GITHUB_REF_NAME#v}
SHA_BIN=$(sha256sum OpenSSH-GUI-linux-x64 | cut -d' ' -f1)
SHA_ICON=$(sha256sum OpenSSH_GUI/Assets/appicon.png | cut -d' ' -f1)
SHA_DESKTOP=$(sha256sum io.github.frequency403.openssh_gui.desktop | cut -d' ' -f1)
SHA_LICENSE=$(sha256sum LICENSE | cut -d' ' -f1)
sed -i "s/^pkgver=.*/pkgver=$VERSION/" openssh-gui-bin/PKGBUILD
sed -i "s/sha256sums=.*/sha256sums=('$SHA_BIN' '$SHA_ICON' '$SHA_DESKTOP' '$SHA_LICENSE')/" openssh-gui-bin/PKGBUILD
# Also update openssh-gui-git pkgver for consistency
sed -i "s/^pkgver=.*/pkgver=$VERSION/" openssh-gui-git/PKGBUILD
- name: Update AUR (openssh-gui-bin)
uses: KSXGitHub/github-actions-deploy-aur@v4.1.1
with:
pkgname: openssh-gui-bin
pkgbuild: ./openssh-gui-bin/PKGBUILD
commit_username: ${{ github.repository_owner }}
commit_email: ${{ github.repository_owner }}@users.noreply.github.com
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
commit_message: "Update to ${{ github.ref_name }}"
- name: Update AUR (openssh-gui-git)
uses: KSXGitHub/github-actions-deploy-aur@v4.1.1
with:
pkgname: openssh-gui-git
pkgbuild: ./openssh-gui-git/PKGBUILD
commit_username: ${{ github.repository_owner }}
commit_email: ${{ github.repository_owner }}@users.noreply.github.com
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
commit_message: "Update to ${{ github.ref_name }}"