From 5210c938033c7e2aab5c4b92a07e892ff49f2506 Mon Sep 17 00:00:00 2001 From: Ruk Doe Date: Wed, 14 Oct 2026 13:34:27 +0900 Subject: [PATCH] =?UTF-8?q?ci:=20=E3=82=BF=E3=82=B0(v1.2.3)=E3=82=92=20pus?= =?UTF-8?q?h=20=E3=81=97=E3=81=9F=E3=82=89=E3=83=AA=E3=83=AA=E3=83=BC?= =?UTF-8?q?=E3=82=B9=E3=81=99=E3=82=8B=E3=80=82=E7=89=88=E3=81=AF=E3=82=BF?= =?UTF-8?q?=E3=82=B0=E3=81=8B=E3=82=89=E5=8F=96=E3=82=8A=E3=80=81csproj=20?= =?UTF-8?q?=E3=81=AB=E3=81=AF=E6=9B=B8=E3=81=8B=E3=81=AA=E3=81=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01QpDYXaosTCf5Q41gbCw8qt --- .github/workflows/release.yml | 38 +++++++++++++++++------------------ README.md | 2 +- server/Mado.csproj | 3 ++- tray/MadoTray.csproj | 3 ++- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f166789..f34cea3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,14 +1,13 @@ name: Release -# main に入ったら、server/Mado.csproj の版のタグがまだ無ければ MSI を作ってリリースする(タグもここで打つ)。 -# 版を上げない変更(依存の更新など)はリリースしない。 +# v1.2.3 の形のタグを push したら、その版で MSI を作ってリリースする。版の数字はタグから取り、csproj には書かない。 +# 署名の鍵を使うので、main に入っているコミットに打たれたタグだけを出す。 # - mado.msi: サービス・タスクトレイ・ファイアウォール・ProgramData の権限まで入れる(installer/mado.wxs) # - mado.msi.sig: ECDSA P-256 の署名(`mado <タグ> `)。動いている mado はこれを確かめてから入れる(server/Updater.cs) # - mado.msi.sha256 と出どころの証明(gh attestation verify): 入れる側(gitops の setup.ps1)が確かめる on: push: - branches: [main] - workflow_dispatch: + tags: ["v*"] permissions: {} @@ -18,8 +17,6 @@ concurrency: jobs: release: - # 署名鍵を使うので main だけ(workflow_dispatch をほかの枝から動かしても、main に無いコミットを出さない) - if: github.ref == 'refs/heads/main' runs-on: windows-latest permissions: contents: write @@ -27,18 +24,19 @@ jobs: attestations: write steps: - uses: actions/checkout@v7 + with: + fetch-depth: 0 - id: version shell: pwsh run: | - $version = ([xml](Get-Content server/Mado.csproj)).Project.PropertyGroup.Version | Where-Object { $_ } | Select-Object -First 1 - "tag=v$version" >> $env:GITHUB_OUTPUT - # その版のリリースがもうあれば何もしない - gh release view "v$version" --repo $env:GITHUB_REPOSITORY 2>$null | Out-Null - if ($LASTEXITCODE -eq 0) { "v$version はもうある。リリースしない"; "release=false" >> $env:GITHUB_OUTPUT } - else { "release=true" >> $env:GITHUB_OUTPUT } - exit 0 - env: - GH_TOKEN: ${{ github.token }} + $tag = $env:GITHUB_REF_NAME + if ($tag -notmatch '^v\d+\.\d+\.\d+$') { throw "タグは v1.2.3 の形にする: $tag" } + # main に無いコミットは出さない(署名の鍵を使うので) + git merge-base --is-ancestor $env:GITHUB_SHA origin/main + if ($LASTEXITCODE -ne 0) { throw "$tag のコミットが main に無い" } + "tag=$tag" >> $env:GITHUB_OUTPUT + "version=$($tag.TrimStart('v'))" >> $env:GITHUB_OUTPUT + "release=true" >> $env:GITHUB_OUTPUT - if: steps.version.outputs.release == 'true' uses: oven-sh/setup-bun@v2 - if: steps.version.outputs.release == 'true' @@ -62,9 +60,9 @@ jobs: - if: steps.version.outputs.release == 'true' run: dotnet run --project tests/Mado.Tests.csproj - if: steps.version.outputs.release == 'true' - run: dotnet publish server/Mado.csproj -c Release -r win-x64 -o publish + run: dotnet publish server/Mado.csproj -c Release -r win-x64 -o publish -p:Version=${{ steps.version.outputs.version }} - if: steps.version.outputs.release == 'true' - run: dotnet publish tray/MadoTray.csproj -c Release -r win-x64 -o publish + run: dotnet publish tray/MadoTray.csproj -c Release -r win-x64 -o publish -p:Version=${{ steps.version.outputs.version }} - if: steps.version.outputs.release == 'true' shell: pwsh run: | @@ -75,7 +73,7 @@ jobs: wix extension add -g WixToolset.Firewall.wixext/5.0.2 wix extension add -g WixToolset.Util.wixext/5.0.2 wix build installer/mado.wxs -arch x64 -ext WixToolset.Firewall.wixext -ext WixToolset.Util.wixext ` - -d Version=$("${{ steps.version.outputs.tag }}".TrimStart('v')) -d PublishDir=publish -o dist/mado.msi + -d Version=${{ steps.version.outputs.version }} -d PublishDir=publish -o dist/mado.msi $sha = (Get-FileHash dist/mado.msi -Algorithm SHA256).Hash.ToLower() $sha + ' mado.msi' | Set-Content dist/mado.msi.sha256 -NoNewline # 自動更新のための署名。秘密鍵は secret の MADO_SIGNING_KEY(PKCS#8 の base64)。署名したあと、exe に入れた公開鍵で確かめ直す @@ -99,10 +97,10 @@ jobs: uses: actions/attest-build-provenance@v4 with: subject-path: dist/mado.msi - # タグはここで、このコミットに打つ + # タグは push されたものを使う - if: steps.version.outputs.release == 'true' shell: pwsh - run: gh release create $env:TAG dist/mado.msi dist/mado.msi.sha256 dist/mado.msi.sig --target $env:GITHUB_SHA --generate-notes + run: gh release create $env:TAG dist/mado.msi dist/mado.msi.sha256 dist/mado.msi.sig --verify-tag --generate-notes env: GH_TOKEN: ${{ github.token }} TAG: ${{ steps.version.outputs.tag }} diff --git a/README.md b/README.md index 52e179a..41c76fb 100644 --- a/README.md +++ b/README.md @@ -119,7 +119,7 @@ dotnet run tray/make-icon.cs tray/mado.ico # アイコンを作り直す bun run check # 画面の biome、tsc、テスト(bun test web) ``` -main にマージすると自動でリリースする。`server/Mado.csproj` の `` を上げていれば、その版のタグを打って MSI を出す(`release.yml`)。版を上げていなければリリースしない。 +リリースは `v1.2.3` の形のタグを push すると自動で行う(`git tag v1.2.3 && git push origin v1.2.3`)。版の数字はタグから取るので、csproj は書き換えない。main に入っているコミットに打ったタグだけを出す(`release.yml`)。 bun や .NET が手元に無ければ、`oven/bun` と `mcr.microsoft.com/dotnet/sdk:10.0` のコンテナで同じことができる。 exe(Native AOT)と MSI は Windows でしか作れないので、CI(`windows-latest`)で作る。 diff --git a/server/Mado.csproj b/server/Mado.csproj index 197b765..fdfed44 100644 --- a/server/Mado.csproj +++ b/server/Mado.csproj @@ -5,7 +5,8 @@ enable mado Mado - 0.8.6 + + 0.0.0 true true diff --git a/tray/MadoTray.csproj b/tray/MadoTray.csproj index 2ec3e29..4fbbbfb 100644 --- a/tray/MadoTray.csproj +++ b/tray/MadoTray.csproj @@ -7,7 +7,8 @@ enable mado-tray Mado.Tray - 0.8.6 + + 0.0.0 true true