github.com/v2fly/v2ray-core/v5@v5.16.2-0.20240507031116-8191faa6e095/.github/workflows/release.yml (about) 1 name: Release 2 3 on: 4 release: 5 types: 6 - prereleased 7 - released 8 push: 9 branches: 10 - master 11 - v* 12 - dev* 13 paths: 14 - "**/*.go" 15 - "go.mod" 16 - "go.sum" 17 - ".github/workflows/*.yml" 18 pull_request: 19 types: [opened, synchronize, reopened] 20 paths: 21 - "**/*.go" 22 - "go.mod" 23 - "go.sum" 24 - ".github/workflows/*.yml" 25 26 jobs: 27 build: 28 strategy: 29 matrix: 30 # Include amd64 on all platforms. 31 goos: [windows, freebsd, openbsd, linux, dragonfly, darwin] 32 goarch: [amd64, 386] 33 exclude: 34 # Exclude i386 on darwin and dragonfly. 35 - goarch: 386 36 goos: dragonfly 37 - goarch: 386 38 goos: darwin 39 include: 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 Windows ARM 7 52 - goos: windows 53 goarch: arm 54 goarm: 7 55 # END Windows ARM 7 56 # BEGIN FreeBSD ARM 6 7 57 - goos: freebsd 58 goarch: arm 59 goarm: 6 60 - goos: freebsd 61 goarch: arm 62 goarm: 7 63 # END FreeBSD ARM 6 7 64 # BEGIN OpenBSD ARM 6 7 65 - goos: openbsd 66 goarch: arm 67 goarm: 6 68 - goos: openbsd 69 goarch: arm 70 goarm: 7 71 # END OpenBSD ARM 6 7 72 # BEGIN Other architectures 73 - goos: darwin 74 goarch: arm64 75 - goos: linux 76 goarch: arm64 77 - goos: linux 78 goarch: riscv64 79 - goos: linux 80 goarch: loong64 81 - goos: windows 82 goarch: arm64 83 - goos: android 84 goarch: arm64 85 - goos: freebsd 86 goarch: arm64 87 - goos: openbsd 88 goarch: arm64 89 # BEGIN MIPS 90 - goos: linux 91 goarch: mips64 92 - goos: linux 93 goarch: mips64le 94 - goos: linux 95 goarch: mipsle 96 - goos: linux 97 goarch: mips 98 # END MIPS 99 # END Other architectures 100 fail-fast: false 101 102 runs-on: ubuntu-latest 103 env: 104 GOOS: ${{ matrix.goos }} 105 GOARCH: ${{ matrix.goarch }} 106 GOARM: ${{ matrix.goarm }} 107 CGO_ENABLED: 0 108 109 steps: 110 - name: Checkout codebase 111 uses: actions/checkout@v3 112 with: 113 fetch-depth: 0 114 115 - name: Show workflow information 116 id: get_filename 117 run: | 118 export _NAME=$(jq ".[\"$GOOS-$GOARCH$GOARM\"].friendlyName" -r < release/friendly-filenames.json) 119 echo "GOOS: $GOOS, GOARCH: $GOARCH, GOARM: $GOARM, RELEASE_NAME: $_NAME" 120 echo "ASSET_NAME=$_NAME" >> $GITHUB_OUTPUT 121 echo "ASSET_NAME=$_NAME" >> $GITHUB_ENV 122 123 - name: Set up Go 124 uses: actions/setup-go@v4 125 with: 126 go-version: ^1.21 127 128 - name: Get project dependencies 129 run: go mod download 130 131 - name: Build V2Ray 132 run: | 133 mkdir -p build_assets 134 EXTRA_ARG="" 135 case "$GOOS-$GOARCH" in 136 "linux-386") 137 ;& 138 "linux-amd64") 139 ;& 140 "linux-arm64") 141 EXTRA_ARG=EXTRA_ARG+"-buildmode=pie" 142 ;; 143 esac 144 go build -v -o build_assets/v2ray -trimpath -ldflags "-s -w -buildid=" ./main 145 146 - name: Rename Windows V2Ray 147 if: matrix.goos == 'windows' 148 run: | 149 cd ./build_assets || exit 1 150 mv v2ray v2ray.exe 151 152 - name: Download geo files 153 run: | 154 wget -O release/config/geoip.dat "https://raw.githubusercontent.com/v2fly/geoip/release/geoip.dat" 155 wget -O release/config/geoip-only-cn-private.dat "https://raw.githubusercontent.com/v2fly/geoip/release/geoip-only-cn-private.dat" 156 wget -O release/config/geosite.dat "https://raw.githubusercontent.com/v2fly/domain-list-community/release/dlc.dat" 157 158 - name: Prepare package 159 run: cp -v ./release/config/*.* ./build_assets 160 161 - name: Prepare package for Linux 162 if: matrix.goos == 'linux' 163 run: cp -rv ./release/config/systemd ./build_assets/ 164 165 - name: Create ZIP archive 166 run: | 167 pushd build_assets || exit 1 168 zip -9vr ../v2ray-$ASSET_NAME.zip . 169 popd || exit 1 170 FILE=./v2ray-$ASSET_NAME.zip 171 DGST=$FILE.dgst 172 openssl dgst -md5 $FILE | sed 's/([^)]*)//g' >>$DGST 173 openssl dgst -sha1 $FILE | sed 's/([^)]*)//g' >>$DGST 174 openssl dgst -sha256 $FILE | sed 's/([^)]*)//g' >>$DGST 175 openssl dgst -sha512 $FILE | sed 's/([^)]*)//g' >>$DGST 176 177 - name: Upload ZIP file to Artifacts 178 uses: actions/upload-artifact@v3 179 with: 180 name: v2ray-${{ steps.get_filename.outputs.ASSET_NAME }}.zip 181 path: v2ray-${{ steps.get_filename.outputs.ASSET_NAME }}.zip 182 183 - name: Upload files to GitHub release 184 uses: svenstaro/upload-release-action@v2 185 if: github.event_name == 'release' 186 with: 187 repo_token: ${{ secrets.GITHUB_TOKEN }} 188 file_glob: true 189 file: ./v2ray-${{ steps.get_filename.outputs.ASSET_NAME }}.zip* 190 tag: ${{ github.ref }} 191 overwrite: true 192 193 signature: 194 runs-on: ubuntu-latest 195 needs: build 196 steps: 197 - name: Checkout codebase 198 uses: actions/checkout@v3 199 with: 200 fetch-depth: 0 201 202 - name: Set up Go 203 uses: actions/setup-go@v4 204 with: 205 go-version: ^1.21 206 207 - uses: actions/download-artifact@v3 208 with: 209 path: build_artifacts 210 211 - name: Create extra package 212 run: | 213 pushd ./release/extra/ 214 zip -9vr ../../build_artifacts/v2ray-extra.zip . 215 popd 216 217 - name: Generate shasum 218 run: | 219 go get -v github.com/v2fly/V2BuildAssist/v2buildutil 220 cd build_artifacts || exit 1 221 mkdir .temp 222 mv ./*/*.zip ./.temp 223 rmdir ./*/ 224 mv ./.temp/* . 225 ls -lah --recursive 226 { 227 go run github.com/v2fly/V2BuildAssist/v2buildutil gen version $(git describe --tags $(git rev-list --tags --max-count=1)) 228 go run github.com/v2fly/V2BuildAssist/v2buildutil gen project "v2fly" 229 for zip in $(ls *.zip); do 230 go run github.com/v2fly/V2BuildAssist/v2buildutil gen file ${zip} 231 done 232 } >Release.unsigned.unsorted 233 go run github.com/v2fly/V2BuildAssist/v2buildutil gen sort < Release.unsigned.unsorted > Release.unsigned 234 rm -f Release.unsigned.unsorted 235 FILE=./Release.unsigned 236 DGST=$FILE.dgst 237 openssl dgst -md5 $FILE | sed 's/([^)]*)//g' >>$DGST 238 openssl dgst -sha1 $FILE | sed 's/([^)]*)//g' >>$DGST 239 openssl dgst -sha256 $FILE | sed 's/([^)]*)//g' >>$DGST 240 openssl dgst -sha512 $FILE | sed 's/([^)]*)//g' >>$DGST 241 242 - uses: actions/upload-artifact@v3 243 with: 244 name: Release.unsigned 245 path: build_artifacts/Release.unsigned 246 247 - uses: actions/upload-artifact@v3 248 with: 249 name: Release.unsigned.dgst 250 path: build_artifacts/Release.unsigned.dgst 251 252 - uses: actions/upload-artifact@v3 253 with: 254 name: v2ray-extra.zip 255 path: build_artifacts/v2ray-extra.zip 256 257 - name: Upload Release.unsigned related files 258 uses: svenstaro/upload-release-action@v2 259 if: github.event_name == 'release' 260 with: 261 repo_token: ${{ secrets.GITHUB_TOKEN }} 262 file_glob: true 263 file: build_artifacts/Release.unsigned* 264 tag: ${{ github.ref }} 265 overwrite: true 266 267 - name: Upload extra package 268 uses: svenstaro/upload-release-action@v2 269 if: github.event_name == 'release' 270 with: 271 repo_token: ${{ secrets.GITHUB_TOKEN }} 272 file_glob: true 273 file: build_artifacts/v2ray-extra.zip 274 tag: ${{ github.ref }} 275 overwrite: true 276 buildContainer: 277 if: github.event_name == 'release' 278 needs: signature 279 name: Build And Push image 280 runs-on: ubuntu-latest 281 env: 282 REGISTRY_USER: ${{ github.actor }} 283 REGISTRY_PASSWORD: ${{ github.token }} 284 IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }} 285 RELEASE_REPO: ${{ github.repository }} 286 VERSION: ${{ github.event.release.tag_name }} 287 TIMESTAMP: ${{ github.event.release.created_at }} 288 PRERELEASE: ${{ github.event.release.prerelease }} 289 VARIANTS: | # <v2ray variant>:<image tag suffix> 290 std: 291 extra:-extra 292 ARCHS: | # <v2ray arch name>:<container arch name> 293 32:386 294 64:amd64 295 arm32-v6:arm/v6 296 arm32-v7a:arm/v7 297 arm64-v8a:arm64 298 arm64-v8a:arm64/v8 299 steps: 300 - uses: actions/checkout@v3 301 302 - name: Log in to ghcr.io 303 uses: redhat-actions/podman-login@v1 304 with: 305 username: ${{ env.REGISTRY_USER }} 306 password: ${{ env.REGISTRY_PASSWORD }} 307 registry: ${{ env.IMAGE_REGISTRY }} 308 309 - name: Build Images 310 id: build-image 311 run: | 312 image=v2ray 313 tags= 314 315 timestamp=$(date -d $TIMESTAMP +%s) 316 versions="$VERSION" # full version (v1.2.3) 317 versions="$versions $(echo $VERSION | cut -d. -f1,2)" # minor version (v1.2) 318 if [ $PRERELEASE = false ]; then 319 versions="$versions $(echo $VERSION | cut -d. -f1)" # major version (v1) 320 versions="$versions latest" 321 fi 322 323 formatEach() { 324 format=$1 325 shift 1 326 echo "$@" | xargs -n1 | xargs -i echo "$format" | xargs 327 } 328 329 for variant in $VARIANTS; do 330 v2Variant=$(echo $variant | cut -d: -f1) 331 containerVariant=$(echo $variant | cut -d: -f2) 332 variantTags=$(formatEach "{}$containerVariant" $versions) 333 tags="$tags $variantTags" 334 for arch in $ARCHS; do 335 v2Arch=$(echo $arch | cut -d: -f1) 336 containerArch=$(echo $arch | cut -d: -f2) 337 bash ./release/container/downloadAssets.sh $VERSION $v2Arch $containerArch $v2Variant 338 for tag in $variantTags; do 339 buildah bud \ 340 --manifest $image:$tag \ 341 --file ./release/container/Containerfile \ 342 --platform linux/$containerArch \ 343 --timestamp $timestamp \ 344 --squash \ 345 ./context/linux/$containerArch/$v2Variant 346 done 347 done 348 done 349 350 echo image=$image >> $GITHUB_OUTPUT 351 echo tags=$tags >> $GITHUB_OUTPUT 352 353 - name: Push To ghcr.io 354 uses: redhat-actions/push-to-registry@v2 355 with: 356 image: ${{ steps.build-image.outputs.image }} 357 tags: ${{ steps.build-image.outputs.tags }} 358 registry: ${{ env.IMAGE_REGISTRY }}