create-release.yml 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. ################################################################################
  2. ### Build MonoGame.Extended (Release)
  3. ### Clones a specified release tag or the `develop` branch and performs a build,
  4. ### test, then pack of the Monogame.Extended source code. Once the build job is
  5. ### finished, the deploy job will upload the nupkg files created to the specified
  6. ### package source (GitHub or NuGet).
  7. ###
  8. ### - Can be triggered manually with workflow_dispatch
  9. ### - Allows specifying a release tag or defaults to develop branch
  10. ### - Allows choosing between GitHub Packages or NuGet as deployment target
  11. ################################################################################
  12. name: "Create Release"
  13. on:
  14. workflow_dispatch:
  15. inputs:
  16. source-feed:
  17. description: 'Which source feed to publish to?'
  18. required: true
  19. type: choice
  20. options:
  21. - GitHub
  22. - NuGet
  23. default: 'GitHub'
  24. release-tag:
  25. description: 'Release tag to build from (e.g., v1.0.0). Leave empty to use develop branch.'
  26. required: false
  27. type: string
  28. default: ''
  29. jobs:
  30. build:
  31. name: "Build MonoGame.Extended"
  32. runs-on: ubuntu-latest
  33. steps:
  34. - name: Clone Repository
  35. uses: actions/checkout@v4
  36. with:
  37. ref: ${{ inputs.release-tag || 'develop' }}
  38. - name: Setup Dotnet
  39. uses: actions/setup-dotnet@v4
  40. with:
  41. dotnet-version: 8.0.x
  42. - name: Setup xvfb
  43. run: |
  44. sudo apt-get update
  45. sudo apt-get install -y xvfb
  46. - name: Build MonoGame.Extended
  47. run: dotnet build MonoGame.Extended.sln --nologo --verbosity minimal --configuration Release
  48. - name: Test MonoGame.Extended
  49. run: |
  50. xvfb-run -a -s "-screen 0 1024x768x24" dotnet test MonoGame.Extended.sln --nologo --verbosity minimal --configuration Release
  51. - name: Pack MonoGame.Extended
  52. run: dotnet pack MonoGame.Extended.sln --nologo --verbosity minimal --configuration Release
  53. - name: Pack Kni.Extended
  54. run: dotnet pack KNI.Extended.sln --nologo --verbosity minimal --configuration Release
  55. - name: Upload Artifacts
  56. uses: actions/upload-artifact@v4
  57. with:
  58. name: build-artifacts
  59. path: ./.artifacts/source/package/release/*.nupkg
  60. deploy:
  61. name: "Deploy NuGets"
  62. runs-on: ubuntu-latest
  63. needs: [ build ]
  64. permissions:
  65. packages: write
  66. contents: write
  67. steps:
  68. - name: "Download Artifacts"
  69. uses: actions/download-artifact@v4
  70. with:
  71. name: build-artifacts
  72. path: ./.artifacts
  73. - name: "Push Packages"
  74. env:
  75. SOURCE_URL: ${{ inputs.source-feed == 'GitHub' && 'https://nuget.pkg.github.com/craftworkgames/index.json' || inputs.source-feed == 'NuGet' && 'https://api.nuget.org/v3/index.json' }}
  76. API_KEY: ${{ inputs.source-feed == 'GitHub' && secrets.GITHUB_TOKEN || inputs.source-feed == 'NuGet' && secrets.NUGET_ACCESS_TOKEN }}
  77. run: |
  78. PACKAGES=(".artifacts/*.nupkg")
  79. for PACKAGE in "${PACKAGES[@]}"; do
  80. dotnet nuget push "$PACKAGE" --source "$SOURCE_URL" --skip-duplicate --api-key "$API_KEY"
  81. done