1
0

build.yml 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. name: Build Release
  2. on:
  3. push:
  4. tags:
  5. - "v*"
  6. workflow_dispatch:
  7. jobs:
  8. build:
  9. runs-on: ubuntu-latest
  10. permissions:
  11. contents: write
  12. steps:
  13. - name: Checkout
  14. uses: actions/checkout@v4
  15. - name: Setup .NET
  16. uses: actions/setup-dotnet@v4
  17. with:
  18. dotnet-version: "10.0.x"
  19. - name: Restore
  20. run: dotnet restore
  21. - name: Build
  22. run: dotnet build -c Release --no-restore
  23. - name: Test
  24. run: dotnet test tests/WeaponCrossModding.Tests/WeaponCrossModding.Tests.csproj -c Release
  25. - name: Validate build output
  26. run: |
  27. test -f bin/Release/WeaponCrossModding.dll || exit 1
  28. echo "Built WeaponCrossModding.dll"
  29. - name: Compute mod version
  30. id: version
  31. run: |
  32. VER=$(grep -oP '(?<=<Version>)[^<]+' WeaponCrossModding.csproj)
  33. echo "version=$VER" >> "$GITHUB_OUTPUT"
  34. - name: Package mod as SPT-ready zip
  35. run: |
  36. VER="${{ steps.version.outputs.version }}"
  37. STAGE="staging"
  38. # 4.1.x 把 mod 根目录从 SPT/ 改为 SPT_Runtime/,且新数据不向后兼容。
  39. mkdir -p "$STAGE/SPT_Runtime/user/mods/WeaponCrossModding"
  40. cp bin/Release/WeaponCrossModding.dll "$STAGE/SPT_Runtime/user/mods/WeaponCrossModding/"
  41. cd "$STAGE"
  42. ZIP_NAME="WeaponCrossModding-v${VER}.zip"
  43. mkdir -p ../dist
  44. zip -r "../dist/${ZIP_NAME}" SPT_Runtime
  45. cd ..
  46. echo "Packed dist/${ZIP_NAME}"
  47. ls -lh dist/
  48. - name: Upload artifact
  49. uses: actions/upload-artifact@v4
  50. with:
  51. name: WeaponCrossModding-v${{ steps.version.outputs.version }}
  52. path: dist/*.zip
  53. - name: Create Release
  54. if: startsWith(github.ref, 'refs/tags/')
  55. uses: softprops/action-gh-release@v2
  56. with:
  57. files: dist/*.zip
  58. generate_release_notes: true