Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 20 additions & 61 deletions .github/workflows/release-upload-zip.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
name: Release - Upload ZIP

on:
pull_request:
branches:
- main
types:
- closed
push:
tags:
- 'v*' # v1.3.0.0 など

permissions:
contents: write
Expand All @@ -15,85 +13,46 @@ env:

jobs:
release:
# 通常のマージでのみ動作することを想定
if: github.event.pull_request.merged == true
runs-on: windows-latest # 安定した最新のWindows環境
runs-on: windows-2025-vs2026

steps:
- name: Checkout
uses: actions/checkout@v4
with:
# マージコミットではなく、ソースブランチのHEADを一時的に見るか、全履歴を取得
fetch-depth: 0

- name: Resolve tag from source branch (v*)
id: tag_check
shell: pwsh
run: |
git fetch --tags --force
$headSha = '${{ github.event.pull_request.head.sha }}'
$baseSha = '${{ github.event.pull_request.base.sha }}'

$selectedTag = git describe --tags --match 'v*' --abbrev=0 $headSha 2>$null
if (-not $selectedTag) {
Write-Error "No reachable v* tag found from source branch head commit: $headSha"
exit 1
}

$tagCommit = git rev-list -n 1 $selectedTag

# 初期値を設定
$shouldRelease = "true"

git merge-base --is-ancestor $tagCommit $baseSha
if ($LASTEXITCODE -eq 0) {
$shouldRelease = "false"
Write-Host "Tag $selectedTag already existed on main side before merge. Skipping release flow."
}

# GitHubの環境変数とステップ出力に保存
"SHOULD_RELEASE=$shouldRelease" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
"RELEASE_TAG=$selectedTag" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
Write-Host "Using tag: $selectedTag"

- name: Setup .NET
if: env.SHOULD_RELEASE == 'true'
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'

- name: Setup MSBuild
if: env.SHOULD_RELEASE == 'true'
uses: microsoft/setup-msbuild@v2
with:
vs-version: '17.0'

# packages.config 対応
- name: NuGet Restore
if: env.SHOULD_RELEASE == 'true'
run: nuget restore SampleCSharpBulkRAGReg.sln

- name: Build (Release)
if: env.SHOULD_RELEASE == 'true'
run: |
msbuild SampleCSharpBulkRAGReg.sln `
/p:Configuration=Release `
/p:Platform="Any CPU" `
/t:Build
run: msbuild SampleCSharpBulkRAGReg.sln `
/p:Configuration=Release `
/p:Platform="Any CPU" `
/t:Build

# ZIP 作成(タグ名を使用)
- name: Create ZIP
if: env.SHOULD_RELEASE == 'true'
run: |
Compress-Archive `
-Path SampleCSharpBulkRAGReg/bin/Release/* `
-DestinationPath SampleCSharpBulkRAGReg-${{ env.RELEASE_TAG }}.zip
-DestinationPath SampleCSharpBulkRAGReg-${{ github.ref_name }}.zip

# 非推奨アクションを最新の定番アクションに統合
- name: Create and Upload GitHub Release
if: env.SHOULD_RELEASE == 'true'
uses: softprops/action-gh-release@v2
# Release を作成または更新し、ZIP を添付
- name: Create or Update Release and Upload ZIP
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ env.RELEASE_TAG }}
name: Release ${{ env.RELEASE_TAG }}
tag_name: ${{ github.ref_name }}
name: Release ${{ github.ref_name }}
draft: false
prerelease: false
files: SampleCSharpBulkRAGReg-${{ env.RELEASE_TAG }}.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
overwrite_files: true
files: SampleCSharpBulkRAGReg-${{ github.ref_name }}.zip
4 changes: 2 additions & 2 deletions SampleCSharpBulkRAGReg/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@
// ビルド番号
// リビジョン
//
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyVersion("1.1.1.0")]
[assembly: AssemblyFileVersion("1.1.1.0")]
4 changes: 2 additions & 2 deletions SampleCSharpBulkRAGReg/SampleCSharpBulkRAGReg.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@
<Reference Include="Microsoft.Extensions.Logging.Abstractions, Version=10.0.0.8, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Extensions.Logging.Abstractions.10.0.8\lib\net462\Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Identity.Client, Version=4.79.2.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Identity.Client.4.79.2\lib\net472\Microsoft.Identity.Client.dll</HintPath>
<Reference Include="Microsoft.Identity.Client, Version=4.81.0.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Identity.Client.4.81.0\lib\net472\Microsoft.Identity.Client.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IdentityModel.Abstractions, Version=8.18.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.IdentityModel.Abstractions.8.18.0\lib\net472\Microsoft.IdentityModel.Abstractions.dll</HintPath>
Expand Down
2 changes: 1 addition & 1 deletion SampleCSharpBulkRAGReg/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<package id="Microsoft.Bcl.TimeProvider" version="10.0.8" targetFramework="net472" />
<package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="10.0.8" targetFramework="net472" />
<package id="Microsoft.Extensions.Logging.Abstractions" version="10.0.8" targetFramework="net472" />
<package id="Microsoft.Identity.Client" version="4.79.2" targetFramework="net472" />
<package id="Microsoft.Identity.Client" version="4.81.0" targetFramework="net472" />
<package id="Microsoft.IdentityModel.Abstractions" version="8.18.0" targetFramework="net472" />
<package id="Microsoft.IdentityModel.JsonWebTokens" version="8.18.0" targetFramework="net472" />
<package id="Microsoft.IdentityModel.Logging" version="8.18.0" targetFramework="net472" />
Expand Down
Loading