diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..54e576f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,61 @@ +name: Build and Release + +on: + push: + branches: + - "release/v[0-9]-[0-9]*" + +jobs: + build-and-release: + runs-on: windows-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup MSBuild + uses: microsoft/setup-msbuild@v2 + + # ブランチ名からバージョン番号を抽出 + - name: Extract Version from Branch + id: get_version + shell: bash + run: | + BRANCH_NAME=${GITHUB_REF#refs/heads/release/v} + VERSION_BASE=${BRANCH_NAME//-/. } + echo "VERSION_BASE=$VERSION_BASE" >> $GITHUB_OUTPUT + + # バージョン変数を定義 + - name: Set Version + id: version + shell: bash + run: | + VERSION=v${{ steps.get_version.outputs.VERSION_BASE }}.${{ github.run_number }} + echo "VERSION=$VERSION" >> $GITHUB_OUTPUT + + # ビルド + - name: Build + run: | + echo "Building version ${{ steps.version.outputs.VERSION }}" + msbuild desktop.sln ` + /p:Configuration=Release ` + /p:Platform="Any CPU" ` + /p:OutputPath=build_output/ + /p:Version=${{ steps.version.outputs.VERSION }} + + # 成果物をZIPにまとめる + - name: Archive Release + shell: pwsh + run: | + Compress-Archive -Path build_output/* -DestinationPath STOPGAME_${{ steps.version.outputs.VERSION }}.zip + + # リリース作成 + - name: Create Release + uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ steps.version.outputs.VERSION }} + name: Release ${{ steps.version.outputs.VERSION }} + generate_release_notes: true + files: | + STOPGAME_${{ steps.version.outputs.VERSION }}.zip + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}