build.yml 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. jobs:
  13. build:
  14. name: Build
  15. runs-on: windows-latest
  16. strategy:
  17. matrix:
  18. configuration: [Debug, Release]
  19. steps:
  20. - name: Checkout
  21. uses: actions/checkout@v4
  22. with:
  23. fetch-depth: 0
  24. - name: Set Describe
  25. shell: bash
  26. run: |
  27. describe=`git describe --tags --always`
  28. echo "describe=$describe" >> $GITHUB_ENV
  29. - name: Setup MSBuild.exe
  30. uses: microsoft/setup-msbuild@v2
  31. with:
  32. msbuild-architecture: x64
  33. - name: Update Help
  34. run: |
  35. # 切换到上一级目录,免得混在一起
  36. Set-Location ..
  37. # 检出远程仓库的 master 分支
  38. git clone https://github.com/LTCatt/PCL2Help.git -b master
  39. # 切换到帮助库的目录
  40. Set-Location PCL2Help
  41. # 删掉无用的文件
  42. Remove-Item -Path *.* -Recurse -Force
  43. # 压缩
  44. Compress-Archive -Path .\* -DestinationPath .\Help.zip
  45. # 覆盖文件
  46. Copy-Item -Path .\Help.zip -Destination "..\PCL2\Plain Craft Launcher 2\Resources\Help.zip" -Force
  47. # 切换到原来的目录进行编译
  48. Set-Location ..\PCL2
  49. - name: Replace
  50. run: |
  51. (gc "Plain Craft Launcher 2\Modules\ModSecret.vb") -replace 'Public Const OAuthClientId As String = ""', 'Public Const OAuthClientId As String = "${{ secrets.CLIENT_ID }}"' | Out-File "Plain Craft Launcher 2\Modules\ModSecret.vb"
  52. (gc "Plain Craft Launcher 2\Modules\ModSecret.vb") -replace 'Public Const CurseForgeAPIKey As String = ""', 'Public Const CurseForgeAPIKey As String = "${{ secrets.CURSEFORGE_API_KEY }}"' | Out-File "Plain Craft Launcher 2\Modules\ModSecret.vb"
  53. (gc "Plain Craft Launcher 2\Modules\Base\ModBase.vb") -replace 'Public Const CommitHash As String = ""', 'Public Const CommitHash As String = "${{ github.sha }}"' | Out-File "Plain Craft Launcher 2\Modules\Base\ModBase.vb"
  54. - name: Build
  55. run: msbuild "Plain Craft Launcher 2\Plain Craft Launcher 2.vbproj" -p:Configuration=${{ matrix.configuration }}
  56. - name: Upload a Build Artifact
  57. uses: actions/upload-artifact@v4
  58. with:
  59. name: ${{ matrix.configuration }} ${{ env.describe }}
  60. path: Plain Craft Launcher 2\obj\${{ matrix.configuration }}\Plain Craft Launcher 2.exe