发布支持electron的运行 #214
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 发布软件 | |
on: | |
workflow_dispatch: | |
push: | |
paths-ignore: | |
- '**/*.md' | |
- '**/*.yml' | |
- .gitignore | |
- .editorconfig | |
permissions: write-all # 给所有工作写权限 | |
jobs: | |
jobs_v: | |
name: 构建版本号和变更信息 | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.create_version.outputs.NewVersion }} # 版本号 | |
body: ${{ steps.create_body.outputs.Body }} # 版本变更内容 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
fetch-depth: 0 | |
- name: 检查是否 "发布" | |
run: | | |
latest_commit_message=$(git log -1 --pretty=%B) | |
if [[ $latest_commit_message == *"发布"* ]]; then | |
echo "找到发布关键字继续工作流" | |
else | |
echo "没有找到发布关键字停止工作流" | |
exit 1 # 停止工作流程 | |
fi | |
- name: 递增版本号 | |
id: create_version | |
uses: duolabmeng6/action-autotag-python@master | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: 获取更新日志 | |
id: create_body | |
uses: duolabmeng6/action-Releases-log@main | |
with: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
FILE: .github/releasesText.md | |
KEYS: bug,改进,优化,新增,删除 | |
- name: 查看版本号和更新日志 | |
run: | | |
echo ${{ format('version={0}', steps.create_version.outputs.NewVersion ) }} | |
echo "${{ steps.create_body.outputs.Body }}" | |
jobs_macos: | |
# 暂停 | |
#if: false | |
needs: [ jobs_v ] | |
name: 构建macos软件 | |
runs-on: macos-12 | |
env: | |
version: ${{ needs.jobs_v.outputs.version }} | |
body: ${{ needs.jobs_v.outputs.Body }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: 构建缓存 | |
uses: actions/cache@v3 | |
with: | |
path: | | |
/Users/runner/.npm | |
key: ${{ runner.os }}-js-${{ hashFiles('**/package.json') }} | |
restore-keys: | | |
${{ runner.os }}-js- | |
- name: 查看文件 | |
run: | | |
pwd | |
ls -la | |
echo "New Body: ${{ env.body }}" | |
- name: 安装 go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '^1.21.0' | |
cache-dependency-path: | | |
**/go.sum | |
**/go.mod | |
go-version-file: 'go.mod' | |
- run: go version | |
- name: 安装 wails 工具 | |
run: | | |
go install github.com/wailsapp/wails/v2/cmd/wails@latest | |
wails | |
- name: 生成 Version.go 文件 | |
run: | | |
echo -e "package mymodel\n\nvar Version = \"${version}\"" > GoEasyDesigner/mymodel/Version.go | |
cat GoEasyDesigner/mymodel/Version.go | |
- name: 编译 | |
run: | | |
pwd | |
cd GoEasyDesigner | |
wails build | |
ls -la | |
- name: 查看编译的文件保存 | |
run: | | |
ls -la | |
mkdir -p /tmp/artifacts | |
cp -r GoEasyDesigner/build/bin/GoEasyDesigner.app /tmp/artifacts/GoEasyDesigner.app | |
cp -r GoEasyDesigner/build/dmg.sh /tmp/artifacts/dmg.sh | |
chmod +x /tmp/artifacts/GoEasyDesigner.app/Contents/MacOS/GoEasyDesigner | |
- name: 创建压缩包 | |
run: | | |
cd /tmp/artifacts/ | |
./dmg.sh | |
zip -r ./GoEasyDesigner_MacOS.zip ./GoEasyDesigner.app | |
- name: 上传产物 | |
uses: actions/upload-artifact@v3 | |
with: | |
name: macos | |
path: | | |
/tmp/artifacts/*.zip | |
/tmp/artifacts/*.dmg | |
jobs_window: | |
needs: jobs_v # 等待 jobs_v 任务完成才执行 | |
name: 构建window软件 | |
timeout-minutes: 20 | |
runs-on: windows-2022 | |
env: | |
version: ${{ needs.jobs_v.outputs.version }} | |
body: ${{ needs.jobs_v.outputs.Body }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
- name: 构建缓存 | |
uses: actions/cache@v3 | |
with: | |
path: | | |
C:\npm\cache | |
key: ${{ runner.os }}-js-${{ hashFiles('**/package.json') }} | |
restore-keys: | | |
${{ runner.os }}-js- | |
- name: 读入环境信息 | |
run: | | |
echo ${{ format('version {0}', env.version ) }} # 版本号 | |
- name: 安装 go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '^1.21.0' | |
cache-dependency-path: | | |
**/go.sum | |
**/go.mod | |
go-version-file: 'go.mod' | |
- run: go version | |
- name: 安装 UPX | |
uses: crazy-max/ghaction-upx@v2 | |
with: | |
install-only: true | |
- name: 安装 wails 工具 | |
run: | | |
go install github.com/wailsapp/wails/v2/cmd/wails@latest | |
wails | |
- name: 生成 Version.go 文件 | |
shell: bash | |
run: | | |
echo -e "package mymodel\n\nvar Version = \"${version}\"" > GoEasyDesigner/mymodel/Version.go | |
cat GoEasyDesigner/mymodel/Version.go | |
- name: 编译exe | |
run: | | |
cd GoEasyDesigner | |
wails build -webview2 embed -upx | |
ls | |
- name: 上传产物 | |
uses: actions/upload-artifact@v3 | |
with: | |
name: window | |
path: | | |
GoEasyDesigner/build/bin/*.exe | |
jobs4: | |
needs: [ jobs_v,jobs_macos,jobs_window ] | |
name: 发布版本 | |
runs-on: ubuntu-latest | |
env: | |
version: ${{ needs.jobs_v.outputs.version }} | |
body: ${{ needs.jobs_v.outputs.Body }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
fetch-depth: 0 | |
- name: 下载产物 | |
id: download | |
uses: actions/download-artifact@v3 | |
with: | |
path: ./ | |
- name: 读入环境信息 | |
run: | | |
echo ${{ format('version {0}', env.version ) }} | |
echo ${{steps.download.outputs.download-path}} | |
ls -R | |
- name: 发布文件 | |
uses: ncipollo/release-action@v1 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
allowUpdates: true # 覆盖文件 | |
#draft: true # 草稿 自己可见 版本号会保持一样 默认是自动发布 latest | |
#prerelease: true # 预发布 别人可以看到 版本号会继续加 | |
tag: ${{ env.version }} # 版本号 v0.1.0 | |
body: ${{ env.body }} | |
artifacts: "macos/*.zip,macos/*.dmg,window/*.exe,window/*.zip" | |