diff --git a/.github/workflows/release-win7.yml b/.github/workflows/release-win7.yml index 8313e2f1..73c240ff 100644 --- a/.github/workflows/release-win7.yml +++ b/.github/workflows/release-win7.yml @@ -14,21 +14,49 @@ on: branches: - main paths: - - "**/*.go" + # - "**/*.go" - "go.mod" - "go.sum" - ".github/workflows/release-win7.yml" pull_request: types: [opened, synchronize, reopened] paths: - - "**/*.go" + # - "**/*.go" - "go.mod" - "go.sum" - ".github/workflows/release-win7.yml" + jobs: prepare: runs-on: ubuntu-latest steps: + - name: Set up Go compiler + uses: actions/setup-go@v5 + with: + go-version: 'stable' + check-latest: true + + - name: Download patched Go + uses: actions/checkout@v4 + with: + # To change the repository of toolchail, change it here + repository: 'MetaCubeX/go' + ref: 'release-branch.go1.23' + + - name: Build patched Go + run: | + cd ./src + . ./all.bash + cd ../ + mkdir -p patched-go + rsync -a --exclude 'patched-go' ./ 'patched-go' + + - name: Save patched builder + uses: actions/cache/save@v4 + with: + path: patched-go + key: xray-patched-go-${{ github.sha }}-${{ github.run_number }} + - name: Restore Cache uses: actions/cache/restore@v4 with: @@ -75,71 +103,55 @@ jobs: contents: write strategy: matrix: - goos: [""] - goarch: [""] - gotoolchain-ref: [""] - gotoolchain-branch: [""] - assetname: [""] include: # BEGIN Windows 7 - goos: windows goarch: amd64 - gotoolchain-ref: 'MetaCubeX/go' - gotoolchain-branch: release-branch.go1.23 assetname: win7-64 - goos: windows goarch: 386 - gotoolchain-ref: 'MetaCubeX/go' - gotoolchain-branch: release-branch.go1.23 assetname: win7-32 # END Windows 7 fail-fast: false runs-on: ubuntu-latest env: - GOOS: ${{ matrix.goos }} + GOOS: ${{ matrix.goos}} GOARCH: ${{ matrix.goarch }} CGO_ENABLED: 0 steps: - name: Show workflow information run: | _NAME=${{ matrix.assetname }} - echo "GOOS: $GOOS, GOARCH: $GOARCH, RELEASE_NAME: $_NAME" + echo "GOOS: ${{ matrix.goos }}, GOARCH: ${{ matrix.goarch }}, RELEASE_NAME: $_NAME" echo "ASSET_NAME=$_NAME" >> $GITHUB_ENV - - name: Set up Go compiler - uses: actions/setup-go@v5 - with: - go-version: 'latest' - - - name: Prepare patched Go source directory - run: | - mkdir patched-go - cd patched-go - - - name: Download patched Go - uses: actions/checkout@v4 - with: - repository: ${{ matrix.gotoolchain-ref }} - ref: ${{ matrix.gotoolchain-branch }} - - - name: Build patched Go - run: | - cd src - ./all.bash - cd ../.. - - name: Checkout codebase uses: actions/checkout@v4 + + - name: Restore Go builder + uses: actions/cache/restore@v4 + with: + path: patched-go + key: xray-patched-go-${{ github.sha }}-${{ github.run_number }} - - name: Get project dependencies - run: go mod download - - - name: Build Xray + - name: Download dependencies and build Xray run: | + echo "Setup environment..." + export PATH=$PATH:$PWD/patched-go/bin + ./patched-go/bin/go version + ./patched-go/bin/go env -w GOPATH=$PWD + ./patched-go/bin/go env -w GOROOT=$PWD/patched-go + echo "Download dependencies..." + ./patched-go/bin/go mod download + echo "Build Xray..." mkdir -p build_assets - make - find . -maxdepth 1 -type f -regex './\(wxray\|xray\|xray_softfloat\)\(\|.exe\)' -exec mv {} ./build_assets/ \; + ./patched-go/bin/go clean -v -i $PWD + rm -f xray xray.exe wxray.exe xray_softfloat + ./patched-go/bin/go build -o xray.exe -trimpath -ldflags "-s -w -buildid=" -v ./main + ./patched-go/bin/go build -o wxray.exe -trimpath -ldflags "-H windowsgui -s -w -buildid=" -v ./main + echo "Build completed." + find . -maxdepth 1 -type f -regex './\(wxray\|xray\).exe' -exec mv {} ./build_assets/ \; - name: Restore Cache uses: actions/cache/restore@v4