create-release.yml 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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: Build MonoGame.Extended
  43. run: dotnet build MonoGame.Extended.sln --nologo --verbosity minimal --configuration Release
  44. - name: Test MonoGame.Extended
  45. run: dotnet test MonoGame.Extended.sln --nologo --verbosity minimal --configuration Release
  46. - name: Pack MonoGame.Extended
  47. run: dotnet pack MonoGame.Extended.sln --nologo --verbosity minimal --configuration Release
  48. - name: Pack Kni.Extended
  49. run: dotnet pack KNI.Extended.sln --nologo --verbosity minimal --configuration Release
  50. - name: Upload Artifacts
  51. uses: actions/upload-artifact@v4
  52. with:
  53. name: build-artifacts
  54. path: ./.artifacts/source/package/release/*.nupkg
  55. deploy:
  56. name: "Deploy NuGets"
  57. runs-on: ubuntu-latest
  58. needs: [ build ]
  59. permissions:
  60. packages: write
  61. contents: write
  62. steps:
  63. - name: "Download Artifacts"
  64. uses: actions/download-artifact@v4
  65. with:
  66. name: build-artifacts
  67. path: ./.artifacts
  68. - name: "Push Packages"
  69. env:
  70. 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' }}
  71. API_KEY: ${{ inputs.source-feed == 'GitHub' && secrets.GITHUB_TOKEN || inputs.source-feed == 'NuGet' && secrets.NUGET_ACCESS_TOKEN }}
  72. run: |
  73. PACKAGES=(".artifacts/*.nupkg")
  74. for PACKAGE in "${PACKAGES[@]}"; do
  75. dotnet nuget push "$PACKAGE" --source "$SOURCE_URL" --skip-duplicate --api-key "$API_KEY"
  76. done