Skip to content

Commit 1b06ac1

Browse files
committed
feat: 优化构建及字体加载
1 parent e6ed23b commit 1b06ac1

7 files changed

Lines changed: 85 additions & 127 deletions

File tree

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Build for Linux & Windows
2+
3+
on:
4+
push:
5+
tags:
6+
- v*
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v2
14+
with:
15+
fetch-depth: 0
16+
17+
- name: Set env
18+
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
19+
20+
- name: Install Docker
21+
run: curl -fsSL https://get.docker.com | bash -s docker
22+
23+
- name: Setup Go
24+
uses: actions/setup-go@v2
25+
with:
26+
go-version: 1.18.2
27+
28+
- name: Go tidy
29+
run: go mod tidy
30+
31+
- name: Install fyne-cross
32+
run: go get github.com/fyne-io/fyne-cross && go install github.com/fyne-io/fyne-cross
33+
34+
- name: Package for Windows
35+
run: fyne-cross windows -arch=*
36+
37+
- name: Package for Linux
38+
run: fyne-cross linux -arch=*
39+
40+
- name: Create pkg dist dir
41+
run: mkdir pkg-dist
42+
43+
- name: Move Windows-amd64
44+
run: mv fyne-cross/dist/windows-amd64/Fetch-Github-Hosts.exe.zip pkg-dist/fetch-github-hosts_${{ env.RELEASE_VERSION }}_windows_amd64.zip
45+
46+
- name: Move Windows-386
47+
run: mv fyne-cross/dist/windows-386/Fetch-Github-Hosts.exe.zip pkg-dist/fetch-github-hosts_${{ env.RELEASE_VERSION }}_windows_386.zip
48+
49+
- name: Move Linux-386
50+
run: mv fyne-cross/dist/linux-386/Fetch-Github-Hosts.tar.xz pkg-dist/fetch-github-hosts_${{ env.RELEASE_VERSION }}_linux_386.tar.xz
51+
52+
- name: Move Linux-amd64
53+
run: mv fyne-cross/dist/linux-amd64/Fetch-Github-Hosts.tar.xz pkg-dist/fetch-github-hosts_${{ env.RELEASE_VERSION }}_linux_amd64.tar.xz
54+
55+
- name: Move Linux-arm
56+
run: mv fyne-cross/dist/linux-arm/Fetch-Github-Hosts.tar.xz pkg-dist/fetch-github-hosts_${{ env.RELEASE_VERSION }}_linux_arm.tar.xz
57+
58+
- name: Move Linux-arm64
59+
run: mv fyne-cross/dist/linux-arm64/Fetch-Github-Hosts.tar.xz pkg-dist/fetch-github-hosts_${{ env.RELEASE_VERSION }}_linux_arm64.tar.xz
60+
61+
- uses: actions/upload-artifact@v3
62+
with:
63+
name: build-result
64+
path: |
65+
pkg-dist
66+
67+
- name: Release
68+
uses: softprops/action-gh-release@v1
69+
if: startsWith(github.ref, 'refs/tags/')
70+
with:
71+
draft: true
72+
append_body: true
73+
files: |
74+
pkg-dist/fetch-github-hosts_${{ env.RELEASE_VERSION }}_windows_amd64.zip
75+
pkg-dist/fetch-github-hosts_${{ env.RELEASE_VERSION }}_windows_386.zip
76+
pkg-dist/fetch-github-hosts_${{ env.RELEASE_VERSION }}_linux_386.tar.xz
77+
pkg-dist/fetch-github-hosts_${{ env.RELEASE_VERSION }}_linux_amd64.tar.xz
78+
pkg-dist/fetch-github-hosts_${{ env.RELEASE_VERSION }}_linux_arm.tar.xz
79+
pkg-dist/fetch-github-hosts_${{ env.RELEASE_VERSION }}_linux_arm64.tar.xz
80+
env:
81+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/build-linux.yml

Lines changed: 0 additions & 50 deletions
This file was deleted.

.github/workflows/build-windows.yml

Lines changed: 0 additions & 50 deletions
This file was deleted.

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
`fetch-github-hosts` 是主要为解决研究及学习人员访问 `Github` 过慢或其他问题而提供的 `Github Hosts` 同步工具
77

88
[![Release](https://img.shields.io/github/v/release/Licoy/fetch-github-hosts.svg?logo=git)](https://github.com/Licoy/fetch-github-hosts)
9-
[![LinuxBuild](https://github.com/Licoy/fetch-github-hosts/workflows/Build%20for%20Linux/badge.svg)](https://github.com/Licoy/fetch-github-hosts)
10-
[![LinuxBuild](https://github.com/Licoy/fetch-github-hosts/workflows/Build%20for%20MacOS/badge.svg)](https://github.com/Licoy/fetch-github-hosts)
11-
[![LinuxBuild](https://github.com/Licoy/fetch-github-hosts/workflows/Build%20for%20Windows/badge.svg)](https://github.com/Licoy/fetch-github-hosts)
9+
[![Build Linux & Windows](https://github.com/Licoy/fetch-github-hosts/workflows/Build%20for%20Linux%20&%20Windows/badge.svg)](https://github.com/Licoy/fetch-github-hosts)
10+
[![Build MacOS](https://github.com/Licoy/fetch-github-hosts/workflows/Build%20for%20MacOS/badge.svg)](https://github.com/Licoy/fetch-github-hosts)
1211

1312
</div>
1413

gui.go

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ func bootGui() {
4040
return
4141
}
4242
_fileLog = &fetchLog{w: logFile}
43-
if err := initGuiFont(); err != nil {
44-
_fileLog.Print("字体加载失败")
45-
}
4643
fetchConf = LoadFetchConf()
4744
logoResource := getLogoResource()
4845
a := app.New()
@@ -370,24 +367,6 @@ func componentsStatusChange(enable bool, components ...fyne.Disableable) {
370367
}
371368
}
372369

373-
func initGuiFont() (err error) {
374-
fontPath := AppExecDir() + "/" + GuiFontName
375-
_, err = os.Stat(fontPath)
376-
if err != nil {
377-
var file []byte
378-
file, err = fyneFontEmbedFs.ReadFile(GuiFontName)
379-
if err != nil {
380-
err = ComposeError("加载字体失败", err)
381-
return
382-
}
383-
if err = ioutil.WriteFile(fontPath, file, os.ModePerm); err != nil {
384-
err = ComposeError("加载所需字体文件失败", err)
385-
return
386-
}
387-
}
388-
return
389-
}
390-
391370
func openUrl(urlStr string) func() {
392371
return func() {
393372
u, _ := url.Parse(urlStr)

index.template

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@
1313
<p><img src="https://github.com/Licoy/fetch-github-hosts/raw/main/logo.png" alt="LOGO" /></p>
1414
<p><code>fetch-github-hosts</code> 是主要为解决研究及学习人员访问 <code>Github</code> 过慢或其他问题而提供的 <code>Github Hosts</code> 同步工具</p>
1515
<p><a href="https://github.com/Licoy/fetch-github-hosts"><img src="https://img.shields.io/github/v/release/Licoy/fetch-github-hosts.svg?logo=git" alt="Release" /></a>
16-
<a href="https://github.com/Licoy/fetch-github-hosts"><img src="https://github.com/Licoy/fetch-github-hosts/workflows/Build%20for%20Linux/badge.svg" alt="LinuxBuild" /></a>
17-
<a href="https://github.com/Licoy/fetch-github-hosts"><img src="https://github.com/Licoy/fetch-github-hosts/workflows/Build%20for%20MacOS/badge.svg" alt="LinuxBuild" /></a>
18-
<a href="https://github.com/Licoy/fetch-github-hosts"><img src="https://github.com/Licoy/fetch-github-hosts/workflows/Build%20for%20Windows/badge.svg" alt="LinuxBuild" /></a></p>
16+
<a href="https://github.com/Licoy/fetch-github-hosts"><img src="https://github.com/Licoy/fetch-github-hosts/workflows/Build%20for%20Linux%20&%20Windows/badge.svg" alt="Build Linux & Windows" /></a>
17+
<a href="https://github.com/Licoy/fetch-github-hosts"><img src="https://github.com/Licoy/fetch-github-hosts/workflows/Build%20for%20MacOS/badge.svg" alt="Build MacOS" /></a>
1918
</div>
2019
<h2>原理</h2>
2120
<p>此项目是通过部署此项目本身的服务器来获取 <code>github.com</code> 的 <code>hosts</code>,而不是通过第三方ip地址接口来进行获取,例如 <code>ipaddress.com</code> 等。</p>

0 commit comments

Comments
 (0)