forked from openscopeproject/TrguiNG
-
Notifications
You must be signed in to change notification settings - Fork 0
194 lines (170 loc) · 5.98 KB
/
build.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
name: 'build'
on:
workflow_dispatch:
push:
tags:
- v**
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
download-dbip:
runs-on: ubuntu-latest
steps:
- name: Download dbip database
run: wget -nv -O- "https://download.db-ip.com/free/dbip-country-lite-2024-09.mmdb.gz" | zcat > dbip.mmdb
- uses: actions/upload-artifact@v3
with:
name: dbip
path: "dbip.mmdb"
build-binaries:
needs: download-dbip
strategy:
fail-fast: false
matrix:
platform:
- os: ubuntu-latest
rust_target: x86_64-unknown-linux-gnu
- os: macos-latest
rust_target: x86_64-apple-darwin
- os: macos-latest
rust_target: aarch64-apple-darwin
- os: windows-latest
rust_target: x86_64-pc-windows-msvc
runs-on: ${{ matrix.platform.os }}
steps:
- name: Disable crlf
if: matrix.platform.os == 'windows-latest'
run: |
git config --global core.autocrlf input
- uses: actions/checkout@v3
# Download the previously uploaded artifacts
- uses: actions/download-artifact@v3
id: download
with:
name: dbip
path: src-tauri/
- name: setup node
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'
- name: 'Setup Rust'
if: matrix.platform.rust_target == 'aarch64-apple-darwin'
run: rustup target add aarch64-apple-darwin
- name: "Setup Rust"
if: matrix.platform.rust_target == 'x86_64-apple-darwin'
run: rustup target add x86_64-apple-darwin
- uses: Swatinem/rust-cache@v2
with:
shared-key: ${{ matrix.platform.rust_target }}
workspaces: |
src-tauri
- name: install dependencies (ubuntu only)
if: matrix.platform.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf libasound2-dev libfontconfig-dev
- name: install npm packages
run: npm ci
- uses: JonasKruckenberg/tauri-build@v1
id: tauri_build
with:
target: ${{ matrix.platform.rust_target }}
- name: Git status and version
run: |
git status
git describe --tags --dirty --always
git diff
# The artifacts output can now be used to upload the artifacts
- uses: actions/upload-artifact@v3
with:
name: ${{ matrix.platform.rust_target }}
path: "${{ join(fromJSON(steps.tauri_build.outputs.artifacts), '\n') }}"
- name: pack webapp
if: matrix.platform.os == 'ubuntu-latest'
working-directory: dist
id: pack-webapp
run: |
GIT_VERSION=`git describe --tags --always`
zip -9 -r "trguing-web-$GIT_VERSION.zip" ./* -x create\* -x \*.map -x \*flag-icons\*
echo "ZIPFILE=trguing-web-$GIT_VERSION.zip" >> $GITHUB_OUTPUT
- uses: actions/upload-artifact@v3
if: matrix.platform.os == 'ubuntu-latest'
with:
name: build web
path: "dist/${{ steps.pack-webapp.outputs.ZIPFILE }}"
publish:
needs: build-binaries
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
# Download the previously uploaded artifacts
- uses: actions/download-artifact@v3
id: download
with:
path: artifacts
- name: Rename mac app archives
run: |
mv artifacts/x86_64-apple-darwin/TrguiNG.app.tar.gz artifacts/x86_64-apple-darwin/TrguiNG_x86_64.app.tar.gz
mv artifacts/aarch64-apple-darwin/TrguiNG.app.tar.gz artifacts/aarch64-apple-darwin/TrguiNG_aarch64.app.tar.gz
- name: Downloaded artifacts
run: ls -lhR artifacts/
# Generate chagnelog
- id: prevtag
run: |
PREVIOUS_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo '')
echo "previous_tag=$PREVIOUS_TAG" >> $GITHUB_OUTPUT
- name: Generate changelog
id: changelog
uses: jaywcjlove/changelog-generator@main
if: steps.prevtag.outputs.previous_tag
with:
token: ${{ secrets.GITHUB_TOKEN }}
show-emoji: false
# And create a release with the artifacts attached
- name: 'create release'
uses: softprops/action-gh-release@v0.1.15
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
with:
draft: true
files: ./artifacts/**/*
body: |
${{ steps.changelog.outputs.compareurl }}
${{ steps.changelog.outputs.changelog }}
update_aur:
name: Publish AUR package
needs: build-binaries
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Determine version
id: determine-version
run: |
GIT_VERSION=`git describe --tags --always`
echo "GIT_VERSION=$GIT_VERSION" >> $GITHUB_OUTPUT
# Download the previously uploaded artifacts
- uses: actions/download-artifact@v3
id: download
with:
name: dbip
- name: Download desktop file
run: wget -nv -O TrguiNG.desktop "https://raw.githubusercontent.com/flathub/org.openscopeproject.TrguiNG/master/org.openscopeproject.TrguiNG.desktop"
- name: Generate PKGBUILD
run: |
python3 ci/generate_pkgbuild.py
cat PKGBUILD
- name: Publish to the AUR
uses: KSXGitHub/github-actions-deploy-aur@v2.7.0
with:
pkgname: trgui-ng
pkgbuild: ./PKGBUILD
commit_username: ${{ secrets.AUR_USERNAME }}
commit_email: ${{ secrets.AUR_EMAIL }}
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
commit_message: Update to ${{ steps.determine-version.outputs.GIT_VERSION }}