Build #115
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 | |
| on: | |
| workflow_run: | |
| workflows: ["Verify Templates"] | |
| types: | |
| - completed | |
| push: | |
| branches: | |
| - master | |
| jobs: | |
| collect-info: | |
| if: ${{ github.event_name == 'push' || github.event.workflow_run.conclusion == 'success' }} | |
| runs-on: ubuntu-latest | |
| outputs: | |
| build_type: ${{ steps.info.outputs.build_type }} | |
| build_id: ${{ steps.info.outputs.build_id }} | |
| sha_short: ${{ steps.info.outputs.sha_short }} | |
| last_commit: ${{ steps.setSHAs.outputs.base }} | |
| steps: | |
| - uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 # Need to fetch all for proper history | |
| - name: Collect build info | |
| id: info | |
| uses: actions/github-script@v6 | |
| with: | |
| script: | | |
| let buildType = "Development"; | |
| if (context.ref == "refs/heads/master" && context.repo.owner == "ResoniteModding") { | |
| buildType = "BleedingEdge"; | |
| } | |
| core.setOutput("build_type", buildType); | |
| let shortHash = ""; | |
| await exec.exec("git", ["rev-parse", "--short", "HEAD"], { | |
| listeners: { | |
| stdout: d => shortHash += d.toString().trim(), | |
| } | |
| }); | |
| core.setOutput("sha_short", shortHash); | |
| core.setOutput("build_id", context.runNumber); | |
| - name: Derive appropriate SHAs for base and head | |
| id: setSHAs | |
| uses: nrwl/nx-set-shas@v4 | |
| if: ${{ steps.info.outputs.build_type == 'BleedingEdge' }} | |
| with: | |
| main-branch-name: master | |
| workflow-id: build.yml | |
| build: | |
| needs: collect-info | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| project: | |
| - name: BepInEx.Templates | |
| path: BepInEx.Templates/BepInEx.Templates.csproj | |
| version_tag: PackageVersion | |
| - name: BepInEx.ResonitePluginInfoProps | |
| path: BepInEx.ResonitePluginInfoProps/BepInEx.ResonitePluginInfoProps.csproj | |
| version_tag: Version | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: "10.0.x" | |
| - name: Extract version | |
| id: version | |
| run: | | |
| VERSION=$(grep -oP "(?<=<${{ matrix.project.version_tag }}>)[^<]+" ${{ matrix.project.path }}) | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| - name: Build | |
| run: | | |
| if [ "${{ needs.collect-info.outputs.build_type }}" == "BleedingEdge" ]; then | |
| VERSION="${{ steps.version.outputs.version }}-be.${{ needs.collect-info.outputs.build_id }}" | |
| else | |
| VERSION="${{ steps.version.outputs.version }}" | |
| fi | |
| dotnet build ${{ matrix.project.path }} -c Release -p:PackageVersion="$VERSION" | |
| - name: Pack | |
| run: | | |
| if [ "${{ needs.collect-info.outputs.build_type }}" == "BleedingEdge" ]; then | |
| VERSION="${{ steps.version.outputs.version }}-be.${{ needs.collect-info.outputs.build_id }}" | |
| else | |
| VERSION="${{ steps.version.outputs.version }}" | |
| fi | |
| dotnet pack ${{ matrix.project.path }} -c Release --no-build -p:PackageVersion="$VERSION" -o ./bin/dist | |
| - name: Upload Artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| path: "./bin/dist/*.nupkg" | |
| name: "${{ matrix.project.name }}_${{ needs.collect-info.outputs.build_type }}_${{ needs.collect-info.outputs.sha_short }}_${{ needs.collect-info.outputs.build_id || 0 }}" | |
| publish: | |
| needs: [collect-info, build] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: ./artifacts | |
| - name: Combine artifacts | |
| run: | | |
| mkdir -p ./bin/dist | |
| find ./artifacts -name "*.nupkg" -exec cp {} ./bin/dist/ \; | |
| - name: Upload Combined Artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| path: "./bin/dist/*.nupkg" | |
| name: "BepInEx_Templates_CI_${{ needs.collect-info.outputs.build_type }}_${{ needs.collect-info.outputs.sha_short }}_${{ needs.collect-info.outputs.build_id || 0 }}" | |
| - name: Publish to GitHub Packages | |
| if: ${{ needs.collect-info.outputs.build_type == 'BleedingEdge' }} | |
| run: | | |
| dotnet nuget push ./bin/dist/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://nuget-modding.resonite.net/v3/index.json --skip-duplicate |