Skip to content

feat(windows): 自動執行新增 CSV 匯入、資料傳輸、失敗重試與 Webhook 通知 #173

feat(windows): 自動執行新增 CSV 匯入、資料傳輸、失敗重試與 Webhook 通知

feat(windows): 自動執行新增 CSV 匯入、資料傳輸、失敗重試與 Webhook 通知 #173

Workflow file for this run

name: Auto Release Gate
on:
push:
branches:
- master
workflow_dispatch:
inputs:
force:
description: "人工核准並立即發布完整的 Unreleased 批次"
required: false
default: false
type: boolean
permissions:
contents: write
actions: write
concurrency:
group: auto-release-master
cancel-in-progress: false
jobs:
evaluate-and-release:
name: Evaluate release batch
runs-on: windows-latest
steps:
- name: Checkout full history
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Evaluate release policy
id: decision
shell: pwsh
run: |
$force = "${{ github.event_name }}" -eq "workflow_dispatch" -and "${{ inputs.force }}" -eq "true"
$parameters = @{
RepositoryRoot = "."
Force = $force
}
.\scripts\Invoke-AutoReleaseDecision.ps1 @parameters
- name: Write decision summary
if: always()
shell: pwsh
run: |
@"
## 自動發版判斷
- 是否發布:`${{ steps.decision.outputs.should_release }}`
- 原因:${{ steps.decision.outputs.reason }}
- 最新版本:`${{ steps.decision.outputs.latest_tag }}`
- 下一版本:`v${{ steps.decision.outputs.next_version }}`
- 尚未發版的程式 commit:`${{ steps.decision.outputs.impact_commit_count }}`
- 參考變更分數(不會觸發發版):`${{ steps.decision.outputs.score }}`
"@ | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Append -Encoding utf8
# 日常驗證由 Windows Desktop workflow 處理;真正發版前再在同一條流程重跑一次,
# 避免版本 commit、tag 與公開 Release 在 smoke 失敗時仍被建立。
- name: Setup MSBuild for release verification
if: steps.decision.outputs.should_release == 'true'
uses: microsoft/setup-msbuild@v3
- name: Setup NuGet for release verification
if: steps.decision.outputs.should_release == 'true'
uses: NuGet/setup-nuget@v4
- name: Verify Windows desktop build and smoke tests
if: steps.decision.outputs.should_release == 'true'
shell: pwsh
run: .\tests\Run-SmokeTests.ps1
- name: Prepare version files
if: steps.decision.outputs.should_release == 'true'
shell: pwsh
run: |
.\scripts\Prepare-AutoRelease.ps1 `
-Version "${{ steps.decision.outputs.next_version }}" `
-LatestTag "${{ steps.decision.outputs.latest_tag }}" `
-RepositoryRoot "."
- name: Commit and tag release
if: steps.decision.outputs.should_release == 'true'
shell: pwsh
run: |
$version = "${{ steps.decision.outputs.next_version }}"
$tagName = "v$version"
git config user.name "Nick Lin"
git config user.email "nicklin@gis.fcu.edu.tw"
git add -- .\mySQLPunk\Properties\AssemblyInfo.cs .\README.md .\CHANGELOG.md
git diff --cached --check
if ($LASTEXITCODE -ne 0) { throw "Release preparation diff check failed." }
git commit `
-m "chore(release): 發佈 $tagName" `
-m "原因:已標記重大里程碑,將累積完成的功能與修正一起發布。" `
-m "調整:同步程式版本、README 與 Git tag,交由 Release workflow 建置安裝程式。" `
-m "影響:GitHub Release 會一次產生 Windows、Linux 與 macOS 的已驗證安裝資產。"
if ($LASTEXITCODE -ne 0) { throw "Cannot create the release commit." }
git tag -a $tagName -m "發佈 $tagName"
if ($LASTEXITCODE -ne 0) { throw "Cannot create $tagName." }
git push origin HEAD:master $tagName
if ($LASTEXITCODE -ne 0) { throw "Cannot push the release commit and tag." }
# 使用 GITHUB_TOKEN 推 tag 不會再觸發另一個 workflow,必須明確 dispatch Release。
- name: Dispatch release build
if: steps.decision.outputs.should_release == 'true'
shell: pwsh
env:
GH_TOKEN: ${{ github.token }}
run: |
gh workflow run release.yml `
--repo "${{ github.repository }}" `
--ref master `
-f "version=${{ steps.decision.outputs.next_version }}"