create-release.yml 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. ################################################################################
  2. ### Build MonoGame.Extended (Release)
  3. ### Performs a build, test, then pack of the Monogame.Extended source code
  4. ### from a specified branch or release tag. Once the build job is finished,
  5. ### the deploy job will upload the nupkg files to NuGet.
  6. ###
  7. ### - Can be triggered manually with workflow_dispatch
  8. ### - Allows specifying a branch (defaults to develop)
  9. ### - Allows specifying a release tag (overrides branch if provided)
  10. ### - Supports both stable and preview builds
  11. ################################################################################
  12. name: "Create Release"
  13. on:
  14. workflow_dispatch:
  15. inputs:
  16. branch:
  17. description: 'Branch to build from (e.g., develop, v5.3.2-preview-1). Ignored if release-tag is provided.'
  18. required: false
  19. type: string
  20. default: 'develop'
  21. release-tag:
  22. description: 'Release tag to build from (e.g., v5.3.1). Overrides branch if provided.'
  23. required: false
  24. type: string
  25. default: ''
  26. build-type:
  27. description: 'Build type (Stable or Preview)'
  28. required: true
  29. type: choice
  30. options:
  31. - Stable
  32. - Preview
  33. default: 'Stable'
  34. preview-label:
  35. description: 'Preview label (e.g., preview.1, alpha.1). Only used for Preview builds.'
  36. required: false
  37. type: string
  38. default: 'preview.1'
  39. monogame-version:
  40. description: 'MonoGame version to target. Leave empty to use defaults (3.8.4 for Stable, 3.8.5.-preview.# for Preview).'
  41. required: false
  42. type: string
  43. default: ''
  44. jobs:
  45. build:
  46. name: "Build MonoGame.Extended"
  47. runs-on: ubuntu-latest
  48. steps:
  49. - name: Clone Repository
  50. uses: actions/checkout@v4
  51. with:
  52. ref: ${{ inputs.release-tag != '' && inputs.release-tag || inputs.branch }}
  53. - name: Setup Dotnet
  54. uses: actions/setup-dotnet@v4
  55. with:
  56. dotnet-version: 8.0.x
  57. - name: Setup xvfb
  58. run: |
  59. sudo apt-get update
  60. sudo apt-get install -y xvfb
  61. - name: Build MonoGame.Extended (Stable)
  62. if: ${{ inputs.build-type == 'Stable' }}
  63. run: |
  64. BUILD_ARGS="--nologo --verbosity minimal --configuration Release"
  65. if [ -n "${{ inputs.monogame-version }}" ]; then
  66. BUILD_ARGS="$BUILD_ARGS -p:MonoGameVersion=${{ inputs.monogame-version }}"
  67. fi
  68. dotnet build MonoGame.Extended.sln $BUILD_ARGS
  69. - name: Build MonoGame.Extended (Preview)
  70. if: ${{ inputs.build-type == 'Preview' }}
  71. run: |
  72. BUILD_ARGS="--nologo --verbosity minimal --configuration Release -p:IsPreviewBuild=true -p:PreviewLabel=${{ inputs.preview-label }}"
  73. if [ -n "${{ inputs.monogame-version }}" ]; then
  74. BUILD_ARGS="$BUILD_ARGS -p:MonoGameVersion=${{ inputs.monogame-version }}"
  75. fi
  76. dotnet build MonoGame.Extended.sln $BUILD_ARGS
  77. - name: Test MonoGame.Extended (Stable)
  78. if: ${{ inputs.build-type == 'Stable' }}
  79. run: |
  80. TEST_ARGS="--nologo --verbosity minimal --configuration Release"
  81. if [ -n "${{ inputs.monogame-version }}" ]; then
  82. TEST_ARGS="$TEST_ARGS -p:MonoGameVersion=${{ inputs.monogame-version }}"
  83. fi
  84. xvfb-run -a -s "-screen 0 1024x768x24" dotnet test MonoGame.Extended.sln $TEST_ARGS
  85. - name: Test MonoGame.Extended (Preview)
  86. if: ${{ inputs.build-type == 'Preview' }}
  87. run: |
  88. TEST_ARGS="--nologo --verbosity minimal --configuration Release -p:IsPreviewBuild=true -p:PreviewLabel=${{ inputs.preview-label }}"
  89. if [ -n "${{ inputs.monogame-version }}" ]; then
  90. TEST_ARGS="$TEST_ARGS -p:MonoGameVersion=${{ inputs.monogame-version }}"
  91. fi
  92. xvfb-run -a -s "-screen 0 1024x768x24" dotnet test MonoGame.Extended.sln $TEST_ARGS
  93. - name: Pack MonoGame.Extended (Stable)
  94. if: ${{ inputs.build-type == 'Stable' }}
  95. run: |
  96. PACK_ARGS="--nologo --verbosity minimal --configuration Release"
  97. if [ -n "${{ inputs.monogame-version }}" ]; then
  98. PACK_ARGS="$PACK_ARGS -p:MonoGameVersion=${{ inputs.monogame-version }}"
  99. fi
  100. dotnet pack MonoGame.Extended.sln $PACK_ARGS
  101. - name: Pack MonoGame.Extended (Preview)
  102. if: ${{ inputs.build-type == 'Preview' }}
  103. run: |
  104. PACK_ARGS="--nologo --verbosity minimal --configuration Release -p:IsPreviewBuild=true -p:PreviewLabel=${{ inputs.preview-label }}"
  105. if [ -n "${{ inputs.monogame-version }}" ]; then
  106. PACK_ARGS="$PACK_ARGS -p:MonoGameVersion=${{ inputs.monogame-version }}"
  107. fi
  108. dotnet pack MonoGame.Extended.sln $PACK_ARGS
  109. - name: Pack Kni.Extended (Stable)
  110. if: ${{ inputs.build-type == 'Stable' }}
  111. run: |
  112. PACK_ARGS="--nologo --verbosity minimal --configuration Release"
  113. if [ -n "${{ inputs.monogame-version }}" ]; then
  114. PACK_ARGS="$PACK_ARGS -p:MonoGameVersion=${{ inputs.monogame-version }}"
  115. fi
  116. dotnet pack KNI.Extended.sln $PACK_ARGS
  117. - name: Pack Kni.Extended (Preview)
  118. if: ${{ inputs.build-type == 'Preview' }}
  119. run: |
  120. PACK_ARGS="--nologo --verbosity minimal --configuration Release -p:IsPreviewBuild=true -p:PreviewLabel=${{ inputs.preview-label }}"
  121. if [ -n "${{ inputs.monogame-version }}" ]; then
  122. PACK_ARGS="$PACK_ARGS -p:MonoGameVersion=${{ inputs.monogame-version }}"
  123. fi
  124. dotnet pack KNI.Extended.sln $PACK_ARGS
  125. - name: Upload Artifacts
  126. uses: actions/upload-artifact@v4
  127. with:
  128. name: build-artifacts
  129. path: ./.artifacts/source/package/release/*.nupkg
  130. deploy:
  131. name: "Deploy NuGets"
  132. runs-on: ubuntu-latest
  133. needs: [ build ]
  134. permissions:
  135. contents: write
  136. steps:
  137. - name: "Download Artifacts"
  138. uses: actions/download-artifact@v4
  139. with:
  140. name: build-artifacts
  141. path: ./.artifacts
  142. - name: "Push Packages to NuGet"
  143. env:
  144. NUGET_API_KEY: ${{ secrets.NUGET_ACCESS_TOKEN }}
  145. run: |
  146. PACKAGES=(".artifacts/*.nupkg")
  147. for PACKAGE in "${PACKAGES[@]}"; do
  148. dotnet nuget push "$PACKAGE" --source https://api.nuget.org/v3/index.json --skip-duplicate --api-key "$NUGET_API_KEY"
  149. done