release-win7.yml 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. name: Build and Release for Windows 7
  2. # NOTE: This Github Actions file depends on the Makefile.
  3. # Building the correct package requires the correct binaries generated by the Makefile. To
  4. # ensure the correct output, the Makefile must accept the appropriate input and compile the
  5. # correct file with the correct name. If you need to modify this file, please ensure it won't
  6. # disrupt the Makefile.
  7. on:
  8. workflow_dispatch:
  9. release:
  10. types: [published]
  11. push:
  12. pull_request:
  13. types: [opened, synchronize, reopened]
  14. jobs:
  15. build:
  16. permissions:
  17. contents: write
  18. strategy:
  19. matrix:
  20. include:
  21. # BEGIN Windows 7
  22. - goos: windows
  23. goarch: amd64
  24. assetname: win7-64
  25. - goos: windows
  26. goarch: 386
  27. assetname: win7-32
  28. # END Windows 7
  29. fail-fast: false
  30. runs-on: ubuntu-latest
  31. env:
  32. GOOS: ${{ matrix.goos}}
  33. GOARCH: ${{ matrix.goarch }}
  34. CGO_ENABLED: 0
  35. steps:
  36. - name: Show workflow information
  37. run: |
  38. _NAME=${{ matrix.assetname }}
  39. echo "GOOS: ${{ matrix.goos }}, GOARCH: ${{ matrix.goarch }}, RELEASE_NAME: $_NAME"
  40. echo "ASSET_NAME=$_NAME" >> $GITHUB_ENV
  41. - name: Set up Go
  42. uses: actions/setup-go@v5
  43. with:
  44. go-version: stable
  45. check-latest: true
  46. - name: Setup patched builder
  47. run: |
  48. GOSDK=$(go env GOROOT)
  49. curl -O -L https://github.com/XTLS/go-win7/releases/latest/download/go-for-win7-linux-amd64.zip
  50. rm -r $GOSDK/*
  51. unzip ./go-for-win7-linux-amd64.zip -d $GOSDK
  52. - name: Checkout codebase
  53. uses: actions/checkout@v4
  54. - name: Get project dependencies
  55. run: go mod download
  56. - name: Build Xray
  57. run: |
  58. mkdir -p build_assets
  59. make
  60. find . -maxdepth 1 -type f -regex './\(wxray\|xray\).exe' -exec mv {} ./build_assets/ \;
  61. - name: Restore Geodat Cache
  62. uses: actions/cache/restore@v4
  63. with:
  64. path: resources
  65. key: xray-geodat-
  66. - name: Copy README.md & LICENSE
  67. run: |
  68. mv -f resources/* build_assets
  69. cp ${GITHUB_WORKSPACE}/README.md ./build_assets/README.md
  70. cp ${GITHUB_WORKSPACE}/LICENSE ./build_assets/LICENSE
  71. - name: Create ZIP archive
  72. if: github.event_name == 'release'
  73. shell: bash
  74. run: |
  75. pushd build_assets || exit 1
  76. touch -mt $(date +%Y01010000) *
  77. zip -9vr ../Xray-${{ env.ASSET_NAME }}.zip .
  78. popd || exit 1
  79. FILE=./Xray-${{ env.ASSET_NAME }}.zip
  80. DGST=$FILE.dgst
  81. for METHOD in {"md5","sha1","sha256","sha512"}
  82. do
  83. openssl dgst -$METHOD $FILE | sed 's/([^)]*)//g' >>$DGST
  84. done
  85. - name: Change the name
  86. run: |
  87. mv build_assets Xray-${{ env.ASSET_NAME }}
  88. - name: Upload files to Artifacts
  89. uses: actions/upload-artifact@v4
  90. with:
  91. name: Xray-${{ env.ASSET_NAME }}
  92. path: |
  93. ./Xray-${{ env.ASSET_NAME }}/*
  94. - name: Upload binaries to release
  95. uses: svenstaro/upload-release-action@v2
  96. if: github.event_name == 'release'
  97. with:
  98. repo_token: ${{ secrets.GITHUB_TOKEN }}
  99. file: ./Xray-${{ env.ASSET_NAME }}.zip*
  100. tag: ${{ github.ref }}
  101. file_glob: true