Skip to content

Commit bef2ba6

Browse files
committed
feat(windows): add icon and metadata
1 parent c24aa8d commit bef2ba6

File tree

8 files changed

+131
-1
lines changed

8 files changed

+131
-1
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ internal/btree/*.db
1212

1313
# binary builds
1414
go-cqhttp
15+
*.exe
1516

1617
# macos
1718
.DS_Store
19+
20+
# windwos rc
21+
*.syso

.goreleaser.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ env:
33
before:
44
hooks:
55
- go mod tidy
6+
- go install github.com/tc-hib/go-winres@latest
7+
- go generate winres/init.go
8+
- go-winres make
69
release:
710
draft: true
811
discussion_category_name: General

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<p align="center">
22
<a href="https://ishkong.github.io/go-cqhttp-docs/">
3-
<img src="https://user-images.githubusercontent.com/25968335/120111974-8abef880-c139-11eb-99cd-fa928348b198.png" width="200" height="200" alt="go-cqhttp">
3+
<img src="winres/icon.png" width="200" height="200" alt="go-cqhttp">
44
</a>
55
</p>
66

winres/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
winres.json

winres/gen/json.go

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
// Package main generates winres.json
2+
package main
3+
4+
import (
5+
"bytes"
6+
"fmt"
7+
"os"
8+
"os/exec"
9+
"strings"
10+
"time"
11+
12+
"github.com/Mrs4s/go-cqhttp/internal/base"
13+
)
14+
15+
const js = `{
16+
"RT_GROUP_ICON": {
17+
"APP": {
18+
"0000": [
19+
"icon.png",
20+
"icon16.png"
21+
]
22+
}
23+
},
24+
"RT_MANIFEST": {
25+
"#1": {
26+
"0409": {
27+
"identity": {
28+
"name": "go-cqhttp",
29+
"version": "%s"
30+
},
31+
"description": "",
32+
"minimum-os": "vista",
33+
"execution-level": "as invoker",
34+
"ui-access": false,
35+
"auto-elevate": false,
36+
"dpi-awareness": "system",
37+
"disable-theming": false,
38+
"disable-window-filtering": false,
39+
"high-resolution-scrolling-aware": false,
40+
"ultra-high-resolution-scrolling-aware": false,
41+
"long-path-aware": false,
42+
"printer-driver-isolation": false,
43+
"gdi-scaling": false,
44+
"segment-heap": false,
45+
"use-common-controls-v6": false
46+
}
47+
}
48+
},
49+
"RT_VERSION": {
50+
"#1": {
51+
"0000": {
52+
"fixed": {
53+
"file_version": "%s",
54+
"product_version": "%s",
55+
"timestamp": "%s"
56+
},
57+
"info": {
58+
"0409": {
59+
"Comments": "Golang implementation of cqhttp.",
60+
"CompanyName": "Mrs4s",
61+
"FileDescription": "https://github.com/Mrs4s/go-cqhttp",
62+
"FileVersion": "%s",
63+
"InternalName": "",
64+
"LegalCopyright": "©️ 2020 - %d Mrs4s. All Rights Reserved.",
65+
"LegalTrademarks": "",
66+
"OriginalFilename": "GOCQHTTP.EXE",
67+
"PrivateBuild": "",
68+
"ProductName": "go-cqhttp",
69+
"ProductVersion": "%s",
70+
"SpecialBuild": ""
71+
}
72+
}
73+
}
74+
}
75+
}
76+
}`
77+
78+
const timeformat = `2006-01-02T15:04:05+08:00`
79+
80+
func main() {
81+
f, err := os.Create("winres.json")
82+
if err != nil {
83+
panic(err)
84+
}
85+
defer f.Close()
86+
v := ""
87+
if base.Version == "(devel)" {
88+
vartag := bytes.NewBuffer(nil)
89+
vartagcmd := exec.Command("git", "tag", "--sort=committerdate")
90+
vartagcmd.Stdout = vartag
91+
err = vartagcmd.Run()
92+
if err != nil {
93+
panic(err)
94+
}
95+
s := strings.Split(vartag.String(), "\n")
96+
v = s[len(s)-2]
97+
} else {
98+
v = base.Version
99+
}
100+
i := strings.Index(v, "-") // remove -rc / -beta
101+
if i <= 0 {
102+
i = len(v)
103+
}
104+
commitcnt := strings.Builder{}
105+
commitcnt.WriteString(v[1:i])
106+
commitcnt.WriteByte('.')
107+
commitcntcmd := exec.Command("git", "rev-list", "--count", "master")
108+
commitcntcmd.Stdout = &commitcnt
109+
err = commitcntcmd.Run()
110+
if err != nil {
111+
panic(err)
112+
}
113+
fv := commitcnt.String()[:commitcnt.Len()-1]
114+
_, err = fmt.Fprintf(f, js, fv, fv, v, time.Now().Format(timeformat), fv, time.Now().Year(), v)
115+
if err != nil {
116+
panic(err)
117+
}
118+
}

winres/icon.png

81.7 KB
Loading

winres/icon16.png

2.5 KB
Loading

winres/init.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Package winres 生成windows资源
2+
package winres
3+
4+
//go:generate go run github.com/Mrs4s/go-cqhttp/winres/gen

0 commit comments

Comments
 (0)