################################################################################ ### Build MonoGame.Extended (Release) ### Performs a build, test, then pack of the Monogame.Extended source code ### from a specified branch or release tag. Once the build job is finished, ### the deploy job will upload the nupkg files to NuGet. ### ### - Can be triggered manually with workflow_dispatch ### - Allows specifying a branch (defaults to develop) ### - Allows specifying a release tag (overrides branch if provided) ### - Supports both stable and preview builds ################################################################################ name: "Create Release" on: workflow_dispatch: inputs: branch: description: 'Branch to build from (e.g., develop, v5.3.2-preview-1). Ignored if release-tag is provided.' required: false type: string default: 'develop' release-tag: description: 'Release tag to build from (e.g., v5.3.1). Overrides branch if provided.' required: false type: string default: '' build-type: description: 'Build type (Stable or Preview)' required: true type: choice options: - Stable - Preview default: 'Stable' preview-label: description: 'Preview label (e.g., preview.1, alpha.1). Only used for Preview builds.' required: false type: string default: 'preview.1' monogame-version: description: 'MonoGame version to target. Leave empty to use defaults (3.8.4 for Stable, 3.8.5.-preview.# for Preview).' required: false type: string default: '' jobs: build: name: "Build MonoGame.Extended" runs-on: ubuntu-latest steps: - name: Clone Repository uses: actions/checkout@v4 with: ref: ${{ inputs.release-tag != '' && inputs.release-tag || inputs.branch }} - name: Setup Dotnet uses: actions/setup-dotnet@v4 with: dotnet-version: 8.0.x - name: Setup xvfb run: | sudo apt-get update sudo apt-get install -y xvfb - name: Build MonoGame.Extended (Stable) if: ${{ inputs.build-type == 'Stable' }} run: | BUILD_ARGS="--nologo --verbosity minimal --configuration Release" if [ -n "${{ inputs.monogame-version }}" ]; then BUILD_ARGS="$BUILD_ARGS -p:MonoGameVersion=${{ inputs.monogame-version }}" fi dotnet build MonoGame.Extended.sln $BUILD_ARGS - name: Build MonoGame.Extended (Preview) if: ${{ inputs.build-type == 'Preview' }} run: | BUILD_ARGS="--nologo --verbosity minimal --configuration Release -p:IsPreviewBuild=true -p:PreviewLabel=${{ inputs.preview-label }}" if [ -n "${{ inputs.monogame-version }}" ]; then BUILD_ARGS="$BUILD_ARGS -p:MonoGameVersion=${{ inputs.monogame-version }}" fi dotnet build MonoGame.Extended.sln $BUILD_ARGS - name: Test MonoGame.Extended (Stable) if: ${{ inputs.build-type == 'Stable' }} run: | TEST_ARGS="--nologo --verbosity minimal --configuration Release" if [ -n "${{ inputs.monogame-version }}" ]; then TEST_ARGS="$TEST_ARGS -p:MonoGameVersion=${{ inputs.monogame-version }}" fi xvfb-run -a -s "-screen 0 1024x768x24" dotnet test MonoGame.Extended.sln $TEST_ARGS - name: Test MonoGame.Extended (Preview) if: ${{ inputs.build-type == 'Preview' }} run: | TEST_ARGS="--nologo --verbosity minimal --configuration Release -p:IsPreviewBuild=true -p:PreviewLabel=${{ inputs.preview-label }}" if [ -n "${{ inputs.monogame-version }}" ]; then TEST_ARGS="$TEST_ARGS -p:MonoGameVersion=${{ inputs.monogame-version }}" fi xvfb-run -a -s "-screen 0 1024x768x24" dotnet test MonoGame.Extended.sln $TEST_ARGS - name: Pack MonoGame.Extended (Stable) if: ${{ inputs.build-type == 'Stable' }} run: | PACK_ARGS="--nologo --verbosity minimal --configuration Release" if [ -n "${{ inputs.monogame-version }}" ]; then PACK_ARGS="$PACK_ARGS -p:MonoGameVersion=${{ inputs.monogame-version }}" fi dotnet pack MonoGame.Extended.sln $PACK_ARGS - name: Pack MonoGame.Extended (Preview) if: ${{ inputs.build-type == 'Preview' }} run: | PACK_ARGS="--nologo --verbosity minimal --configuration Release -p:IsPreviewBuild=true -p:PreviewLabel=${{ inputs.preview-label }}" if [ -n "${{ inputs.monogame-version }}" ]; then PACK_ARGS="$PACK_ARGS -p:MonoGameVersion=${{ inputs.monogame-version }}" fi dotnet pack MonoGame.Extended.sln $PACK_ARGS - name: Pack Kni.Extended (Stable) if: ${{ inputs.build-type == 'Stable' }} run: | PACK_ARGS="--nologo --verbosity minimal --configuration Release" if [ -n "${{ inputs.monogame-version }}" ]; then PACK_ARGS="$PACK_ARGS -p:MonoGameVersion=${{ inputs.monogame-version }}" fi dotnet pack KNI.Extended.sln $PACK_ARGS - name: Pack Kni.Extended (Preview) if: ${{ inputs.build-type == 'Preview' }} run: | PACK_ARGS="--nologo --verbosity minimal --configuration Release -p:IsPreviewBuild=true -p:PreviewLabel=${{ inputs.preview-label }}" if [ -n "${{ inputs.monogame-version }}" ]; then PACK_ARGS="$PACK_ARGS -p:MonoGameVersion=${{ inputs.monogame-version }}" fi dotnet pack KNI.Extended.sln $PACK_ARGS - name: Upload Artifacts uses: actions/upload-artifact@v4 with: name: build-artifacts path: ./.artifacts/source/package/release/*.nupkg deploy: name: "Deploy NuGets" runs-on: ubuntu-latest needs: [ build ] permissions: contents: write steps: - name: "Download Artifacts" uses: actions/download-artifact@v4 with: name: build-artifacts path: ./.artifacts - name: "Push Packages to NuGet" env: NUGET_API_KEY: ${{ secrets.NUGET_ACCESS_TOKEN }} run: | PACKAGES=(".artifacts/*.nupkg") for PACKAGE in "${PACKAGES[@]}"; do dotnet nuget push "$PACKAGE" --source https://api.nuget.org/v3/index.json --skip-duplicate --api-key "$NUGET_API_KEY" done