Files
rerun-io--rerun/.github/workflows/reusable_build_and_upload_rerun_cli.yml
2026-07-13 13:05:14 +08:00

233 lines
8.3 KiB
YAML

name: Reusable Rerun CLI build & upload
on:
workflow_call:
inputs:
CONCURRENCY:
required: true
type: string
PLATFORM:
required: true
type: string
ADHOC_NAME:
required: false
type: string
default: ""
RELEASE_COMMIT:
required: false
type: string
default: ""
workflow_dispatch:
inputs:
ADHOC_NAME:
required: false
type: string
default: ""
description: "Name of the adhoc build, used for upload directory"
PLATFORM:
type: choice
options:
- linux-arm64
- linux-x64
- windows-x64
- macos-arm64
description: "Platform to build for"
required: true
CONCURRENCY:
required: false
type: string
default: "adhoc"
description: "Concurrency group to use"
concurrency:
group: ${{ inputs.CONCURRENCY }}-build-rerun-cli
cancel-in-progress: true
env:
PYTHON_VERSION: "3.10"
RUSTFLAGS: --deny warnings
RUSTDOCFLAGS: --deny warnings
defaults:
run:
shell: bash --noprofile --norc -euo pipefail {0}
permissions:
contents: "read"
packages: "read"
id-token: "write"
jobs:
set-config:
name: Set Config (${{ inputs.PLATFORM }})
runs-on: ubuntu-latest
outputs:
RUNNER: ${{ steps.set-config.outputs.runner }}
TARGET: ${{ steps.set-config.outputs.target }}
CONTAINER: ${{ steps.set-config.outputs.container }}
BIN_NAME: ${{ steps.set-config.outputs.bin_name }}
steps:
- name: Set runner and target based on platform
id: set-config
run: |
case "${{ inputs.PLATFORM }}" in
linux-arm64)
runner="ubuntu-arm-16-core"
target="aarch64-unknown-linux-gnu"
container="'ghcr.io/rerun-io/ci_docker:0.18.0'"
bin_name="rerun"
;;
linux-x64)
runner="ubuntu-latest-16-cores"
target="x86_64-unknown-linux-gnu"
container="'ghcr.io/rerun-io/ci_docker:0.18.0'"
bin_name="rerun"
;;
windows-x64)
runner="windows-latest-16-cores"
target="x86_64-pc-windows-msvc"
container="null"
bin_name="rerun.exe"
;;
macos-arm64)
runner="macos-26-xlarge" # See https://github.blog/2023-10-02-introducing-the-new-apple-silicon-powered-m1-macos-larger-runner-for-github-actions/
target="aarch64-apple-darwin"
container="null"
bin_name="rerun"
;;
*) echo "Invalid platform" && exit 1 ;;
esac
echo "runner=$runner" >> "$GITHUB_OUTPUT"
echo "target=$target" >> "$GITHUB_OUTPUT"
echo "container=$container" >> "$GITHUB_OUTPUT"
echo "bin_name=$bin_name" >> "$GITHUB_OUTPUT"
build-rerun-cli:
name: Build rerun-cli (${{ needs.set-config.outputs.RUNNER }})
timeout-minutes: 60
needs: [set-config]
runs-on: ${{ needs.set-config.outputs.RUNNER }}
container:
image: ${{ fromJson(needs.set-config.outputs.CONTAINER) }}
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Show context
run: |
echo "GITHUB_CONTEXT": $GITHUB_CONTEXT
echo "JOB_CONTEXT": $JOB_CONTEXT
echo "INPUTS_CONTEXT": $INPUTS_CONTEXT
echo "ENV_CONTEXT": $ENV_CONTEXT
env:
ENV_CONTEXT: ${{ toJson(env) }}
GITHUB_CONTEXT: ${{ toJson(github) }}
JOB_CONTEXT: ${{ toJson(job) }}
INPUTS_CONTEXT: ${{ toJson(inputs) }}
- uses: actions/checkout@v4
with:
ref: ${{ inputs.RELEASE_COMMIT || ((github.event_name == 'pull_request' && github.event.pull_request.head.ref) || '') }}
- name: Set up Rust and Authenticate to GCS
uses: ./.github/actions/setup-rust
with:
cache_key: "build-${{ inputs.PLATFORM }}"
save_cache: false
workload_identity_provider: ${{ secrets.GOOGLE_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GOOGLE_SERVICE_ACCOUNT }}
targets: ${{ needs.set-config.outputs.TARGET }}
- uses: prefix-dev/setup-pixi@v0.10.0
with:
pixi-version: v0.71.3
- name: Build web-viewer (release)
run: pixi run rerun-build-web-release
# This does not run in the pixi environment, doing so
# causes it to select the wrong compiler on macos-arm64
- name: Build rerun-cli
run: |
pixi run cargo build \
--locked \
-p rerun-cli \
--no-default-features \
--features release_full \
--release \
--target ${{ needs.set-config.outputs.TARGET }}
# Now that we already have a CLI binary, we can use it to check whether our man page is up to date.
- name: Compare man page to CLI docs
if: runner.os == 'Linux'
run: |
pixi run ./scripts/ci/check_cli_docs.py --rerun-exe "./target/${{ needs.set-config.outputs.TARGET }}/release/${{ needs.set-config.outputs.BIN_NAME }}"
- name: Get sha
id: get-sha
run: |
full_commit="${{ inputs.RELEASE_COMMIT || ((github.event_name == 'pull_request' && github.event.pull_request.head.sha) || github.sha) }}"
echo "sha=$(echo $full_commit | cut -c1-7)" >> "$GITHUB_OUTPUT"
# Wrap the macOS binary in a Rerun.app bundle so macOS uses "Rerun" as the
# dock label / "About" name instead of falling back to the binary filename.
- name: Bundle Rerun.app (macOS)
if: inputs.PLATFORM == 'macos-arm64'
run: |
version=$(pixi run python scripts/ci/crates.py get-version)
mkdir -p bundle-out
pixi run python scripts/ci/bundle_macos_app.py \
--binary "./target/${{ needs.set-config.outputs.TARGET }}/release/${{ needs.set-config.outputs.BIN_NAME }}" \
--icon crates/viewer/re_viewer/data/app_icon_mac.png \
--info-plist scripts/ci/macos/Info.plist \
--version "$version" \
--output-dir bundle-out
tar -czf bundle-out/Rerun.app.tar.gz -C bundle-out Rerun.app
- name: "Upload rerun-cli (commit)"
uses: google-github-actions/upload-cloud-storage@v3
with:
path: "./target/${{ needs.set-config.outputs.TARGET }}/release/${{ needs.set-config.outputs.BIN_NAME }}"
destination: "rerun-builds/commit/${{ steps.get-sha.outputs.sha }}/rerun-cli/${{ inputs.PLATFORM }}"
parent: false
process_gcloudignore: false
- name: "Upload Rerun.app (commit, macOS)"
if: inputs.PLATFORM == 'macos-arm64'
uses: google-github-actions/upload-cloud-storage@v3
with:
path: "bundle-out/Rerun.app.tar.gz"
destination: "rerun-builds/commit/${{ steps.get-sha.outputs.sha }}/rerun-cli/${{ inputs.PLATFORM }}"
parent: false
process_gcloudignore: false
# The tarball is already gzip-compressed. Uploading with the action's default
# `gzip: true` sets `Content-Encoding: gzip` on the blob, so the download client
# transparently decompresses one layer while validating the checksum against the
# still-compressed stored hash — a guaranteed checksum mismatch.
gzip: false
- name: "Upload rerun-cli (adhoc)"
if: ${{ inputs.ADHOC_NAME != '' }}
uses: google-github-actions/upload-cloud-storage@v3
with:
path: "./target/${{ needs.set-config.outputs.TARGET }}/release/${{ needs.set-config.outputs.BIN_NAME }}"
destination: "rerun-builds/adhoc/${{inputs.ADHOC_NAME}}/rerun-cli/${{ inputs.PLATFORM }}"
parent: false
process_gcloudignore: false
- name: "Upload Rerun.app (adhoc, macOS)"
if: ${{ inputs.ADHOC_NAME != '' && inputs.PLATFORM == 'macos-arm64' }}
uses: google-github-actions/upload-cloud-storage@v3
with:
path: "bundle-out/Rerun.app.tar.gz"
destination: "rerun-builds/adhoc/${{inputs.ADHOC_NAME}}/rerun-cli/${{ inputs.PLATFORM }}"
parent: false
process_gcloudignore: false
# See the note on the commit upload above: keep the already-gzipped tarball raw.
gzip: false