release-win7.yml 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. name: Build and Release for Windows 7
  2. on:
  3. workflow_dispatch:
  4. release:
  5. types: [published]
  6. push:
  7. pull_request:
  8. types: [opened, synchronize, reopened]
  9. jobs:
  10. build:
  11. permissions:
  12. contents: write
  13. strategy:
  14. matrix:
  15. include:
  16. # BEGIN Windows 7
  17. - goos: windows
  18. goarch: amd64
  19. assetname: win7-64
  20. - goos: windows
  21. goarch: 386
  22. assetname: win7-32
  23. # END Windows 7
  24. fail-fast: false
  25. runs-on: ubuntu-latest
  26. env:
  27. GOOS: ${{ matrix.goos}}
  28. GOARCH: ${{ matrix.goarch }}
  29. CGO_ENABLED: 0
  30. steps:
  31. - name: Checkout codebase
  32. uses: actions/checkout@v4
  33. - name: Show workflow information
  34. run: |
  35. _NAME=${{ matrix.assetname }}
  36. echo "GOOS: ${{ matrix.goos }}, GOARCH: ${{ matrix.goarch }}, RELEASE_NAME: $_NAME"
  37. echo "ASSET_NAME=$_NAME" >> $GITHUB_ENV
  38. - name: Set up Go
  39. uses: actions/setup-go@v5
  40. with:
  41. go-version-file: go.mod
  42. check-latest: true
  43. - name: Setup patched builder
  44. run: |
  45. GOSDK=$(go env GOROOT)
  46. rm -r $GOSDK/*
  47. cd $GOSDK
  48. curl -O -L https://github.com/XTLS/go-win7/releases/latest/download/go-for-win7-linux-amd64.zip
  49. unzip ./go-for-win7-linux-amd64.zip -d $GOSDK
  50. rm ./go-for-win7-linux-amd64.zip
  51. - name: Get project dependencies
  52. run: go mod download
  53. - name: Build Xray
  54. run: |
  55. mkdir -p build_assets
  56. COMMID=$(git describe --always --dirty)
  57. echo 'Building Xray for Windows 7...'
  58. go build -o build_assets/xray.exe -trimpath -buildvcs=false -ldflags="-X github.com/xtls/xray-core/core.build=${COMMID} -s -w -buildid=" -v ./main
  59. echo 'CreateObject("Wscript.Shell").Run "xray.exe -config config.json",0' > build_assets/xray_no_window.vbs
  60. echo 'Start-Process -FilePath ".\xray.exe" -ArgumentList "-config .\config.json" -WindowStyle Hidden' > build_assets/xray_no_window.ps1
  61. # The line below is for without running conhost.exe version. Commented for not being used. Provided for reference.
  62. # go build -o build_assets/wxray.exe -trimpath -buildvcs=false -ldflags="-H windowsgui -X github.com/xtls/xray-core/core.build=${COMMID} -s -w -buildid=" -v ./main
  63. - name: Restore Geodat Cache
  64. uses: actions/cache/restore@v4
  65. with:
  66. path: resources
  67. key: xray-geodat-
  68. - name: Copy README.md & LICENSE
  69. run: |
  70. mv -f resources/* build_assets
  71. cp ${GITHUB_WORKSPACE}/README.md ./build_assets/README.md
  72. cp ${GITHUB_WORKSPACE}/LICENSE ./build_assets/LICENSE
  73. - name: Create ZIP archive
  74. if: github.event_name == 'release'
  75. shell: bash
  76. run: |
  77. pushd build_assets || exit 1
  78. touch -mt $(date +%Y01010000) *
  79. zip -9vr ../Xray-${{ env.ASSET_NAME }}.zip .
  80. popd || exit 1
  81. FILE=./Xray-${{ env.ASSET_NAME }}.zip
  82. DGST=$FILE.dgst
  83. for METHOD in {"md5","sha1","sha256","sha512"}
  84. do
  85. openssl dgst -$METHOD $FILE | sed 's/([^)]*)//g' >>$DGST
  86. done
  87. - name: Change the name
  88. run: |
  89. mv build_assets Xray-${{ env.ASSET_NAME }}
  90. - name: Upload files to Artifacts
  91. uses: actions/upload-artifact@v4
  92. with:
  93. name: Xray-${{ env.ASSET_NAME }}
  94. path: |
  95. ./Xray-${{ env.ASSET_NAME }}/*
  96. - name: Upload binaries to release
  97. uses: svenstaro/upload-release-action@v2
  98. if: github.event_name == 'release'
  99. with:
  100. repo_token: ${{ secrets.GITHUB_TOKEN }}
  101. file: ./Xray-${{ env.ASSET_NAME }}.zip*
  102. tag: ${{ github.ref }}
  103. file_glob: true