mirror of
https://github.com/graphql-hive/console
synced 2026-04-21 22:47:17 +00:00
258 lines
7.4 KiB
YAML
258 lines
7.4 KiB
YAML
on:
|
|
workflow_call:
|
|
|
|
jobs:
|
|
publish_rust:
|
|
runs-on: ubuntu-22.04
|
|
name: find-changes
|
|
outputs:
|
|
rust_changed: ${{ steps.rust_changed.outputs.rust_changed }}
|
|
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 2
|
|
- name: Look for changes
|
|
id: rust_changed
|
|
run: |
|
|
lines=$( git diff HEAD~ HEAD --name-only -- 'packages/libraries/router' | wc -l )
|
|
if [ $lines -gt 0 ]; then
|
|
echo 'rust_changed=true' >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
publish_rust_docker:
|
|
needs: publish_rust
|
|
if: needs.publish_rust.outputs.rust_changed == 'true'
|
|
name: docker
|
|
runs-on: ubuntu-22.04
|
|
|
|
env:
|
|
REGISTRY: ghcr.io
|
|
IMAGE_NAME: ${{ github.repository }}/apollo-router
|
|
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v2
|
|
with:
|
|
platforms: 'linux/arm64,linux/amd64'
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v2
|
|
|
|
- name: Login to registry
|
|
uses: docker/login-action@v2
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Extract metadata (tags, labels)
|
|
id: router-extract
|
|
uses: docker/metadata-action@v4
|
|
with:
|
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
|
tags: |
|
|
type=ref,event=branch
|
|
type=sha,prefix=,format=long
|
|
type=raw,value=latest,enable={{is_default_branch}}
|
|
|
|
- name: Build and push Docker image
|
|
uses: docker/build-push-action@v3
|
|
with:
|
|
platforms: linux/amd64,linux/arm64
|
|
file: packages/libraries/router/Dockerfile
|
|
context: .
|
|
push: true
|
|
tags: ${{ steps.router-extract.outputs.tags }}
|
|
labels: ${{ steps.router-extract.outputs.labels }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
|
|
publish_rust_windows:
|
|
needs: publish_rust
|
|
if: needs.publish_rust.outputs.rust_changed == 'true'
|
|
name: windows
|
|
runs-on: windows-latest
|
|
timeout-minutes: 40
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Install Rust
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
toolchain: stable
|
|
override: true
|
|
|
|
- name: Cache Rust
|
|
uses: Swatinem/rust-cache@v2
|
|
|
|
- name: Build
|
|
uses: actions-rs/cargo@v1
|
|
with:
|
|
command: build
|
|
args: --release
|
|
|
|
- name: Compress
|
|
run: ./target/release/compress ./target/release/router.exe ./router.tar.gz
|
|
|
|
- name: Upload artifacts
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: router-win
|
|
path: router.tar.gz
|
|
|
|
- name: Upload to R2
|
|
uses: randomairborne/r2-release@v1.0.2
|
|
with:
|
|
endpoint: https://6d5bc18cd8d13babe7ed321adba3d8ae.r2.cloudflarestorage.com
|
|
accesskeyid: ${{ secrets.R2_ACCESS_KEY_ID }}
|
|
secretaccesskey: ${{ secrets.R2_SECRET_ACCESS_KEY }}
|
|
bucket: apollo-router
|
|
file: router.tar.gz
|
|
destination: ${{ github.sha }}/win/router.tar.gz
|
|
|
|
- name: Upload to R2 as latest
|
|
uses: randomairborne/r2-release@v1.0.2
|
|
with:
|
|
endpoint: https://6d5bc18cd8d13babe7ed321adba3d8ae.r2.cloudflarestorage.com
|
|
accesskeyid: ${{ secrets.R2_ACCESS_KEY_ID }}
|
|
secretaccesskey: ${{ secrets.R2_SECRET_ACCESS_KEY }}
|
|
bucket: apollo-router
|
|
file: router.tar.gz
|
|
destination: latest/win/router.tar.gz
|
|
|
|
publish_rust_macos:
|
|
needs: publish_rust
|
|
if: needs.publish_rust.outputs.rust_changed == 'true'
|
|
name: macos
|
|
runs-on: macos-latest
|
|
timeout-minutes: 40
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
|
|
- uses: pnpm/action-setup@v2.2.4
|
|
with:
|
|
version: 7
|
|
|
|
- name: Use Node.js ${{ matrix.node-version }}
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: ${{ matrix.node-version }}
|
|
cache: 'pnpm'
|
|
node-version-file: .node-version
|
|
|
|
- name: Install Rust
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
toolchain: stable
|
|
override: true
|
|
|
|
- name: Cache Rust
|
|
uses: Swatinem/rust-cache@v2
|
|
|
|
- name: Build
|
|
uses: actions-rs/cargo@v1
|
|
with:
|
|
command: build
|
|
args: --release
|
|
|
|
- name: Strip binary from debug symbols
|
|
run: strip target/release/router
|
|
|
|
- name: Compress
|
|
run: ./target/release/compress ./target/release/router ./router.tar.gz
|
|
|
|
- name: Upload artifact
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: router-macos
|
|
path: router.tar.gz
|
|
|
|
- name: Upload to R2
|
|
uses: randomairborne/r2-release@v1.0.2
|
|
with:
|
|
endpoint: https://6d5bc18cd8d13babe7ed321adba3d8ae.r2.cloudflarestorage.com
|
|
accesskeyid: ${{ secrets.R2_ACCESS_KEY_ID }}
|
|
secretaccesskey: ${{ secrets.R2_SECRET_ACCESS_KEY }}
|
|
bucket: apollo-router
|
|
file: router.tar.gz
|
|
destination: ${{ github.sha }}/macos/router.tar.gz
|
|
|
|
- name: Upload to R2 as latest
|
|
uses: randomairborne/r2-release@v1.0.2
|
|
with:
|
|
endpoint: https://6d5bc18cd8d13babe7ed321adba3d8ae.r2.cloudflarestorage.com
|
|
accesskeyid: ${{ secrets.R2_ACCESS_KEY_ID }}
|
|
secretaccesskey: ${{ secrets.R2_SECRET_ACCESS_KEY }}
|
|
bucket: apollo-router
|
|
file: router.tar.gz
|
|
destination: latest/macos/router.tar.gz
|
|
|
|
publish_rust_linux:
|
|
needs: publish_rust
|
|
if: needs.publish_rust.outputs.rust_changed == 'true'
|
|
name: linux
|
|
runs-on: ubuntu-22.04
|
|
timeout-minutes: 40
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Install Rust
|
|
run: |
|
|
curl https://sh.rustup.rs -sSf | sh -s -- -y
|
|
rustup target add x86_64-unknown-linux-gnu
|
|
|
|
- name: Cache Rust
|
|
uses: Swatinem/rust-cache@v2
|
|
with:
|
|
key: rust_linux_cross
|
|
|
|
- name: Build
|
|
run: cargo build --target x86_64-unknown-linux-gnu --release
|
|
|
|
- name: Strip binary from debug symbols
|
|
run: strip target/x86_64-unknown-linux-gnu/release/router
|
|
|
|
- name: Compress
|
|
run:
|
|
./target/x86_64-unknown-linux-gnu/release/compress
|
|
./target/x86_64-unknown-linux-gnu/release/router ./router.tar.gz
|
|
|
|
- name: Upload artifact
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: router-linux
|
|
path: router.tar.gz
|
|
|
|
- name: Upload to R2
|
|
uses: randomairborne/r2-release@v1.0.2
|
|
with:
|
|
endpoint: https://6d5bc18cd8d13babe7ed321adba3d8ae.r2.cloudflarestorage.com
|
|
accesskeyid: ${{ secrets.R2_ACCESS_KEY_ID }}
|
|
secretaccesskey: ${{ secrets.R2_SECRET_ACCESS_KEY }}
|
|
bucket: apollo-router
|
|
file: router.tar.gz
|
|
destination: ${{ github.sha }}/linux/router.tar.gz
|
|
|
|
- name: Upload to R2 as latest
|
|
uses: randomairborne/r2-release@v1.0.2
|
|
with:
|
|
endpoint: https://6d5bc18cd8d13babe7ed321adba3d8ae.r2.cloudflarestorage.com
|
|
accesskeyid: ${{ secrets.R2_ACCESS_KEY_ID }}
|
|
secretaccesskey: ${{ secrets.R2_SECRET_ACCESS_KEY }}
|
|
bucket: apollo-router
|
|
file: router.tar.gz
|
|
destination: latest/linux/router.tar.gz
|