build.yml 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. name: Build
  2. on:
  3. push:
  4. paths:
  5. - 'Plain Craft Launcher 2/**'
  6. - '.github/workflows/**'
  7. pull_request:
  8. paths:
  9. - 'Plain Craft Launcher 2/**'
  10. - '.github/workflows/**'
  11. workflow_dispatch:
  12. inputs:
  13. Release:
  14. description: 'Release'
  15. required: true
  16. type: boolean
  17. jobs:
  18. build:
  19. strategy:
  20. matrix:
  21. configuration: [Debug]
  22. runs-on: windows-latest
  23. steps:
  24. - name: Checkout
  25. uses: actions/checkout@v4
  26. with:
  27. fetch-depth: 0
  28. - name: Set Describe
  29. shell: bash
  30. run: |
  31. Describe=`git describe --tags --always`
  32. echo "Describe=$Describe" >> $GITHUB_ENV
  33. - name: Setup MSBuild.exe
  34. uses: microsoft/setup-msbuild@v2
  35. with:
  36. msbuild-architecture: x64
  37. - name: Replace
  38. shell: powershell
  39. run: |
  40. (gc "Plain Craft Launcher 2\Modules\Minecraft\ModLaunch.vb") -replace 'Dim ClientId As String = ""', 'Dim ClientId As String = "${{ secrets.CLIENT_ID }}"' | Out-File "Plain Craft Launcher 2\Modules\Minecraft\ModLaunch.vb"
  41. (gc "Plain Craft Launcher 2\Modules\ModSecret.vb") -replace 'Client.Headers\("x-api-key"\) = ""', 'Client.Headers("x-api-key") = "${{ secrets.X_API_KEY }}"' | Out-File "Plain Craft Launcher 2\Modules\ModSecret.vb"
  42. (gc "Plain Craft Launcher 2\Modules\ModSecret.vb") -replace 'Request.Headers\("x-api-key"\) = ""', 'Request.Headers("x-api-key") = "${{ secrets.X_API_KEY }}"' | Out-File "Plain Craft Launcher 2\Modules\ModSecret.vb"
  43. - name: Build
  44. run: msbuild "Plain Craft Launcher 2\Plain Craft Launcher 2.vbproj" -p:Configuration=${{ matrix.configuration }}
  45. - name: Upload a Build Artifact
  46. uses: actions/upload-artifact@v4
  47. with:
  48. name: ${{ matrix.configuration }} ${{ env.Describe }}
  49. path: Plain Craft Launcher 2\obj\${{ matrix.configuration }}\Plain Craft Launcher 2.exe
  50. - name: Create Release
  51. if: ${{ inputs.Release }}
  52. id: create_release
  53. uses: actions/create-release@latest
  54. env:
  55. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  56. with:
  57. tag_name: ${{ env.Describe }}
  58. release_name: ${{ env.Describe }}
  59. - name: Upload Release Asset
  60. if: ${{ inputs.Release }}
  61. id: upload-release-asset
  62. uses: actions/upload-release-asset@latest
  63. env:
  64. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  65. with:
  66. upload_url: ${{ steps.create_release.outputs.upload_url }}
  67. asset_path: Plain Craft Launcher 2\obj\${{ matrix.configuration }}\Plain Craft Launcher 2.exe
  68. asset_name: ${{ matrix.configuration }} ${{ env.Describe }}.exe
  69. asset_content_type: application/octet-stream