github.com/eagleql/xray-core@v1.4.4/.github/workflows/release.yml (about) 1 name: Build and Release 2 3 on: 4 workflow_dispatch: 5 release: 6 types: [published] 7 push: 8 branches: 9 - main 10 paths: 11 - "**/*.go" 12 - "go.mod" 13 - "go.sum" 14 - ".github/workflows/*.yml" 15 pull_request: 16 types: [opened, synchronize, reopened] 17 paths: 18 - "**/*.go" 19 - "go.mod" 20 - "go.sum" 21 - ".github/workflows/*.yml" 22 jobs: 23 build: 24 strategy: 25 matrix: 26 # Include amd64 on all platforms. 27 goos: [windows, freebsd, openbsd, linux, dragonfly, darwin] 28 goarch: [amd64, 386] 29 exclude: 30 # Exclude i386 on darwin and dragonfly. 31 - goarch: 386 32 goos: dragonfly 33 - goarch: 386 34 goos: darwin 35 include: 36 # BEIGIN MacOS ARM64 37 - goos: darwin 38 goarch: arm64 39 # END MacOS ARM64 40 # BEGIN Linux ARM 5 6 7 41 - goos: linux 42 goarch: arm 43 goarm: 7 44 - goos: linux 45 goarch: arm 46 goarm: 6 47 - goos: linux 48 goarch: arm 49 goarm: 5 50 # END Linux ARM 5 6 7 51 # BEGIN Android ARM 8 52 - goos: android 53 goarch: arm64 54 # END Android ARM 8 55 # Windows ARM 7 56 - goos: windows 57 goarch: arm 58 goarm: 7 59 # BEGIN Other architectures 60 # BEGIN riscv64 & ARM64 61 - goos: linux 62 goarch: arm64 63 - goos: linux 64 goarch: riscv64 65 # END riscv64 & ARM64 66 # BEGIN MIPS 67 - goos: linux 68 goarch: mips64 69 - goos: linux 70 goarch: mips64le 71 - goos: linux 72 goarch: mipsle 73 - goos: linux 74 goarch: mips 75 # END MIPS 76 # BEGIN PPC 77 - goos: linux 78 goarch: ppc64 79 - goos: linux 80 goarch: ppc64le 81 # END PPC 82 # BEGIN FreeBSD ARM 83 - goos: freebsd 84 goarch: arm64 85 - goos: freebsd 86 goarch: arm 87 goarm: 7 88 # END FreeBSD ARM 89 # BEGIN S390X 90 - goos: linux 91 goarch: s390x 92 # END S390X 93 # END Other architectures 94 # BEGIN OPENBSD ARM 95 - goos: openbsd 96 goarch: arm64 97 - goos: openbsd 98 goarch: arm 99 goarm: 7 100 # END OPENBSD ARM 101 fail-fast: false 102 103 runs-on: ubuntu-latest 104 env: 105 GOOS: ${{ matrix.goos }} 106 GOARCH: ${{ matrix.goarch }} 107 GOARM: ${{ matrix.goarm }} 108 CGO_ENABLED: 0 109 steps: 110 - name: Checkout codebase 111 uses: actions/checkout@v2 112 113 - name: Show workflow information 114 id: get_filename 115 run: | 116 export _NAME=$(jq ".[\"$GOOS-$GOARCH$GOARM$GOMIPS\"].friendlyName" -r < .github/build/friendly-filenames.json) 117 echo "GOOS: $GOOS, GOARCH: $GOARCH, GOARM: $GOARM, GOMIPS: $GOMIPS, RELEASE_NAME: $_NAME" 118 echo "::set-output name=ASSET_NAME::$_NAME" 119 echo "ASSET_NAME=$_NAME" >> $GITHUB_ENV 120 121 - name: Set up Go 122 uses: actions/setup-go@v2 123 with: 124 go-version: ^1.16 125 126 - name: Get project dependencies 127 run: go mod download 128 129 - name: Replace Custom to Commit ID 130 if: github.event_name != 'release' 131 run: | 132 ID=$(git rev-parse --short ${{ github.sha }}) 133 if [ "${{ github.event_name }}" == 'pull_request' ] 134 then 135 ID=$(git rev-parse --short ${{ github.event.pull_request.head.sha }}) 136 fi 137 sed -i '/build/ s/Custom/'$ID'/' ./core/core.go 138 139 - name: Build Xray 140 run: | 141 mkdir -p build_assets 142 go build -v -o build_assets/xray -trimpath -ldflags "-s -w -buildid=" ./main 143 144 - name: Build Mips softfloat Xray 145 if: matrix.goarch == 'mips' || matrix.goarch == 'mipsle' 146 run: | 147 GOMIPS=softfloat go build -v -o build_assets/xray_softfloat -trimpath -ldflags "-s -w -buildid=" ./main 148 149 - name: Rename Windows Xray 150 if: matrix.goos == 'windows' 151 run: | 152 cd ./build_assets || exit 1 153 mv xray xray.exe 154 155 - name: Prepare to release 156 run: | 157 cp ${GITHUB_WORKSPACE}/README.md ./build_assets/README.md 158 cp ${GITHUB_WORKSPACE}/LICENSE ./build_assets/LICENSE 159 LIST=('geoip geoip geoip' 'domain-list-community dlc geosite') 160 for i in "${LIST[@]}" 161 do 162 INFO=($(echo $i | awk 'BEGIN{FS=" ";OFS=" "} {print $1,$2,$3}')) 163 LASTEST_TAG="$(curl -sL "https://api.github.com/repos/v2fly/${INFO[0]}/releases" | jq -r ".[0].tag_name" || echo "latest")" 164 FILE_NAME="${INFO[2]}.dat" 165 echo -e "Downloading ${FILE_NAME}..." 166 curl -L "https://github.com/v2fly/${INFO[0]}/releases/download/${LASTEST_TAG}/${INFO[1]}.dat" -o ./build_assets/${FILE_NAME} 167 echo -e "Verifying HASH key..." 168 HASH="$(curl -sL "https://github.com/v2fly/${INFO[0]}/releases/download/${LASTEST_TAG}/${INFO[1]}.dat.sha256sum" | awk -F ' ' '{print $1}')" 169 [ "$(sha256sum "./build_assets/${FILE_NAME}" | awk -F ' ' '{print $1}')" == "${HASH}" ] || { echo -e "The HASH key of ${FILE_NAME} does not match cloud one."; exit 1; } 170 done 171 172 - name: Create ZIP archive 173 shell: bash 174 run: | 175 pushd build_assets || exit 1 176 touch -mt $(date +%Y01010000) * 177 zip -9vr ../Xray-$ASSET_NAME.zip . 178 popd || exit 1 179 FILE=./Xray-$ASSET_NAME.zip 180 DGST=$FILE.dgst 181 for METHOD in {"md5","sha1","sha256","sha512"} 182 do 183 openssl dgst -$METHOD $FILE | sed 's/([^)]*)//g' >>$DGST 184 done 185 186 - name: Change the name 187 run: | 188 mv build_assets Xray-$ASSET_NAME 189 190 - name: Upload files to Artifacts 191 uses: actions/upload-artifact@v2 192 with: 193 name: Xray-${{ steps.get_filename.outputs.ASSET_NAME }} 194 path: | 195 ./Xray-${{ steps.get_filename.outputs.ASSET_NAME }}/* 196 197 - name: Upload binaries to release 198 uses: svenstaro/upload-release-action@v2 199 if: github.event_name == 'release' 200 with: 201 repo_token: ${{ secrets.GITHUB_TOKEN }} 202 file: ./Xray-${{ steps.get_filename.outputs.ASSET_NAME }}.zip* 203 tag: ${{ github.ref }} 204 file_glob: true