mirror of
https://github.com/wavetermdev/wails.git
synced 2026-08-05 13:53:43 -07:00
feat(website): improve website content (#1309)
Update Chinese translation
This commit is contained in:
@@ -6,6 +6,6 @@ leaanthony:
|
||||
|
||||
misitebao:
|
||||
name: Misitebao
|
||||
title: Front-End Architect
|
||||
title: Architect
|
||||
url: https://github.com/misitebao
|
||||
image_url: https://cdn.jsdelivr.net/gh/misitebao/CDN@main/gravatar.gif
|
||||
image_url: https://github.com/misitebao.png
|
||||
|
||||
@@ -89,7 +89,7 @@ const config = {
|
||||
},
|
||||
{
|
||||
to: "https://github.com/sponsors/leaanthony",
|
||||
label: "Sponsor ❤",
|
||||
label: "Sponsor",
|
||||
position: "left",
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"version.label": {
|
||||
"message": "Next Version",
|
||||
"message": "Next Version 🚧",
|
||||
"description": "The label for version current"
|
||||
},
|
||||
"sidebar.tutorialSidebar.category.Getting Started": {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"item.label.Sponsor ❤": {
|
||||
"item.label.Sponsor": {
|
||||
"message": "Sponsor ❤",
|
||||
"description": "Navbar item with label Sponsor ❤"
|
||||
"description": "Navbar item with label Sponsor"
|
||||
},
|
||||
"item.label.Docs": {
|
||||
"message": "Docs",
|
||||
|
||||
+1
-5
@@ -1,11 +1,7 @@
|
||||
---
|
||||
slug: wails-v2-beta-for-windows
|
||||
title: Windows 平台的 Wails v2 测试版
|
||||
authors:
|
||||
- name: Lea Anthony
|
||||
title: Wails 项目作者
|
||||
url: https://github.com/leaanthony
|
||||
image_url: https://github.com/leaanthony.png
|
||||
authors: [leaanthony]
|
||||
tags: [wails, v2]
|
||||
---
|
||||
|
||||
|
||||
+1
-5
@@ -1,11 +1,7 @@
|
||||
---
|
||||
slug: wails-v2-beta-for-mac
|
||||
title: Mac 平台的 Wails v2 测试版
|
||||
authors:
|
||||
- name: Lea Anthony
|
||||
title: Wails 项目作者
|
||||
url: https://github.com/leaanthony
|
||||
image_url: https://github.com/leaanthony.png
|
||||
authors: [leaanthony]
|
||||
tags: [wails, v2]
|
||||
---
|
||||
|
||||
|
||||
+1
-5
@@ -1,11 +1,7 @@
|
||||
---
|
||||
slug: wails-v2-beta-for-linux
|
||||
title: Linux 平台的 Wails v2 测试版
|
||||
authors:
|
||||
- name: Lea Anthony
|
||||
title: Wails 项目作者
|
||||
url: https://github.com/leaanthony
|
||||
image_url: https://github.com/leaanthony.png
|
||||
authors: [leaanthony]
|
||||
tags: [wails, v2]
|
||||
---
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
leaanthony:
|
||||
name: Lea Anthony
|
||||
title: Wails 项目维护者
|
||||
url: https://github.com/leaanthony
|
||||
image_url: https://github.com/leaanthony.png
|
||||
|
||||
misitebao:
|
||||
name: Misitebao
|
||||
title: 架构师
|
||||
url: https://github.com/misitebao
|
||||
image_url: https://github.com/misitebao.png
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"version.label": {
|
||||
"message": "下个版本",
|
||||
"message": "下个版本 🚧",
|
||||
"description": "The label for version current"
|
||||
},
|
||||
"sidebar.tutorialSidebar.category.Getting Started": {
|
||||
|
||||
@@ -4,7 +4,7 @@ sidebar_position: 1
|
||||
|
||||
# 模板
|
||||
|
||||
此页面用作社区支持的模板列表。请提交一个包含您的模板的 PR(点击页面底部的`编辑此页`)。要构建您自己的模板,请参考[模板](/docs/guides/templates)指南。
|
||||
此页面用作社区支持的模板列表。请提交一个包含您的模板的 PR(点击页面底部的`编辑此页`)。要构建您自己的模板,请参考[模板](../guides/templates)指南。
|
||||
|
||||
要使用这些模板,请运行 `wails init -n "您的项目名" -t [下面的链接[@版本]]`
|
||||
|
||||
|
||||
+1
-1
@@ -21,4 +21,4 @@ sidebar_position: 6
|
||||
</div>
|
||||
<br />
|
||||
|
||||
有关编译选项的更多详细信息,请参阅[构建命令](/docs/reference/cli#构建)。
|
||||
有关编译选项的更多详细信息,请参阅[构建命令](../reference/cli#构建)。
|
||||
|
||||
+1
-1
@@ -11,6 +11,6 @@ sidebar_position: 5
|
||||
- 监听 Go 文件中的修改并在更改时重新构建/重新运行
|
||||
- 设置将通过浏览器为您的应用程序提供服务的[网络服务器](http://localhost:34115)。这允许您使用您喜欢的浏览器扩展。您甚至可以从控制台调用 Go 代码。
|
||||
|
||||
首先,在项目目录中运行`wails dev`。可以在[此处](/docs/reference/cli#开发)找到有关这方面的更多信息。
|
||||
首先,在项目目录中运行`wails dev`。可以在[此处](../reference/cli#开发)找到有关这方面的更多信息。
|
||||
|
||||
即将提供:教程
|
||||
|
||||
+2
-2
@@ -11,9 +11,9 @@ sidebar_position: 2
|
||||
|
||||
为了快速启动和运行,您可以通过运行`wails init -n myproject`生成一个默认项目。这将创建一个名为`myproject`的目录,并使用默认模板填充它。
|
||||
|
||||
其他可用的项目模板可以使用 `wails init -l`列出。这里也有提供不同功能和框架的[社区模板](/docs/community/templates)。
|
||||
其他可用的项目模板可以使用 `wails init -l`列出。这里也有提供不同功能和框架的[社区模板](../community/templates)。
|
||||
|
||||
要查看其他可用选项,您可以运行 `wails init -help`。 更多详细信息可以在 [初始化命令](/docs/reference/cli#初始化)中找到。
|
||||
要查看其他可用选项,您可以运行 `wails init -help`。 更多详细信息可以在 [初始化命令](../reference/cli#初始化)中找到。
|
||||
|
||||
## 项目布局
|
||||
|
||||
|
||||
+1
-1
@@ -67,7 +67,7 @@ import TabItem from "@theme/TabItem";
|
||||
<code>libwebkit</code>。与其为不同的发行版列出大量命令,Wails
|
||||
可以尝试确定针对您的特定发行版的安装命令。安装后运行
|
||||
<code>wails doctor</code>
|
||||
以显示如何安装依赖项。
|
||||
以显示如何安装依赖项。如果您的发行版/包管理器不受支持,请参阅<a href="../guides/linux-distro-support">添加Linux发行版</a>指南。
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
|
||||
+4
-4
@@ -26,7 +26,7 @@ func (a *App) shutdown(ctx context.Context) {
|
||||
```
|
||||
|
||||
- `startup`方法会在 Wails 分配它需要的资源后立即调用,这是创建资源、设置事件侦听器以及应用程序在启动时需要的任何其他内容的好地方。它提供了一个`context.Context`,
|
||||
通常保存在结构字段中。调用[运行时](/docs/reference/runtime/intro)需要此`context.Context`。如果此方法返回错误,则应用程序将终止。在开发模式下,错误会输出到控制台。
|
||||
通常保存在结构字段中。调用[运行时](../reference/runtime/intro)需要此`context.Context`。如果此方法返回错误,则应用程序将终止。在开发模式下,错误会输出到控制台。
|
||||
- `shutdown`方法会在应用程序关闭进程时调用,这是释放内存和执行任何关闭任务的好地方。
|
||||
|
||||
`main.go`文件通常由对`wails.Run()`的单个调用组成,它接受应用程序配置。模板使用的模式是,在调用`wails.Run()`之前,
|
||||
@@ -51,7 +51,7 @@ func main() {
|
||||
|
||||
```
|
||||
|
||||
可以在[此处](/docs/howdoesitwork#应用程序生命周期回调)找到有关应用程序生命周期回调的更多信息。
|
||||
可以在[此处](../howdoesitwork#应用程序生命周期回调)找到有关应用程序生命周期回调的更多信息。
|
||||
|
||||
## 绑定方法
|
||||
|
||||
@@ -104,11 +104,11 @@ func main() {
|
||||
|
||||
这将绑定`App`结构中的所有公共方法(它永远不会绑定 startup 和 shutdown 方法)。
|
||||
|
||||
可以在[此处](/docs/howdoesitwork#方法绑定)找到有关绑定的更多信息。
|
||||
可以在[此处](../howdoesitwork#方法绑定)找到有关绑定的更多信息。
|
||||
|
||||
## 应用程序菜单
|
||||
|
||||
Wails 支持向您的应用程序添加菜单。 这是通过将 [菜单](/docs/reference/menus#菜单) 结构体传递给应用程序配置来完成的。
|
||||
Wails 支持向您的应用程序添加菜单。 这是通过将 [菜单](../reference/menus#菜单) 结构体传递给应用程序配置来完成的。
|
||||
常见做法是使用一个返回菜单的方法,更常见的是用作生命周期回调的 `App` 结构体上的方法。
|
||||
|
||||
```go {11} title="main.go"
|
||||
|
||||
@@ -25,3 +25,12 @@ Wails CLI 现在将是最新版本。要更新项目以使用最新版本,请
|
||||
要恢复到稳定版本,请运行:
|
||||
|
||||
`go install github.com/wailsapp/wails/v2/cmd/wails@latest`
|
||||
|
||||
## 测试一个分支
|
||||
|
||||
如果要测试一个分支,请按照上面的说明进行操作,但请确保在安装之前切换要测试的分支:
|
||||
|
||||
- `git clone https://github.com/wailsapp/wails`
|
||||
- `git checkout -b branch-to-test --track origin/branch-to-test`
|
||||
- `cd wails/v2/cmd/wails`
|
||||
- `go install`
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# 无边框应用
|
||||
|
||||
Wails 支持无边框应用程序。这可以通过使用[应用程序参数选项](/docs/reference/options#应用程序参数选项)中的[无边框](/docs/reference/options#无边框)字段来实现。
|
||||
Wails 支持无边框应用程序。这可以通过使用[应用程序参数选项](../reference/options#应用程序参数选项)中的[无边框](../reference/options#无边框)字段来实现。
|
||||
|
||||
Wails 为拖动窗口提供了一个简单的解决方案:任何具有“data-wails-drag”属性的 HTML 元素都将充当“拖动手柄”。
|
||||
此属性适用于所有嵌套元素。如果您需要指定不应该拖动的嵌套元素,请在该元素上使用属性“data-wails-no-drag”。
|
||||
|
||||
@@ -23,7 +23,7 @@ Wails v2 与 v1 相比有重大变化。本文档旨在重点介绍迁移现有
|
||||
app.Run()
|
||||
```
|
||||
|
||||
在 v2 中,只有一个方法`wails.Run()`接受[应用程序参数选项](/docs/reference/options#应用程序参数选项)。
|
||||
在 v2 中,只有一个方法`wails.Run()`接受[应用程序参数选项](../reference/options#应用程序参数选项)。
|
||||
|
||||
```go title="v2"
|
||||
err := wails.Run(&options.App{
|
||||
@@ -39,7 +39,7 @@ Wails v2 与 v1 相比有重大变化。本文档旨在重点介绍迁移现有
|
||||
|
||||
### 绑定
|
||||
|
||||
在 v1 中,可以绑定任意函数和结构。在 v2 中,这已被简化为仅绑定结构。以前传递给 v1`Bind()`中的方法的结构实例现在在[应用程序参数选项](/docs/reference/options#应用程序参数选项)`Bind`字段中指定:
|
||||
在 v1 中,可以绑定任意函数和结构。在 v2 中,这已被简化为仅绑定结构。以前传递给 v1`Bind()`中的方法的结构实例现在在[应用程序参数选项](../reference/options#应用程序参数选项)`Bind`字段中指定:
|
||||
|
||||
```go title="v1"
|
||||
app := wails.CreateApp(/* options */)
|
||||
@@ -59,13 +59,13 @@ Wails v2 与 v1 相比有重大变化。本文档旨在重点介绍迁移现有
|
||||
|
||||
### 应用程序生命周期
|
||||
|
||||
在 v1 中,绑定结构中有 2 个特殊方法:`WailsInit()`和`WailsShutdown()`. 这些已被替换为 3 个生命周期回调,作为[应用程序参数选项](/docs/reference/options#应用程序参数选项)的一部分:
|
||||
在 v1 中,绑定结构中有 2 个特殊方法:`WailsInit()`和`WailsShutdown()`. 这些已被替换为 3 个生命周期回调,作为[应用程序参数选项](../reference/options#应用程序参数选项)的一部分:
|
||||
|
||||
- [应用启动回调](/docs/reference/options#应用启动回调)
|
||||
- [应用退出回调](/docs/reference/options#应用退出回调)
|
||||
- [前端 Dom 加载完成回调](/docs/reference/options#前端-dom-加载完成回调)
|
||||
- [应用启动回调](../reference/options#应用启动回调)
|
||||
- [应用退出回调](../reference/options#应用退出回调)
|
||||
- [前端 Dom 加载完成回调](../reference/options#前端-dom-加载完成回调)
|
||||
|
||||
注意:[前端 Dom 加载完成回调](/docs/reference/options#前端-dom-加载完成回调)替换了 v1 中的 `wails:ready` 系统事件。
|
||||
注意:[前端 Dom 加载完成回调](../reference/options#前端-dom-加载完成回调)替换了 v1 中的 `wails:ready` 系统事件。
|
||||
|
||||
这些方法可以是标准函数,但通常的做法是将它们作为结构的一部分:
|
||||
|
||||
@@ -89,9 +89,9 @@ func (b *Basic) startup(ctx context.Context) {
|
||||
|
||||
### 运行时
|
||||
|
||||
v2 中的运行时比 v1 丰富得多,支持菜单、窗口操作和更好的对话框。方法的签名略有变化 - 请参阅[运行时](/docs/reference/runtime/intro)。
|
||||
v2 中的运行时比 v1 丰富得多,支持菜单、窗口操作和更好的对话框。方法的签名略有变化 - 请参阅[运行时](../reference/runtime/intro)。
|
||||
|
||||
在 v1 中,[运行时](/docs/reference/runtime/intro)可通过传递给`WailsInit()`. 在 v2 中,运行时已移出到它自己的包。运行时中的每个方法都采用`context.Context`传递给了[应用启动回调](/docs/reference/options#应用启动回调)方法。
|
||||
在 v1 中,[运行时](../reference/runtime/intro)可通过传递给`WailsInit()`. 在 v2 中,运行时已移出到它自己的包。运行时中的每个方法都采用`context.Context`传递给了[应用启动回调](../reference/options#应用启动回调)方法。
|
||||
|
||||
```go title="运行时示例"
|
||||
package main
|
||||
@@ -156,7 +156,7 @@ func main() {
|
||||
}
|
||||
```
|
||||
|
||||
当然,如果您愿意,也可以使用打包工具。唯一的要求是在 Wails 中使用`embed.FS`,将最终的程序资源目录传递给[应用程序参数选项](/docs/reference/options#应用程序参数选项)的`Assets`键。
|
||||
当然,如果您愿意,也可以使用打包工具。唯一的要求是在 Wails 中使用`embed.FS`,将最终的程序资源目录传递给[应用程序参数选项](../reference/options#应用程序参数选项)的`Assets`键。
|
||||
|
||||
### 项目配置
|
||||
|
||||
|
||||
@@ -0,0 +1,386 @@
|
||||
# 代码签名
|
||||
|
||||
This is a guide on how you can sign your binaries generated with Wails on MacOS and Windows.
|
||||
The guide will target CI environments, more specifically GitHub Actions.
|
||||
|
||||
## Windows
|
||||
First off you need a code signing certificate. If you do not already have one, Microsoft's
|
||||
info page lists some providers [here](https://docs.microsoft.com/en-us/windows-hardware/drivers/dashboard/get-a-code-signing-certificate).
|
||||
Please note that an EV certificate is not required unless you need to write kernel-level
|
||||
software such as device drivers. For signing your Wails app, a standard code signing
|
||||
certificate will do just fine.
|
||||
|
||||
It may be a good idea to check with your certificate provider
|
||||
how to sign your binaries on your local machine before targeting automated build systems, just so you know if there
|
||||
are any special requirements. For instance, [here](https://www.ssl.com/how-to/using-your-code-signing-certificate/) is SSL.com's code signing guide for Windows.
|
||||
If you know how to sign locally, it will be easier to
|
||||
troubleshoot any potential issues in a CI environment.
|
||||
For instance, SSL.com code signing certificates require the `/tr` flag for [SignTool.exe](https://docs.microsoft.com/en-us/windows/win32/seccrypto/signtool)
|
||||
while other providers may only need the `/t` flag for providing the timestamping server. Popular GitHub Actions for signing
|
||||
Windows binaries like [this one](https://github.com/Dana-Prajea/code-sign-action) does not support the `/tr` flag on SignTool.exe.
|
||||
Therefore this guide will focus on signing our app manually with PowerShell commands, but you can use actions like the [code-sign-action](https://github.com/Dana-Prajea/code-sign-action)
|
||||
Action if you prefer.
|
||||
|
||||
First off, let's make sure we are able to build our Wails app in our GitHub CI. Here is a small workflow template:
|
||||
```yaml
|
||||
name: "example"
|
||||
on:
|
||||
workflow_dispatch:
|
||||
# This Action only starts when you go to Actions and manually run the workflow.
|
||||
|
||||
jobs:
|
||||
package:
|
||||
strategy:
|
||||
matrix:
|
||||
platform: [ windows-latest, macos-latest ]
|
||||
go-version: [1.18]
|
||||
runs-on: ${{ matrix.platform }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: ${{ matrix.go-version }}
|
||||
- name: setup node
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: 14
|
||||
# You may need to manually build you frontend manually here, unless you have configured frontend build and install commands in wails.json.
|
||||
- name: Get Wails
|
||||
run: go install github.com/wailsapp/wails/v2/cmd/wails@latest
|
||||
- name: Build Wails app
|
||||
run: |
|
||||
wails build
|
||||
- name: upload artifacts macOS
|
||||
if: matrix.platform == 'macos-latest'
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: wails-binaries-macos
|
||||
path: build/bin/*
|
||||
- name: upload artifacts windows
|
||||
if: matrix.platform == 'windows-latest'
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: wails-binaries-windows
|
||||
path: build/bin/*
|
||||
```
|
||||
|
||||
Next we need to give the GitHub workflow access to our signing certificate. This is done by encoding your .pfx or .p12 certificate
|
||||
into a base64 string. To do this in PowerShell, you can use the following command assuming your certificate is called 'my-cert.p12':
|
||||
```PowerShell
|
||||
certutil -encode .\my-cert.p12 my-cert-base64.txt
|
||||
```
|
||||
|
||||
You should now have your .txt file with the base64 encoded certificate. It should start with *-----BEGIN CERTIFICATE-----* and
|
||||
end with *-----END CERTIFICATE-----*. Now you need to make two action secrets on GitHub. Navigate to *Settings -> Secrets -> Actions* and create the
|
||||
two following secrets:
|
||||
* **WIN_SIGNING_CERT** with the contents of your base64 encoded certificate text.
|
||||
* **WIN_SIGNING_CERT_PASSWORD** with the contents of your certificate password.
|
||||
|
||||
Now we're ready to implement the signing in our workflow using one of the two methods:
|
||||
|
||||
### Method 1: signing with commands
|
||||
This method uses PowerShell commands to sign our app, and leaves you control over the entire signing process.
|
||||
|
||||
After the `"Build Wails app"` step, we can add the following step to our workflow:
|
||||
```yaml
|
||||
- name: Sign Windows binaries
|
||||
if: matrix.platform == 'windows-latest'
|
||||
run: |
|
||||
echo "Creating certificate file"
|
||||
New-Item -ItemType directory -Path certificate
|
||||
Set-Content -Path certificate\certificate.txt -Value '${{ secrets.WIN_SIGNING_CERT }}'
|
||||
certutil -decode certificate\certificate.txt certificate\certificate.pfx
|
||||
echo "Signing our binaries"
|
||||
& 'C:/Program Files (x86)/Windows Kits/10/bin/10.0.17763.0/x86/signtool.exe' sign /fd <signing algorithm> /t <timestamping server> /f certificate\certificate.pfx /p '${{ secrets.WIN_SIGNING_CERT_PASSWORD }}' <path to binary>
|
||||
|
||||
```
|
||||
This script creates a new directory for your certificate file, creates the certificate file from our base64 secret, converts it to a .pfx file,
|
||||
and finally signs the binary. The following variables needs to be replaced in the last line:
|
||||
* **signing algorithm**: usually sha256.
|
||||
* **timestamping server**: URL to the timestamping server to use with your certificate.
|
||||
* **path to binary**: path to the binary you want to sign.
|
||||
|
||||
Given that our Wails config has `outputfilename` set to "app.exe" and that we have a certificate from SSL.com, this would be our workflow:
|
||||
```yaml
|
||||
name: "example"
|
||||
on:
|
||||
workflow_dispatch:
|
||||
# This Action only starts when you go to Actions and manually run the workflow.
|
||||
|
||||
jobs:
|
||||
package:
|
||||
strategy:
|
||||
matrix:
|
||||
platform: [ windows-latest, macos-latest ]
|
||||
go-version: [1.18]
|
||||
runs-on: ${{ matrix.platform }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: ${{ matrix.go-version }}
|
||||
- name: setup node
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: 14
|
||||
# You may need to manually build you frontend here, unless you have configured frontend build and install commands in wails.json.
|
||||
- name: Get Wails
|
||||
run: go install github.com/wailsapp/wails/v2/cmd/wails@latest
|
||||
- name: Build Wails app
|
||||
run: |
|
||||
wails build
|
||||
- name: Sign Windows binaries
|
||||
if: matrix.platform == 'windows-latest'
|
||||
run: |
|
||||
echo "Creating certificate file"
|
||||
New-Item -ItemType directory -Path certificate
|
||||
Set-Content -Path certificate\certificate.txt -Value '${{ secrets.WIN_SIGNING_CERT }}'
|
||||
certutil -decode certificate\certificate.txt certificate\certificate.pfx
|
||||
echo "Signing our binaries"
|
||||
& 'C:/Program Files (x86)/Windows Kits/10/bin/10.0.17763.0/x86/signtool.exe' sign /fd sha256 /tr http://ts.ssl.com /f certificate\certificate.pfx /p '${{ secrets.WIN_SIGNING_CERT_PASSWORD }}' .\build\bin\app.exe
|
||||
|
||||
- name: upload artifacts macOS
|
||||
if: matrix.platform == 'macos-latest'
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: wails-binaries-macos
|
||||
path: build/bin/*
|
||||
- name: upload artifacts windows
|
||||
if: matrix.platform == 'windows-latest'
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: wails-binaries-windows
|
||||
path: build/bin/*
|
||||
```
|
||||
|
||||
### Method 2: automatically signing with Action
|
||||
It is possible to use a Windows code signing Action like [this](https://github.com/marketplace/actions/code-sign-a-file-with-pfx-certificate) one,
|
||||
but note it requires a SHA1 hash for the certificate and a certificate name. View an example of how to configure it on the Action's [marketplace](https://github.com/marketplace/actions/code-sign-a-file-with-pfx-certificate).
|
||||
|
||||
---
|
||||
|
||||
## MacOS
|
||||
|
||||
First off you need your code signing certificate from Apple. If you do not have one, a simple Google search will help you acquire one.
|
||||
Once you have your certificate, you need to export it and encode it to base64. [This tutorial](https://localazy.com/blog/how-to-automatically-sign-macos-apps-using-github-actions)
|
||||
shows you how to do that in an easy manner. Once you have exported your .p12 certificate file, you can encode it to base64 as seen in the tutorial with the following command:
|
||||
```bash
|
||||
base64 Certificates.p12 | pbcopy
|
||||
```
|
||||
|
||||
Now you're ready to create some GitHub project secrets, just as with Windows:
|
||||
* **APPLE_DEVELOPER_CERTIFICATE_P12_BASE64** with the contents of your newly copied base64 certificate.
|
||||
* **APPLE_DEVELOPER_CERTIFICATE_PASSWORD** with the contents of your certificate password.
|
||||
* **APPLE_PASSWORD** with the contents of an App-Specific password to your Apple-ID account which you can generate [here](https://appleid.apple.com/account/manage).
|
||||
|
||||
Let's make sure we are able to build our Wails app in our GitHub Action workflow. Here is a small template:
|
||||
|
||||
```yaml
|
||||
name: "example"
|
||||
on:
|
||||
workflow_dispatch:
|
||||
# This Action only starts when you go to Actions and manually run the workflow.
|
||||
|
||||
jobs:
|
||||
package:
|
||||
strategy:
|
||||
matrix:
|
||||
platform: [ windows-latest, macos-latest ]
|
||||
go-version: [1.18]
|
||||
runs-on: ${{ matrix.platform }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: ${{ matrix.go-version }}
|
||||
- name: setup node
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: 14
|
||||
# You may need to manually build you frontend here, unless you have configured frontend build and install commands in wails.json.
|
||||
- name: Get Wails
|
||||
run: go install github.com/wailsapp/wails/v2/cmd/wails@latest
|
||||
- name: Build Wails app
|
||||
run: |
|
||||
wails build
|
||||
- name: upload artifacts macOS
|
||||
if: matrix.platform == 'macos-latest'
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: wails-binaries-macos
|
||||
path: build/bin/*
|
||||
- name: upload artifacts windows
|
||||
if: matrix.platform == 'windows-latest'
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: wails-binaries-windows
|
||||
path: build/bin/*
|
||||
```
|
||||
|
||||
For code signing on macOS, [gon](https://github.com/mitchellh/gon) is a very handy tool for code signing and communicating with Apple servers, also written in Go, and
|
||||
will be used in this guide.
|
||||
|
||||
After the `Build Wails app` step, add the following to the workflow:
|
||||
```yaml
|
||||
- name: MacOS download gon for code signing and app notarization
|
||||
if: matrix.platform == 'macos-latest'
|
||||
run: |
|
||||
brew install mitchellh/gon/gon
|
||||
```
|
||||
|
||||
Now we need to configure some gon config files in our `build/darwin` directory:
|
||||
|
||||
1. gon-sign.json:
|
||||
```json
|
||||
{
|
||||
"source" : ["./build/bin/app.app"],
|
||||
"bundle_id" : "app.myapp",
|
||||
"apple_id": {
|
||||
"username": "my-appleid@email.com",
|
||||
"password": "@env:APPLE_PASSWORD"
|
||||
},
|
||||
"sign" :{
|
||||
"application_identity" : "Developer ID Application: My Name"
|
||||
}
|
||||
}
|
||||
```
|
||||
Where `source` is your Wails binary, `bundle_id` is your bundle ID, `apple_id` contains your Apple ID username and App-Specific password
|
||||
which you created earlier, and `sign.application_identity` is your identity which you can find by running the following command:
|
||||
```bash
|
||||
security find-identity -v -p codesigning
|
||||
```
|
||||
2. entitlements.plist:
|
||||
```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>com.apple.security.app-sandbox</key>
|
||||
<true/>
|
||||
<key>com.apple.security.network.client</key>
|
||||
<true/>
|
||||
<key>com.apple.security.network.server</key>
|
||||
<true/>
|
||||
<key>com.apple.security.files.user-selected.read-write</key>
|
||||
<true/>
|
||||
<key>com.apple.security.files.downloads.read-write</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
```
|
||||
In this file you configure the entitlements you need for you app, e.g. camera permissions if your app uses the camera. Read more about entitlements [here](https://developer.apple.com/documentation/bundleresources/entitlements).
|
||||
|
||||
Make sure you have updated your `Info.plist` file with the same bundle ID as you entered in `gon-sign.json`.
|
||||
Here's an example `Info.plist` file:
|
||||
```plist
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0"><dict>
|
||||
<key>CFBundlePackageType</key><string>APPL</string>
|
||||
<key>CFBundleName</key><string>MyApp</string>
|
||||
<key>CFBundleExecutable</key><string>app</string>
|
||||
<key>CFBundleIdentifier</key><string>app.myapp</string>
|
||||
<key>CFBundleVersion</key><string>0.1.0</string>
|
||||
<key>CFBundleGetInfoString</key><string>My app is cool and nice and chill and</string>
|
||||
<key>CFBundleShortVersionString</key><string>0.1.0</string>
|
||||
<key>CFBundleIconFile</key><string>iconfile</string>
|
||||
<key>LSMinimumSystemVersion</key><string>10.13.0</string>
|
||||
<key>NSHighResolutionCapable</key><string>true</string>
|
||||
<key>LSApplicationCategoryType</key><string>public.app-category.utilities</string>
|
||||
<key>NSHumanReadableCopyright</key><string>© Me</string>
|
||||
</dict></plist>
|
||||
```
|
||||
|
||||
Now we're ready to add the signing step in our workflow after building the Wails app:
|
||||
```yaml
|
||||
- name: Import Code-Signing Certificates for macOS
|
||||
if: matrix.platform == 'macos-latest'
|
||||
uses: Apple-Actions/import-codesign-certs@v1
|
||||
with:
|
||||
# The certificates in a PKCS12 file encoded as a base64 string
|
||||
p12-file-base64: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_P12_BASE64 }}
|
||||
# The password used to import the PKCS12 file.
|
||||
p12-password: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_PASSWORD }}
|
||||
- name: Sign our macOS binary
|
||||
if: matrix.platform == 'macos-latest'
|
||||
run: |
|
||||
echo "Signing Package"
|
||||
gon -log-level=info ./build/darwin/gon-sign.json
|
||||
```
|
||||
Please note that signing binaries with Apple could take anywhere from minutes to hours.
|
||||
|
||||
## Combined workflow file:
|
||||
Here is our GitHub workflow file with Windows + macOS combined:
|
||||
```yaml
|
||||
name: "example combined"
|
||||
on:
|
||||
workflow_dispatch:
|
||||
# This Action only starts when you go to Actions and manually run the workflow.
|
||||
|
||||
jobs:
|
||||
package:
|
||||
strategy:
|
||||
matrix:
|
||||
platform: [ windows-latest, macos-latest ]
|
||||
go-version: [1.18]
|
||||
runs-on: ${{ matrix.platform }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: ${{ matrix.go-version }}
|
||||
- name: setup node
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: 14
|
||||
# You may need to manually build you frontend here, unless you have configured frontend build and install commands in wails.json.
|
||||
- name: Get Wails
|
||||
run: go install github.com/wailsapp/wails/v2/cmd/wails@latest
|
||||
- name: Build Wails app
|
||||
run: |
|
||||
wails build
|
||||
- name: MacOS download gon for code signing and app notarization
|
||||
if: matrix.platform == 'macos-latest'
|
||||
run: |
|
||||
brew install mitchellh/gon/gon
|
||||
- name: Import Code-Signing Certificates for macOS
|
||||
if: matrix.platform == 'macos-latest'
|
||||
uses: Apple-Actions/import-codesign-certs@v1
|
||||
with:
|
||||
# The certificates in a PKCS12 file encoded as a base64 string
|
||||
p12-file-base64: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_P12_BASE64 }}
|
||||
# The password used to import the PKCS12 file.
|
||||
p12-password: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_PASSWORD }}
|
||||
- name: Sign our macOS binary
|
||||
if: matrix.platform == 'macos-latest'
|
||||
run: |
|
||||
echo "Signing Package"
|
||||
gon -log-level=info ./build/darwin/gon-sign.json
|
||||
- name: Sign Windows binaries
|
||||
if: matrix.platform == 'windows-latest'
|
||||
run: |
|
||||
echo "Creating certificate file"
|
||||
New-Item -ItemType directory -Path certificate
|
||||
Set-Content -Path certificate\certificate.txt -Value '${{ secrets.WIN_SIGNING_CERT }}'
|
||||
certutil -decode certificate\certificate.txt certificate\certificate.pfx
|
||||
echo "Signing our binaries"
|
||||
& 'C:/Program Files (x86)/Windows Kits/10/bin/10.0.17763.0/x86/signtool.exe' sign /fd sha256 /tr http://ts.ssl.com /f certificate\certificate.pfx /p '${{ secrets.WIN_SIGNING_CERT_PASSWORD }}' .\build\bin\Monitor.exe
|
||||
- name: upload artifacts macOS
|
||||
if: matrix.platform == 'macos-latest'
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: wails-binaries-macos
|
||||
path: build/bin/*
|
||||
- name: upload artifacts windows
|
||||
if: matrix.platform == 'windows-latest'
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: wails-binaries-windows
|
||||
path: build/bin/*
|
||||
```
|
||||
|
||||
# End notes
|
||||
This guide inspired by the RiftShare project and its workflow, which is highly recommended to check out [here](https://github.com/achhabra2/riftshare/blob/main/.github/workflows/build.yaml).
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
Wails 从预先创建的模板生成项目。在 v1 中,这是一组难以维护的项目,这些项目可能会过时。在 v2 中,为了增强社区的能力,为模板添加了一些新功能:
|
||||
|
||||
- 能够从[远程模板](/docs/reference/cli#远程模板)生成项目
|
||||
- 能够从[远程模板](../reference/cli#远程模板)生成项目
|
||||
- 帮助创建自己的模板的工具
|
||||
|
||||
## 创建模板
|
||||
@@ -88,5 +88,5 @@ Renaming package-lock.json -> package-lock.tmpl.json...
|
||||
- 从前端目录中删除任何不需要的文件和目录(例如:.git)
|
||||
- 确保`template.json`完整,尤其是`helpurl`
|
||||
- 将文件推送到 GitHub
|
||||
- 在[社区模板](/docs/community/templates)页面上创建 PR
|
||||
- 在[社区模板](../community/templates)页面上创建 PR
|
||||
- 在[模板公告](https://github.com/wailsapp/wails/discussions/825)讨论板上发布模板
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user