|
| 1 | +name: ci |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - master |
| 8 | + paths-ignore: |
| 9 | + - '**/README.md' |
| 10 | + tags: |
| 11 | + - '*' |
| 12 | + schedule: |
| 13 | + - cron: '0 3 * * 1' |
| 14 | + workflow_dispatch: |
| 15 | + inputs: |
| 16 | + push: |
| 17 | + description: 'Push image to Docker Hub' |
| 18 | + type: boolean |
| 19 | + default: false |
| 20 | + |
| 21 | +jobs: |
| 22 | + |
| 23 | + build-and-push: |
| 24 | + runs-on: ubuntu-latest |
| 25 | + steps: |
| 26 | + - name: Checkout |
| 27 | + uses: actions/checkout@v3 |
| 28 | + |
| 29 | + - name: Inject slug/short variables |
| 30 | + uses: rlespinasse/[email protected] |
| 31 | + |
| 32 | + - name: Get curl version |
| 33 | + id: curlver |
| 34 | + uses: dvershinin/[email protected] |
| 35 | + with: |
| 36 | + repository: 'https://github.com/curl/curl' |
| 37 | + output_format: 'version' |
| 38 | + |
| 39 | + - name: Resolve tags |
| 40 | + run: | |
| 41 | + set -euo pipefail |
| 42 | + CURL_VERSION="${{ steps.curlver.outputs.last_version }}" |
| 43 | + CURL_TAG="curl-${CURL_VERSION//./_}" |
| 44 | + # determine latest quiche semver tag (v-prefixed or plain), choose highest |
| 45 | + QUICHE_VERSION="$( |
| 46 | + git ls-remote --tags https://github.com/cloudflare/quiche \ |
| 47 | + | awk -F'refs/tags/' '/refs\/tags\/v?[0-9]+\.[0-9]+\.[0-9]+(\^\{\})?$/ {gsub(/\^\{\}/,"",$2); gsub(/^v/,"",$2); print $2}' \ |
| 48 | + | sort -V | tail -n1 |
| 49 | + )" |
| 50 | + if git ls-remote --tags https://github.com/cloudflare/quiche "refs/tags/v${QUICHE_VERSION}" | grep -q "refs/tags/v${QUICHE_VERSION}$"; then |
| 51 | + QUICHE_REF="v${QUICHE_VERSION}" |
| 52 | + else |
| 53 | + QUICHE_REF="${QUICHE_VERSION}" |
| 54 | + fi |
| 55 | + echo "CURL_VERSION=${CURL_VERSION}" >> $GITHUB_ENV |
| 56 | + echo "IMAGE_TAG=${CURL_VERSION}" >> $GITHUB_ENV |
| 57 | + echo "CURL_TAG=${CURL_TAG}" >> $GITHUB_ENV |
| 58 | + echo "QUICHE_REF=${QUICHE_REF}" >> $GITHUB_ENV |
| 59 | +
|
| 60 | + - name: Prepare sources (git shallow clone + tar) |
| 61 | + run: | |
| 62 | + set -euo pipefail |
| 63 | + rm -rf src _dl |
| 64 | + mkdir -p src _dl |
| 65 | + git clone --depth 1 --branch "${CURL_TAG}" https://github.com/curl/curl src/curl-src |
| 66 | + git clone --filter=blob:none --recurse-submodules --shallow-submodules https://github.com/cloudflare/quiche src/quiche-src |
| 67 | + git -C src/quiche-src fetch --tags --depth 1 origin "refs/tags/${QUICHE_REF}:refs/tags/${QUICHE_REF}" |
| 68 | + git -C src/quiche-src checkout -q "refs/tags/${QUICHE_REF}" |
| 69 | + git -C src/quiche-src submodule update --init --recursive --depth 1 |
| 70 | + tar -czf _dl/curl.tar.gz -C src curl-src |
| 71 | + tar -czf _dl/quiche.tar.gz -C src quiche-src |
| 72 | + curl -fL "https://raw.githubusercontent.com/b4b4r07/httpstat/master/httpstat.sh" -o _dl/httpstat.sh |
| 73 | +
|
| 74 | + - name: Login to Docker Hub |
| 75 | + if: inputs.push == true || github.event_name == 'push' || github.event_name == 'schedule' |
| 76 | + uses: docker/login-action@v2 |
| 77 | + with: |
| 78 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 79 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 80 | + |
| 81 | + - name: Set up QEMU |
| 82 | + if: github.event_name == 'schedule' |
| 83 | + uses: docker/setup-qemu-action@v3 |
| 84 | + with: |
| 85 | + platforms: linux/arm64 |
| 86 | + |
| 87 | + - name: Set up Docker Buildx |
| 88 | + if: inputs.push == true || github.event_name == 'push' || github.event_name == 'schedule' |
| 89 | + uses: docker/setup-buildx-action@v2 |
| 90 | + |
| 91 | + - name: Build (no push) via docker build (act) |
| 92 | + if: inputs.push != true && github.event_name != 'push' && env.ACT == 'true' |
| 93 | + run: | |
| 94 | + DOCKER_BUILDKIT=1 docker build --platform linux/amd64 --load \ |
| 95 | + -t curl-edge:${IMAGE_TAG} -t curl-edge:latest . |
| 96 | +
|
| 97 | + - name: Build (no push) |
| 98 | + if: inputs.push != true && github.event_name != 'push' && github.event_name != 'schedule' && env.ACT != 'true' |
| 99 | + uses: docker/build-push-action@v4 |
| 100 | + with: |
| 101 | + context: . |
| 102 | + push: false |
| 103 | + platforms: linux/amd64 |
| 104 | + load: true |
| 105 | + tags: | |
| 106 | + curl-edge:${{ env.IMAGE_TAG }} |
| 107 | + curl-edge:latest |
| 108 | +
|
| 109 | + - name: Test curl -V |
| 110 | + if: inputs.push != true && github.event_name != 'push' |
| 111 | + run: docker run --rm curl-edge:${IMAGE_TAG} -V |
| 112 | + |
| 113 | + - name: Test HTTP/3 to Cloudflare |
| 114 | + if: inputs.push != true && github.event_name != 'push' |
| 115 | + run: | |
| 116 | + docker run --rm --network host curl-edge:${IMAGE_TAG} \ |
| 117 | + -I --http3 https://cloudflare-quic.com/ || \ |
| 118 | + docker run --rm --network host curl-edge:${IMAGE_TAG} \ |
| 119 | + -I --http3 https://www.cloudflare.com/ --connect-timeout 10 || true |
| 120 | +
|
| 121 | + - name: Test httpstat script |
| 122 | + if: inputs.push != true && github.event_name != 'push' |
| 123 | + run: | |
| 124 | + docker run --rm --network host curl-edge:${IMAGE_TAG} \ |
| 125 | + /opt/httpstat.sh -I --http3 https://cloudflare-quic.com/ || true |
| 126 | +
|
| 127 | + - name: Build and push (push/dispatch, amd64 only) |
| 128 | + if: inputs.push == true || github.event_name == 'push' |
| 129 | + uses: docker/build-push-action@v4 |
| 130 | + with: |
| 131 | + context: . |
| 132 | + push: true |
| 133 | + platforms: linux/amd64 |
| 134 | + cache-from: type=gha |
| 135 | + cache-to: type=gha,mode=max |
| 136 | + tags: | |
| 137 | + getpagespeed/curl-edge:amd64-${{ env.IMAGE_TAG }} |
| 138 | + getpagespeed/curl-edge:latest-amd64 |
| 139 | +
|
| 140 | + - name: Build and push (nightly, arm64 only) |
| 141 | + if: github.event_name == 'schedule' |
| 142 | + uses: docker/build-push-action@v4 |
| 143 | + with: |
| 144 | + context: . |
| 145 | + push: true |
| 146 | + platforms: linux/arm64 |
| 147 | + cache-from: type=gha |
| 148 | + cache-to: type=gha,mode=max |
| 149 | + tags: | |
| 150 | + getpagespeed/curl-edge:arm64-${{ env.IMAGE_TAG }} |
| 151 | + getpagespeed/curl-edge:latest-arm64 |
| 152 | +
|
| 153 | + - name: Create multi-arch manifest (nightly) |
| 154 | + if: github.event_name == 'schedule' |
| 155 | + run: | |
| 156 | + docker buildx imagetools create \ |
| 157 | + -t getpagespeed/curl-edge:${IMAGE_TAG} \ |
| 158 | + -t getpagespeed/curl-edge:latest \ |
| 159 | + getpagespeed/curl-edge:amd64-${IMAGE_TAG} \ |
| 160 | + getpagespeed/curl-edge:arm64-${IMAGE_TAG} |
0 commit comments