build.yml 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. configuration:
  14. description: 'Configuration'
  15. default: 'Debug'
  16. type: string
  17. replace:
  18. description: 'Replace'
  19. default: true
  20. type: boolean
  21. release:
  22. description: 'Release'
  23. type: boolean
  24. jobs:
  25. build:
  26. name: Build
  27. runs-on: windows-latest
  28. steps:
  29. - name: Checkout
  30. uses: actions/checkout@v4
  31. with:
  32. fetch-depth: 0
  33. - name: Set Describe
  34. shell: bash
  35. run: |
  36. describe=`git describe --tags --always`
  37. echo "describe=$describe" >> $GITHUB_ENV
  38. - name: Setup MSBuild.exe
  39. uses: microsoft/setup-msbuild@v2
  40. with:
  41. msbuild-architecture: x64
  42. - name: Replace
  43. if: ${{ inputs.replace }}
  44. shell: powershell
  45. run: |
  46. (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"
  47. (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"
  48. (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"
  49. - name: Build
  50. run: msbuild "Plain Craft Launcher 2\Plain Craft Launcher 2.vbproj" -p:Configuration=${{ inputs.configuration }}
  51. - name: Upload a Build Artifact
  52. uses: actions/upload-artifact@v4
  53. with:
  54. name: ${{ inputs.configuration }} ${{ env.describe }}
  55. path: Plain Craft Launcher 2\obj\${{ inputs.configuration }}\Plain Craft Launcher 2.exe
  56. - name: Release
  57. if: ${{ inputs.Release }}
  58. uses: softprops/action-gh-release@v2
  59. env:
  60. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  61. with:
  62. name: ${{ env.describe }}
  63. tag_name: ${{ env.describe }}
  64. files: Plain Craft Launcher 2\obj\${{ inputs.configuration }}\Plain Craft Launcher 2.exe