|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'websocket-proxy/v*' |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + |
| 11 | +env: |
| 12 | + REGISTRY_IMAGE: flashbots/flashblocks-websocket-proxy |
| 13 | + |
| 14 | +jobs: |
| 15 | + extract-version: |
| 16 | + name: Extract version |
| 17 | + runs-on: warp-ubuntu-latest-x64-16x |
| 18 | + outputs: |
| 19 | + VERSION: ${{ steps.extract_version.outputs.VERSION }} |
| 20 | + steps: |
| 21 | + - name: Extract version |
| 22 | + id: extract_version |
| 23 | + run: | |
| 24 | + if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then |
| 25 | + VERSION="${GITHUB_REF#refs/tags/websocket-proxy/}" |
| 26 | + else |
| 27 | + VERSION="$(echo ${GITHUB_SHA} | cut -c1-7)" |
| 28 | + fi |
| 29 | + echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT |
| 30 | + echo "| | |" >> $GITHUB_STEP_SUMMARY |
| 31 | + echo "| ------------------- | ---------------------- |" >> $GITHUB_STEP_SUMMARY |
| 32 | + echo "| \`GITHUB_REF_TYPE\` | \`${GITHUB_REF_TYPE}\` |" >> $GITHUB_STEP_SUMMARY |
| 33 | + echo "| \`GITHUB_REF_NAME\` | \`${GITHUB_REF_NAME}\` |" >> $GITHUB_STEP_SUMMARY |
| 34 | + echo "| \`GITHUB_REF\` | \`${GITHUB_REF}\` |" >> $GITHUB_STEP_SUMMARY |
| 35 | + echo "| \`GITHUB_SHA\` | \`${GITHUB_SHA}\` |" >> $GITHUB_STEP_SUMMARY |
| 36 | + echo "| \`VERSION\` | \`${VERSION}\` |" >> $GITHUB_STEP_SUMMARY |
| 37 | + echo "| \`FEATURES\` | \`${{ github.event.inputs.features || 'none' }}\` |" >> $GITHUB_STEP_SUMMARY |
| 38 | + |
| 39 | + build-binary: |
| 40 | + name: Build binary |
| 41 | + needs: extract-version |
| 42 | + runs-on: ${{ matrix.configs.runner }} |
| 43 | + container: |
| 44 | + image: ubuntu:22.04 |
| 45 | + permissions: |
| 46 | + contents: write |
| 47 | + packages: write |
| 48 | + strategy: |
| 49 | + matrix: |
| 50 | + configs: |
| 51 | + - target: x86_64-unknown-linux-gnu |
| 52 | + runner: warp-ubuntu-latest-x64-32x |
| 53 | + - target: aarch64-unknown-linux-gnu |
| 54 | + runner: warp-ubuntu-latest-arm64-32x |
| 55 | + # Paused until docker is pre-installed https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md |
| 56 | + # - target: aarch64-apple-darwin |
| 57 | + # runner: warp-macos-14-arm64-6x |
| 58 | + |
| 59 | + steps: |
| 60 | + - name: Install dependencies |
| 61 | + run: | |
| 62 | + apt-get update |
| 63 | + apt-get install -y \ |
| 64 | + build-essential \ |
| 65 | + curl \ |
| 66 | + git \ |
| 67 | + libclang-dev \ |
| 68 | + libssl-dev \ |
| 69 | + libtss2-dev \ |
| 70 | + pkg-config \ |
| 71 | + protobuf-compiler |
| 72 | + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y |
| 73 | + - uses: actions/checkout@v4 # must install git before checkout and set safe.directory after checkout because of container |
| 74 | + |
| 75 | + - name: Build websocket-proxy binary |
| 76 | + run: | |
| 77 | + git config --global --add safe.directory "$(pwd)" |
| 78 | + . $HOME/.cargo/env |
| 79 | + cargo build --release --target ${{ matrix.configs.target }} --package flashblocks-websocket-proxy |
| 80 | + mkdir -p artifacts |
| 81 | + mv target/${{ matrix.configs.target }}/release/flashblocks-websocket-proxy artifacts/flashblocks-websocket-proxy-${{ needs.extract-version.outputs.VERSION }}-${{ matrix.configs.target }}${{ matrix.features && '-' }}${{ matrix.features }} |
| 82 | + - name: Upload artifacts |
| 83 | + uses: actions/upload-artifact@v4 |
| 84 | + with: |
| 85 | + name: flashblocks-websocket-proxy-${{ needs.extract-version.outputs.VERSION }}-${{ matrix.configs.target }}${{ matrix.features && '-' }}${{ matrix.features }} |
| 86 | + path: artifacts |
| 87 | + |
| 88 | + publish-docker-image: |
| 89 | + name: Publish Docker Image |
| 90 | + strategy: |
| 91 | + matrix: |
| 92 | + configs: |
| 93 | + - platform: linux/amd64 |
| 94 | + runner: warp-ubuntu-latest-x64-32x |
| 95 | + - platform: linux/arm64 |
| 96 | + runner: warp-ubuntu-latest-arm64-32x |
| 97 | + # Paused until docker is pre-installed https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md |
| 98 | + # - target: aarch64-apple-darwin |
| 99 | + # runner: warp-macos-14-arm64-6x |
| 100 | + runs-on: ${{ matrix.configs.runner }} |
| 101 | + steps: |
| 102 | + - name: Checkout sources |
| 103 | + |
| 104 | + |
| 105 | + - name: Set env |
| 106 | + run: | |
| 107 | + platform=${{ matrix.configs.platform }} |
| 108 | + echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV |
| 109 | + echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/websocket-proxy/}" >> $GITHUB_ENV |
| 110 | + |
| 111 | + - name: Print version |
| 112 | + run: | |
| 113 | + echo $RELEASE_VERSION |
| 114 | + echo ${{ env.RELEASE_VERSION }} |
| 115 | +
|
| 116 | + - name: Extract metadata (tags, labels) for Docker images |
| 117 | + id: meta |
| 118 | + uses: docker/metadata-action@v4 |
| 119 | + with: |
| 120 | + images: ${{ env.REGISTRY_IMAGE }} |
| 121 | + tags: | |
| 122 | + type=sha |
| 123 | + type=raw,value=${{ env.RELEASE_VERSION }} |
| 124 | + type=raw,value=latest,enable=${{ !contains(env.RELEASE_VERSION, '-') }} |
| 125 | +
|
| 126 | + - name: Set up QEMU |
| 127 | + uses: docker/setup-qemu-action@v3 |
| 128 | + |
| 129 | + - name: Set up Docker Buildx |
| 130 | + uses: docker/setup-buildx-action@v3 |
| 131 | + |
| 132 | + - name: Login to DockerHub |
| 133 | + uses: docker/login-action@v3 |
| 134 | + with: |
| 135 | + username: ${{ secrets.FLASHBOTS_DOCKERHUB_USERNAME }} |
| 136 | + password: ${{ secrets.FLASHBOTS_DOCKERHUB_TOKEN }} |
| 137 | + |
| 138 | + - name: Build and push |
| 139 | + id: build |
| 140 | + uses: docker/build-push-action@v6 |
| 141 | + with: |
| 142 | + cache-from: type=gha |
| 143 | + cache-to: type=gha,mode=max |
| 144 | + context: . |
| 145 | + file: ./crates/websocket-proxy/Dockerfile |
| 146 | + build-args: | |
| 147 | + VERSION=${{ env.RELEASE_VERSION }} |
| 148 | + platforms: ${{ matrix.configs.platform }} |
| 149 | + labels: ${{ steps.meta.outputs.labels }} |
| 150 | + outputs: type=registry,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true |
| 151 | + |
| 152 | + - name: Export digest |
| 153 | + run: | |
| 154 | + mkdir -p /tmp/digests |
| 155 | + digest="${{ steps.build.outputs.digest }}" |
| 156 | + touch "/tmp/digests/${digest#sha256:}" |
| 157 | +
|
| 158 | + - name: Upload digest |
| 159 | + uses: actions/upload-artifact@v4 |
| 160 | + with: |
| 161 | + name: digests-${{ env.PLATFORM_PAIR }} |
| 162 | + path: /tmp/digests/* |
| 163 | + if-no-files-found: error |
| 164 | + retention-days: 1 |
| 165 | + |
| 166 | + merge: |
| 167 | + runs-on: warp-ubuntu-latest-x64-16x |
| 168 | + needs: |
| 169 | + - publish-docker-image |
| 170 | + steps: |
| 171 | + - name: Download digests |
| 172 | + uses: actions/download-artifact@v4 |
| 173 | + with: |
| 174 | + path: /tmp/digests |
| 175 | + pattern: digests-* |
| 176 | + merge-multiple: true |
| 177 | + |
| 178 | + - name: Login to Docker Hub |
| 179 | + uses: docker/login-action@v3 |
| 180 | + with: |
| 181 | + username: ${{ secrets.FLASHBOTS_DOCKERHUB_USERNAME }} |
| 182 | + password: ${{ secrets.FLASHBOTS_DOCKERHUB_TOKEN }} |
| 183 | + |
| 184 | + - name: Login to GHCR |
| 185 | + uses: docker/login-action@v3 |
| 186 | + with: |
| 187 | + registry: ghcr.io |
| 188 | + username: ${{ github.actor }} |
| 189 | + password: ${{ secrets.FLASHBOTS_GHCR_TOKEN }} # PAT required for Organization policy |
| 190 | + |
| 191 | + - name: Set up Docker Buildx |
| 192 | + uses: docker/setup-buildx-action@v3 |
| 193 | + |
| 194 | + - name: Docker meta |
| 195 | + id: meta |
| 196 | + uses: docker/metadata-action@v5 |
| 197 | + with: |
| 198 | + images: ${{ env.REGISTRY_IMAGE }} |
| 199 | + tags: | |
| 200 | + type=sha |
| 201 | + type=raw,value=${{ env.RELEASE_VERSION }} |
| 202 | + type=raw,value=latest,enable=${{ !contains(env.RELEASE_VERSION, '-') }} |
| 203 | +
|
| 204 | + - name: Create manifest list and push |
| 205 | + working-directory: /tmp/digests |
| 206 | + run: | |
| 207 | + image=$( |
| 208 | + jq -cr '.tags | first' <<< "$DOCKER_METADATA_OUTPUT_JSON" |
| 209 | + ) |
| 210 | +
|
| 211 | + docker buildx imagetools create -t $image $( |
| 212 | + printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' * |
| 213 | + ) |
| 214 | +
|
| 215 | + - name: Install regctl |
| 216 | + uses: regclient/actions/regctl-installer@main |
| 217 | + |
| 218 | + - name: Push to GHCR |
| 219 | + run: | |
| 220 | + regctl image copy \ |
| 221 | + ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} \ |
| 222 | + ghcr.io/${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} |
| 223 | +
|
| 224 | + - name: Inspect image |
| 225 | + run: | |
| 226 | + docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} |
| 227 | +
|
| 228 | + github-release: |
| 229 | + runs-on: warp-ubuntu-latest-x64-16x |
| 230 | + steps: |
| 231 | + - name: Checkout sources |
| 232 | + |
| 233 | + |
| 234 | + - name: Create release |
| 235 | + id: create_release |
| 236 | + uses: actions/create-release@v1 |
| 237 | + env: |
| 238 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 239 | + with: |
| 240 | + tag_name: ${{ github.ref }} |
| 241 | + release_name: ${{ github.ref }} |
| 242 | + draft: true |
| 243 | + prerelease: false |
0 commit comments