build-release #1
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: build-release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: "tag: git tag you want create. (sample 1.0.0)" | |
| required: true | |
| dry-run: | |
| description: "dry-run: true will never create relase/nuget." | |
| required: true | |
| default: false | |
| type: boolean | |
| jobs: | |
| update-packagejson: | |
| permissions: | |
| actions: read | |
| contents: write | |
| uses: Cysharp/Actions/.github/workflows/update-packagejson.yaml@main | |
| with: | |
| file-path: | | |
| ./src/MessagePipe.Unity/Assets/Plugins/MessagePipe/package.json | |
| ./src/MessagePipe.Unity/Assets/Plugins/MessagePipe.VContainer/package.json | |
| ./src/MessagePipe.Unity/Assets/Plugins/MessagePipe.Zenject/package.json | |
| ./src/MessagePipe.Unity/Assets/Plugins/MessagePipe.Interprocess/package.json | |
| tag: ${{ inputs.tag }} | |
| dry-run: ${{ inputs.dry-run }} | |
| build-dotnet: | |
| needs: [update-packagejson] | |
| permissions: | |
| contents: read | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 10 | |
| services: | |
| redis: | |
| image: redis | |
| options: >- | |
| --health-cmd "redis-cli ping" | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| ports: | |
| - 6379:6379 | |
| nats: | |
| image: nats | |
| ports: | |
| - 4222:4222 | |
| steps: | |
| - run: echo ${{ needs.update-packagejson.outputs.sha }} | |
| - uses: Cysharp/Actions/.github/actions/checkout@main | |
| with: | |
| ref: ${{ needs.update-packagejson.outputs.sha }} | |
| - uses: Cysharp/Actions/.github/actions/setup-dotnet@main | |
| with: | |
| dotnet-version: | | |
| 6.0.x | |
| # build and pack nuget (.nupkg and .symbols.nupkg will be created) | |
| - run: dotnet build ./tools/PostBuildUtility/ -c Release | |
| - run: dotnet build -c Release -p:Version=${{ inputs.tag }} | |
| - run: dotnet test -c Release --no-build | |
| - run: dotnet pack -c Release --no-build -p:Version=${{ inputs.tag }} -p:IncludeSymbols=true -o ./publish | |
| # Store artifacts. | |
| - uses: Cysharp/Actions/.github/actions/upload-artifact@main | |
| with: | |
| name: nuget | |
| path: ./publish/ | |
| if-no-files-found: error | |
| retention-days: 1 | |
| # Upload analyzer. | |
| - uses: Cysharp/Actions/.github/actions/upload-artifact@main | |
| with: | |
| name: MessagePipe.Analyzer | |
| path: ./src/MessagePipe.Analyzer/bin/Release/netstandard2.0/MessagePipe.Analyzer.dll | |
| retention-days: 1 | |
| build-unity: | |
| needs: [update-packagejson] | |
| strategy: | |
| matrix: | |
| unity: ["2021.3.41f1"] | |
| permissions: | |
| contents: read | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 15 | |
| steps: | |
| - name: Load secrets | |
| id: op-load-secret | |
| uses: 1password/load-secrets-action@581a835fb51b8e7ec56b71cf2ffddd7e68bb25e0 # v2.0.0 | |
| with: | |
| export-env: false | |
| env: | |
| OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN_PUBLIC }} | |
| UNITY_EMAIL: "op://${{ vars.OP_VAULT_ACTIONS_PUBLIC }}/UNITY_LICENSE/username" | |
| UNITY_PASSWORD: "op://${{ vars.OP_VAULT_ACTIONS_PUBLIC }}/UNITY_LICENSE/credential" | |
| UNITY_SERIAL: "op://${{ vars.OP_VAULT_ACTIONS_PUBLIC }}/UNITY_LICENSE/serial" | |
| - run: echo ${{ needs.update-packagejson.outputs.sha }} | |
| - uses: Cysharp/Actions/.github/actions/checkout@main | |
| with: | |
| ref: ${{ needs.update-packagejson.outputs.sha }} | |
| # Execute scripts: Export Package | |
| # /opt/Unity/Editor/Unity -quit -batchmode -nographics -silent-crashes -logFile -projectPath . -executeMethod PackageExporter.Export | |
| - name: Build Unity (.unitypacakge) | |
| uses: Cysharp/Actions/.github/actions/unity-builder@main | |
| env: | |
| UNITY_EMAIL: ${{ steps.op-load-secret.outputs.UNITY_EMAIL }} | |
| UNITY_PASSWORD: ${{ steps.op-load-secret.outputs.UNITY_PASSWORD }} | |
| UNITY_SERIAL: ${{ steps.op-load-secret.outputs.UNITY_SERIAL }} | |
| with: | |
| projectPath: src/MessagePipe.Unity | |
| unityVersion: ${{ matrix.unity }} | |
| targetPlatform: StandaloneLinux64 | |
| buildMethod: PackageExporter.Export | |
| - uses: Cysharp/Actions/.github/actions/check-metas@main # check meta files | |
| with: | |
| directory: src/MessagePipe.Unity | |
| # Store artifacts. | |
| - uses: Cysharp/Actions/.github/actions/upload-artifact@main | |
| with: | |
| name: MessagePipe.Unity.${{ inputs.tag }}.unitypackage | |
| path: ./src/MessagePipe.Unity/MessagePipe*.${{ inputs.tag }}.unitypackage | |
| if-no-files-found: error | |
| retention-days: 1 | |
| # publish | |
| publish: | |
| name: "Publish NuGet packages" | |
| needs: [build-dotnet, build-unity] | |
| permissions: | |
| contents: read | |
| id-token: write # required for NuGet Trusted Publish | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 10 | |
| steps: | |
| - uses: Cysharp/Actions/.github/actions/setup-dotnet@main | |
| - uses: Cysharp/Actions/.github/actions/download-artifact@main | |
| # push nuget | |
| - name: NuGet login (OIDC) | |
| uses: NuGet/login@8d196754b4036150537f80ac539e15c2f1028841 # v1.2.0 | |
| id: login | |
| with: | |
| user: ${{ secrets.NUGET_USER }} | |
| - run: dotnet nuget push "./nuget/*.nupkg" --skip-duplicate -s https://api.nuget.org/v3/index.json -k "${NUGET_KEY}" | |
| if: ${{ !inputs.dry-run }} | |
| env: | |
| NUGET_KEY: ${{ steps.login.outputs.NUGET_API_KEY }} | |
| # release | |
| create-release: | |
| needs: [update-packagejson, publish] | |
| permissions: | |
| contents: write | |
| id-token: write # required for NuGet Trusted Publish | |
| uses: Cysharp/Actions/.github/workflows/create-release.yaml@main | |
| with: | |
| commit-id: ${{ needs.update-packagejson.outputs.sha }} | |
| dry-run: ${{ inputs.dry-run }} | |
| tag: ${{ inputs.tag }} | |
| nuget-push: false | |
| release-upload: true | |
| release-asset-path: | | |
| ./MessagePipe.Analyzer/MessagePipe.Analyzer.dll | |
| ./MessagePipe.Unity.${{ inputs.tag }}.unitypackage/MessagePipe.${{ inputs.tag }}.unitypackage | |
| ./MessagePipe.Unity.${{ inputs.tag }}.unitypackage/MessagePipe.VContainer.${{ inputs.tag }}.unitypackage | |
| ./MessagePipe.Unity.${{ inputs.tag }}.unitypackage/MessagePipe.Zenject.${{ inputs.tag }}.unitypackage | |
| ./MessagePipe.Unity.${{ inputs.tag }}.unitypackage/MessagePipe.Interprocess.${{ inputs.tag }}.unitypackage | |
| secrets: inherit | |
| cleanup: | |
| if: ${{ needs.update-packagejson.outputs.is-branch-created == 'true' }} | |
| needs: [update-packagejson, create-release] | |
| permissions: | |
| contents: write | |
| uses: Cysharp/Actions/.github/workflows/clean-packagejson-branch.yaml@main | |
| with: | |
| branch: ${{ needs.update-packagejson.outputs.branch-name }} |