高速リリース #10
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: ubuntu-latest | |
| 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 }} | |
| steps: | |
| - name: ソースコードを取得 | |
| uses: actions/checkout@v4 | |
| - name: バージョン番号を決定 | |
| id: version | |
| env: | |
| VERSION_PREFIX: ${{ inputs.version_prefix }} | |
| VERSION_SUFFIX: ${{ inputs.version_suffix }} | |
| run: | | |
| PREFIX="${VERSION_PREFIX}" | |
| if [ -z "${PREFIX}" ]; then | |
| PREFIX=$(sed -n 's/.*<VersionPrefix>\(.*\)<\/VersionPrefix>.*/\1/p' build/Directory.Build.props | head -n 1) | |
| fi | |
| if [[ ! "${PREFIX}" =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$ ]]; then | |
| echo "バージョンの接頭辞が正しくありません。" >&2 | |
| exit 1 | |
| fi | |
| SUFFIX="${VERSION_SUFFIX}" | |
| if [ -n "${SUFFIX}" ] && [[ ! "${SUFFIX}" =~ ^[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*$ ]]; then | |
| echo "バージョンの接尾辞が正しくありません。" >&2 | |
| exit 1 | |
| fi | |
| 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 }}" | |
| 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: パッケージを作成 | |
| env: | |
| VERSION_PREFIX: ${{ needs.validate.outputs.version_prefix }} | |
| VERSION_SUFFIX: ${{ needs.validate.outputs.version_suffix }} | |
| 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=${VERSION_PREFIX}" \ | |
| "-p:VersionSuffix=${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 |