|
| 1 | +name: Build-and-upload-binary |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + |
| 6 | +jobs: |
| 7 | + build-and-release: |
| 8 | + runs-on: ubuntu-latest |
| 9 | + permissions: |
| 10 | + contents: write |
| 11 | + |
| 12 | + strategy: |
| 13 | + matrix: |
| 14 | + include: |
| 15 | + # Linux |
| 16 | + - os: ubuntu-latest |
| 17 | + goos: linux |
| 18 | + goarch: 386 |
| 19 | + goarm: "" |
| 20 | + filename: gows_linux_amd |
| 21 | + - os: ubuntu-latest |
| 22 | + goos: linux |
| 23 | + goarch: amd64 |
| 24 | + goarm: "" |
| 25 | + filename: gows_linux_amd64 |
| 26 | + - os: ubuntu-latest |
| 27 | + goos: linux |
| 28 | + goarch: arm |
| 29 | + goarm: "6" |
| 30 | + filename: gows_linux_arm |
| 31 | + - os: ubuntu-latest |
| 32 | + goos: linux |
| 33 | + goarch: arm64 |
| 34 | + goarm: "" |
| 35 | + filename: gows_linux_arm64 |
| 36 | + |
| 37 | + # FreeBSD |
| 38 | + - os: ubuntu-latest |
| 39 | + goos: freebsd |
| 40 | + goarch: amd64 |
| 41 | + goarm: "" |
| 42 | + filename: gows_freebsd_amd64 |
| 43 | + - os: ubuntu-latest |
| 44 | + goos: freebsd |
| 45 | + goarch: arm64 |
| 46 | + goarm: "" |
| 47 | + filename: gows_freebsd_arm64 |
| 48 | + |
| 49 | + # Windows |
| 50 | + - os: ubuntu-latest |
| 51 | + goos: windows |
| 52 | + goarch: amd64 |
| 53 | + goarm: "" |
| 54 | + filename: gows_windows_amd64.exe |
| 55 | + - os: ubuntu-latest |
| 56 | + goos: windows |
| 57 | + goarch: arm64 |
| 58 | + goarm: "" |
| 59 | + filename: gows_windows_arm64.exe |
| 60 | + |
| 61 | + # macOS (macOS jobs will run on macos runners in a real scenario, but for this workflow we'll use cross-compilation) |
| 62 | + - os: macos-latest |
| 63 | + goos: darwin |
| 64 | + goarch: amd64 |
| 65 | + goarm: "" |
| 66 | + filename: gows_macos_amd64 |
| 67 | + - os: macos-latest |
| 68 | + goos: darwin |
| 69 | + goarch: arm64 |
| 70 | + goarm: "" |
| 71 | + filename: gows_macos_arm64 |
| 72 | + |
| 73 | + steps: |
| 74 | + - name: Checkout code |
| 75 | + uses: actions/checkout@v4 |
| 76 | + with: |
| 77 | + ref: golang |
| 78 | + |
| 79 | + - name: Set up Go |
| 80 | + uses: actions/setup-go@v5 |
| 81 | + with: |
| 82 | + go-version: '1.24' |
| 83 | + |
| 84 | + - name: Get dependencies |
| 85 | + run: | |
| 86 | + go mod tidy |
| 87 | + go mod download |
| 88 | +
|
| 89 | + - name: Build binary |
| 90 | + env: |
| 91 | + GOOS: ${{ matrix.goos }} |
| 92 | + GOARCH: ${{ matrix.goarch }} |
| 93 | + GOARM: ${{ matrix.goarm }} |
| 94 | + CGO_ENABLED: 0 |
| 95 | + run: | |
| 96 | + go build -ldflags="-s -w -extldflags -static" -o ${{ matrix.filename }} . |
| 97 | + |
| 98 | + - name: Upload go.mod and go.sum |
| 99 | + if: matrix.goos == 'linux' && matrix.goarch == 'amd64' # Only upload once |
| 100 | + uses: actions/upload-artifact@v4 |
| 101 | + with: |
| 102 | + name: go-dependencies |
| 103 | + path: | |
| 104 | + go.mod |
| 105 | + go.sum |
| 106 | +
|
| 107 | + - name: Upload binary |
| 108 | + uses: actions/upload-artifact@v4 |
| 109 | + with: |
| 110 | + name: ${{ matrix.filename }} |
| 111 | + path: ${{ matrix.filename }} |
| 112 | + |
| 113 | + |
| 114 | + |
| 115 | + release: |
| 116 | + needs: build-and-release |
| 117 | + runs-on: ubuntu-latest |
| 118 | + permissions: |
| 119 | + contents: write |
| 120 | + |
| 121 | + steps: |
| 122 | + - name: Checkout code |
| 123 | + uses: actions/checkout@v4 |
| 124 | + with: |
| 125 | + ref: golang |
| 126 | + |
| 127 | + - name: Set up Go |
| 128 | + uses: actions/setup-go@v5 |
| 129 | + with: |
| 130 | + go-version: '1.24' |
| 131 | + |
| 132 | + - name: Get dependencies |
| 133 | + run: | |
| 134 | + go mod tidy |
| 135 | + go mod download |
| 136 | +
|
| 137 | + - name: Create binaries directory |
| 138 | + run: mkdir -p ./binaries |
| 139 | + |
| 140 | + - name: Download all artifacts |
| 141 | + uses: actions/download-artifact@v4 |
| 142 | + with: |
| 143 | + path: ./temp-binaries |
| 144 | + |
| 145 | + - name: Move binaries to correct location |
| 146 | + run: | |
| 147 | + find ./temp-binaries -type f -exec mv {} ./binaries/ \; |
| 148 | + ls -la ./binaries/ |
| 149 | +
|
| 150 | + - name: Download dependencies |
| 151 | + uses: actions/download-artifact@v4 |
| 152 | + with: |
| 153 | + name: go-dependencies |
| 154 | + path: ./binaries |
| 155 | + |
| 156 | + - name: Create Release |
| 157 | + uses: softprops/action-gh-release@v2 |
| 158 | + with: |
| 159 | + tag_name: gows-latest |
| 160 | + name: "Gows Latest Release" |
| 161 | + body: | |
| 162 | + ## Gows - Go WebSocket Proxy |
| 163 | + |
| 164 | + This release includes binaries for multiple platforms: |
| 165 | + - Linux: amd, amd64, arm, arm64 |
| 166 | + - FreeBSD: amd64, arm64 |
| 167 | + - Windows: amd64, arm64 |
| 168 | + - macOS: amd64, arm64 |
| 169 | + |
| 170 | + For usage instructions, please refer to the README.md |
| 171 | + files: | |
| 172 | + ./binaries/gows_linux_amd |
| 173 | + ./binaries/gows_linux_amd64 |
| 174 | + ./binaries/gows_linux_arm |
| 175 | + ./binaries/gows_linux_arm64 |
| 176 | + ./binaries/gows_freebsd_amd64 |
| 177 | + ./binaries/gows_freebsd_arm64 |
| 178 | + ./binaries/gows_windows_amd64.exe |
| 179 | + ./binaries/gows_windows_arm64.exe |
| 180 | + ./binaries/gows_macos_amd64 |
| 181 | + ./binaries/gows_macos_arm64 |
| 182 | + draft: false |
| 183 | + prerelease: false |
0 commit comments