Skip to content

Build Release

Build Release #10

Workflow file for this run

name: Build Release
on:
workflow_dispatch: {
inputs: {
tag: {
description: 'Tag',
required: true,
default: 'v0.0.0'
}
}
}
push:
tags:
- 'v*.*.*'
jobs:
build:
name: Build Windows
runs-on: windows-latest
permissions:
contents: write
env:
TOKEN: ${{ secrets.SIGN_PATH_TOKEN }}
BANGUMI_APP_ID: ${{ secrets.BANGUMI_APP_ID }}
BANGUMI_APP_SECRET: ${{ secrets.BANGUMI_APP_SECRET }}
steps:
- name: 签出仓库
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: master
- name: 初始化 Flutter 环境
uses: subosito/flutter-action@v2
with:
channel: stable
architecture: x64
- name: 检查环境
run: flutter doctor
- name: 拉取依赖
run: flutter pub get
- name: 写入 .env
shell: pwsh
run: |
New-Item -Path . -Name .env -ItemType File -Force
Add-Content -Path .env -Value "BANGUMI_APP_ID=${env:BANGUMI_APP_ID}"
Add-Content -Path .env -Value "BANGUMI_APP_SECRET=${env:BANGUMI_APP_SECRET}"
- name: 打包并压缩
run: |
flutter build windows
Compress-Archive -Path build/windows/x64/runner/Release/* -DestinationPath BangumiToday.zip
- name: 上传打包文件
uses: actions/upload-artifact@v4
with:
name: BangumiToday(zip)
path: build/windows/x64/runner/Release
- name: 打包msix
run: dart run msix:create -p ${{ secrets.SIGN_SECRET }} --version ${{ github.event.inputs.tag || github.ref }}
- name: 上传 MSIX
uses: actions/upload-artifact@v4
with:
name: BangumiToday(msix)
path: BangumiToday.msix
- name: 上传证书
uses: actions/upload-artifact@v4
with:
name: 目棃.cer
path: 目棃.cer
- name: 生成更新说明
run: |
$checksum = Get-FileHash -Path BangumiToday.zip -Algorithm SHA256
$checksum = $checksum.Hash
Write-Output "> 本 Release 文件来自 [GithubActions](https://github.com/BTMuli/BangumiToday/actions/runs/${{ github.run_id }})" >> $env:GITHUB_STEP_SUMMARY
Write-Output "> " >> $env:GITHUB_STEP_SUMMARY
Write-Output "> 由于安装 `.msix` 文件需要证书,请参考 [README](https://github.com/BTMuli/BangumiToday/#%E5%85%B3%E4%BA%8E%E8%AF%81%E4%B9%A6) 进行操作" >> $env:GITHUB_STEP_SUMMARY
Write-Output "" >> $env:GITHUB_STEP_SUMMARY
$log = .\genLog.ps1
$log | ForEach-Object { Write-Output $_ >> $env:GITHUB_STEP_SUMMARY }
Write-Output "sha256:" >> $env:GITHUB_STEP_SUMMARY
Write-Output "+ ZIP:`" + $checksum + "`" >> $env:GITHUB_STEP_SUMMARY
$checksum = Get-FileHash -Path BangumiToday.msix -Algorithm SHA256
$checksum = $checksum.Hash
Write-Output "+ MSIX:`" + $checksum + "`" >> $env:GITHUB_STEP_SUMMARY
# 上传 Release
- name: 发行Release
uses: ncipollo/release-action@v1.5.0
with:
tag: ${{ github.event.inputs.tag }} || ${{ github.ref }}
token: ${{ secrets.RELEASE_TOKEN }}
artifacts: |
BangumiToday.zip
目棃.cer
BangumiToday.msix
draft: true
body: $env:GITHUB_STEP_SUMMARY