高速リリース #7
This file contains hidden or 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: | |
| inputs: | |
| version_prefix: | |
| description: "バージョンの接頭辞。空欄なら build/Directory.Build.props の値を使う" | |
| required: false | |
| type: string | |
| default: "" | |
| version_suffix: | |
| description: "バージョンの接尾辞。空欄なら正式版として扱う" | |
| required: false | |
| type: string | |
| default: "" | |
| create_release: | |
| description: "GitHub Release を作成してパッケージを添付する" | |
| required: false | |
| type: boolean | |
| default: true | |
| permissions: | |
| contents: read | |
| env: | |
| DOTNET_SKIP_FIRST_TIME_EXPERIENCE: "1" | |
| DOTNET_NOLOGO: "1" | |
| jobs: | |
| validate: | |
| name: 追加分のテスト | |
| runs-on: windows-2022 | |
| defaults: | |
| run: | |
| shell: bash | |
| outputs: | |
| version: ${{ steps.version.outputs.version }} | |
| version_prefix: ${{ steps.version.outputs.prefix }} | |
| version_suffix: ${{ steps.version.outputs.suffix }} | |
| is_prerelease: ${{ steps.version.outputs.is_prerelease }} | |
| # ComputeWeave.Dxc が参照する環境変数。 | |
| # https://github.com/actions/runner-images/issues/6531 への対処。 | |
| env: | |
| CI_RUNNER_DOTNET_TEST_PLATFORM: x64 | |
| steps: | |
| - name: ソースコードを取得 | |
| uses: actions/checkout@v4 | |
| - name: .NET SDK をセットアップ | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: "10.x" | |
| - name: NuGet パッケージをキャッシュ | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.nuget/packages | |
| key: nuget-${{ runner.os }}-${{ hashFiles('**/*.csproj', 'build/Directory.Build.props') }} | |
| restore-keys: nuget-${{ runner.os }}- | |
| - name: バージョン番号を決定 | |
| id: version | |
| run: | | |
| PREFIX="${{ inputs.version_prefix }}" | |
| if [ -z "${PREFIX}" ]; then | |
| PREFIX=$(sed -n 's/.*<VersionPrefix>\(.*\)<\/VersionPrefix>.*/\1/p' build/Directory.Build.props | head -n 1) | |
| fi | |
| if [ -z "${PREFIX}" ]; then | |
| echo "バージョンの接頭辞を決定できませんでした。" >&2 | |
| exit 1 | |
| fi | |
| SUFFIX="${{ inputs.version_suffix }}" | |
| if [ -n "${SUFFIX}" ]; then | |
| VERSION="${PREFIX}-${SUFFIX}" | |
| IS_PRERELEASE=true | |
| else | |
| VERSION="${PREFIX}" | |
| IS_PRERELEASE=false | |
| fi | |
| echo "prefix=${PREFIX}" >> "$GITHUB_OUTPUT" | |
| echo "suffix=${SUFFIX}" >> "$GITHUB_OUTPUT" | |
| echo "version=${VERSION}" >> "$GITHUB_OUTPUT" | |
| echo "is_prerelease=${IS_PRERELEASE}" >> "$GITHUB_OUTPUT" | |
| - name: 決定したバージョン番号を確認 | |
| run: | | |
| echo "バージョン : ${{ steps.version.outputs.version }}" | |
| echo "プレリリース : ${{ steps.version.outputs.is_prerelease }}" | |
| echo "コミット : ${{ github.sha }}" | |
| - name: ソリューションをビルド | |
| run: | | |
| dotnet build ComputeWeave.sln -c Release -p:Platform=x64 \ | |
| -p:VersionPrefix=${{ steps.version.outputs.prefix }} \ | |
| -p:VersionSuffix=${{ steps.version.outputs.suffix }} | |
| # 全件は release.yml が回す。ここは今回追加した契約に対応するテストだけへ絞る。 | |
| - name: 生成される呼び出しのテストを実行 | |
| run: | | |
| dotnet test tests/ComputeWeave.Tests.SourceGenerators/ComputeWeave.Tests.SourceGenerators.csproj \ | |
| -c Release -p:Platform=x64 \ | |
| --filter "FullyQualifiedName~PipelineHostEmissionTests|FullyQualifiedName~ResourcePlanEmissionTests|FullyQualifiedName~OwnedResourceParameterAnalyzerTests" | |
| - name: 所有資源のテストを実行 | |
| run: | | |
| dotnet test tests/ComputeWeave.Tests.Internals/ComputeWeave.Tests.Internals.csproj \ | |
| -c Release -p:Platform=x64 \ | |
| --filter "FullyQualifiedName~GeneratedPipelineHostTests" | |
| - name: 外部アセンブリからの利用のテストを実行 | |
| run: | | |
| dotnet test tests/ComputeWeave.Tests/ComputeWeave.Tests.csproj \ | |
| -c Release -p:Platform=x64 \ | |
| --filter "FullyQualifiedName~OwnedResourcePipelineTests" | |
| pack: | |
| name: NuGet パッケージの作成 | |
| runs-on: windows-2022 | |
| needs: [validate] | |
| defaults: | |
| run: | |
| shell: bash | |
| steps: | |
| - name: ソースコードを取得 | |
| uses: actions/checkout@v4 | |
| - name: .NET SDK をセットアップ | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: "10.x" | |
| # Platform と CI_RUNNER_DOTNET_TEST_PLATFORM はどちらも設定しない。 | |
| # ComputeWeave.Dxc はどちらも未設定のときだけネイティブライブラリを runtimes/<RID>/native へ配置する。 | |
| - name: パッケージを作成 | |
| run: | | |
| for project in \ | |
| src/ComputeWeave.Core/ComputeWeave.Core.csproj \ | |
| src/ComputeWeave/ComputeWeave.csproj \ | |
| src/ComputeWeave.Dxc/ComputeWeave.Dxc.csproj \ | |
| src/ComputeWeave.D3D12MemoryAllocator/ComputeWeave.D3D12MemoryAllocator.csproj | |
| do | |
| dotnet pack "$project" -c Release \ | |
| -p:VersionPrefix=${{ needs.validate.outputs.version_prefix }} \ | |
| -p:VersionSuffix=${{ needs.validate.outputs.version_suffix }} | |
| done | |
| - name: 作成されたパッケージ一覧を確認 | |
| run: ls -la ./artifacts/ | |
| - name: パッケージをアーティファクトとして保存 | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: nuget-packages | |
| path: artifacts/ | |
| retention-days: 90 | |
| if-no-files-found: error | |
| publish-nuget: | |
| name: NuGet.org へ公開 | |
| runs-on: ubuntu-latest | |
| needs: [validate, pack] | |
| environment: nuget-release | |
| permissions: | |
| id-token: write | |
| packages: write | |
| defaults: | |
| run: | |
| shell: bash | |
| steps: | |
| - name: .NET SDK をセットアップ | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: "10.x" | |
| - name: パッケージをダウンロード | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: nuget-packages | |
| path: ./artifacts | |
| - name: ダウンロードしたファイルを確認 | |
| run: ls -la ./artifacts/ | |
| - name: NuGet Trusted Publishing でログイン | |
| uses: NuGet/login@v1 | |
| id: nuget-login | |
| with: | |
| user: routersys | |
| - name: NuGet.org へパッケージを発行 | |
| run: | | |
| dotnet nuget push ./artifacts/*.nupkg \ | |
| --api-key ${{ steps.nuget-login.outputs.NUGET_API_KEY }} \ | |
| --source https://api.nuget.org/v3/index.json \ | |
| --skip-duplicate | |
| - name: GitHub Packages へも発行 | |
| run: | | |
| dotnet nuget push ./artifacts/*.nupkg \ | |
| --api-key ${{ secrets.GITHUB_TOKEN }} \ | |
| --source https://nuget.pkg.github.com/routersys/index.json \ | |
| --skip-duplicate | |
| continue-on-error: true | |
| github-release: | |
| name: GitHub Release の作成 | |
| runs-on: ubuntu-latest | |
| needs: [validate, pack, publish-nuget] | |
| if: ${{ inputs.create_release }} | |
| permissions: | |
| contents: write | |
| defaults: | |
| run: | |
| shell: bash | |
| steps: | |
| - name: ソースコードを取得 | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: パッケージをダウンロード | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: nuget-packages | |
| path: ./artifacts | |
| - name: 直前のリリースタグを取得 | |
| id: prev_tag | |
| run: | | |
| PREV=$(git tag --sort=-version:refname \ | |
| | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' \ | |
| | head -n 1 || true) | |
| echo "tag=${PREV}" >> "$GITHUB_OUTPUT" | |
| - name: コミット履歴からリリースノートを生成 | |
| id: changelog | |
| run: | | |
| PREV="${{ steps.prev_tag.outputs.tag }}" | |
| if [ -n "${PREV}" ]; then | |
| LOG=$(git log "${PREV}..${{ github.sha }}" --pretty=format:"- %s (%h)" --no-merges) | |
| else | |
| LOG=$(git log -n 30 --pretty=format:"- %s (%h)" --no-merges) | |
| fi | |
| { | |
| echo "notes<<NOTES_EOF" | |
| echo "### 変更内容" | |
| echo "${LOG:-変更履歴を取得できませんでした。}" | |
| echo "" | |
| echo "### インストール" | |
| echo '```sh' | |
| echo "dotnet add package ComputeWeave --version ${{ needs.validate.outputs.version }}" | |
| echo '```' | |
| echo "" | |
| echo "### NuGet" | |
| echo "https://www.nuget.org/packages/ComputeWeave/${{ needs.validate.outputs.version }}" | |
| echo "" | |
| echo "全件のテストは実行していません。今回の変更に対応するテストだけを通しています。" | |
| echo "NOTES_EOF" | |
| } >> "$GITHUB_OUTPUT" | |
| # タグは GITHUB_TOKEN で作られるため release.yml は起動しない。 | |
| - name: GitHub Release を作成してパッケージを添付 | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ needs.validate.outputs.version }} | |
| name: v${{ needs.validate.outputs.version }} | |
| target_commitish: ${{ github.sha }} | |
| body: ${{ steps.changelog.outputs.notes }} | |
| prerelease: ${{ needs.validate.outputs.is_prerelease }} | |
| files: | | |
| artifacts/*.nupkg | |
| artifacts/*.snupkg |