Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local-first wheel publishing #4454

Merged
merged 16 commits into from
Dec 11, 2023
Merged
4 changes: 2 additions & 2 deletions .github/workflows/on_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ jobs:
min-wheel-build:
name: "Minimum Wheel Build"
if: github.event.pull_request.head.repo.owner.login == 'rerun-io'
uses: ./.github/workflows/reusable_build_wheels.yml
uses: ./.github/workflows/reusable_build_and_upload_wheels.yml
with:
CONCURRENCY: pr-${{ github.event.pull_request.number }}
MODE: "pr"
PLATFORM: linux
MATURIN_FEATURE_FLAGS: "--no-default-features --features extension-module"
WHEEL_ARTIFACT_NAME: "linux-wheel-fast"
secrets: inherit

Expand Down
66 changes: 16 additions & 50 deletions .github/workflows/on_push_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,42 +182,46 @@ jobs:

build-wheel-linux:
needs: [checks]
name: "Linux: Build Wheels"
uses: ./.github/workflows/reusable_build_wheels.yml
name: "Linux: Build & Upload Wheels"
uses: ./.github/workflows/reusable_build_and_upload_wheels.yml
with:
CONCURRENCY: push-linux-${{ github.ref_name }}
PLATFORM: linux
WHEEL_ARTIFACT_NAME: linux-wheel
MODE: "pypi"
secrets: inherit

build-wheel-windows:
needs: [checks]
name: "Windows: Build Wheels"
uses: ./.github/workflows/reusable_build_wheels.yml
name: "Windows: Build & Upload Wheels"
uses: ./.github/workflows/reusable_build_and_upload_wheels.yml
with:
CONCURRENCY: push-windows-${{ github.ref_name }}
PLATFORM: windows
WHEEL_ARTIFACT_NAME: windows-wheel
MODE: "pypi"
secrets: inherit

build-wheel-macos-arm:
needs: [checks]
name: "Macos-Arm: Build Wheels"
uses: ./.github/workflows/reusable_build_wheels.yml
name: "Macos-Arm: Build & Upload Wheels"
uses: ./.github/workflows/reusable_build_and_upload_wheels.yml
with:
CONCURRENCY: push-macos-arm-${{ github.ref_name }}
PLATFORM: macos-arm
WHEEL_ARTIFACT_NAME: macos-arm-wheel
MODE: "pypi"
secrets: inherit

build-wheel-macos-intel:
needs: [checks]
name: "Macos-Intel: Build Wheels"
uses: ./.github/workflows/reusable_build_wheels.yml
name: "Macos-Intel: Build & Upload Wheels"
uses: ./.github/workflows/reusable_build_and_upload_wheels.yml
with:
CONCURRENCY: push-macos-intel-${{ github.ref_name }}
PLATFORM: macos-intel
WHEEL_ARTIFACT_NAME: "macos-intel-wheel"
MODE: "pypi"
secrets: inherit

test-wheel-linux:
Expand All @@ -240,52 +244,14 @@ jobs:
WHEEL_ARTIFACT_NAME: windows-wheel
secrets: inherit

# NOTE: We currently don't test wheels on macos-arm/macos-intel

upload-wheels-linux:
name: "Linux: Upload Wheels"
needs: [build-wheel-linux]
uses: ./.github/workflows/reusable_upload_wheels.yml
with:
CONCURRENCY: push-linux-${{ github.ref_name }}
WHEEL_ARTIFACT_NAME: linux-wheel
secrets: inherit

upload-wheels-windows:
name: "Windows: Upload Wheels"
needs: [build-wheel-windows]
uses: ./.github/workflows/reusable_upload_wheels.yml
with:
CONCURRENCY: push-windows-${{ github.ref_name }}
WHEEL_ARTIFACT_NAME: windows-wheel
secrets: inherit

upload-wheels-macos-arm:
name: "Macos-Arm: Upload Wheels"
needs: [build-wheel-macos-arm]
uses: ./.github/workflows/reusable_upload_wheels.yml
with:
CONCURRENCY: push-macos-arm-${{ github.ref_name }}
WHEEL_ARTIFACT_NAME: macos-arm-wheel
secrets: inherit

upload-wheels-macos-intel:
name: "Macos-Intel: Upload Wheels"
needs: [build-wheel-macos-intel]
uses: ./.github/workflows/reusable_upload_wheels.yml
with:
CONCURRENCY: push-macos-intel-${{ github.ref_name }}
WHEEL_ARTIFACT_NAME: macos-intel-wheel
secrets: inherit

generate-pip-index:
name: "Generate Pip Index"
needs:
[
upload-wheels-linux,
upload-wheels-windows,
upload-wheels-macos-arm,
upload-wheels-macos-intel,
build-wheel-linux,
build-wheel-windows,
build-wheel-macos-arm,
build-wheel-macos-intel,
]
uses: ./.github/workflows/reusable_pip_index.yml
with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ on:
CONCURRENCY:
required: true
type: string
MATURIN_FEATURE_FLAGS:
required: false
MODE:
description: "The build mode, either `pypi` or `pr`"
required: true
type: string
default: "--no-default-features --features pypi"
PLATFORM:
required: true
type: string
Expand Down Expand Up @@ -125,45 +125,31 @@ jobs:
workload_identity_provider: ${{ secrets.GOOGLE_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GOOGLE_SERVICE_ACCOUNT }}

- uses: prefix-dev/[email protected]
with:
pixi-version: v0.6.0

- name: Install dependencies
shell: bash
run: |
pixi run rustup target add ${{ needs.set-config.outputs.TARGET }}
pixi run pip install -r rerun_py/requirements-build.txt
rustup target add ${{ needs.set-config.outputs.TARGET }}
pip install -r rerun_py/requirements-build.txt
pip install google-cloud-storage==2.9.0

- name: Build web-viewer
# only build web-viewer when publishing to pypi
if: ${{ contains(inputs.MATURIN_FEATURE_FLAGS, 'pypi') }}
- name: Get sha
id: get-sha
shell: bash
run: |
pixi run cargo run --locked -p re_build_web_viewer -- --release
full_commit="${{ inputs.RELEASE_COMMIT || ((github.event_name == 'pull_request' && github.event.pull_request.head.ref) || github.sha) }}"
echo "sha=$(echo $full_commit | cut -c1-7)" >> "$GITHUB_OUTPUT"

# This does not run in the pixi environment, doing so
# causes it to select the wrong compiler on macos-arm
- name: Build Wheel
uses: PyO3/maturin-action@v1
env:
# this stops `re_web_viewer_server/build.rs` from running
RERUN_IS_PUBLISHING: true
with:
maturin-version: "0.14.17"
manylinux: manylinux_2_31
container: off
command: build
args: |
--manifest-path rerun_py/Cargo.toml
--release
--target ${{ needs.set-config.outputs.TARGET }}
${{ inputs.MATURIN_FEATURE_FLAGS }}
--out dist
- name: Build
shell: bash
run: |
python3 scripts/ci/build_and_upload_wheels.py \
--mode ${{ inputs.MODE }} \
--target ${{ needs.set-config.outputs.TARGET }} \
--dir commit/${{ steps.get-sha.outputs.sha }}/wheels

- name: Save wheel artifact
if: ${{ inputs.WHEEL_ARTIFACT_NAME != '' }}
uses: actions/upload-artifact@v3
with:
name: ${{inputs.WHEEL_ARTIFACT_NAME}}
path: dist
path: dist/${{ needs.set-config.outputs.TARGET }}
Comment on lines 151 to +156
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does anything use the intermediate github artifact now, or can this go away with everything just using gcloud?

Copy link
Member Author

@jprochazk jprochazk Dec 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are jobs using it still, but it's possible to remove it altogether. would like to leave that for another PR

9 changes: 7 additions & 2 deletions .github/workflows/reusable_pip_index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ jobs:
- name: Render pip index and upload to gcloud
shell: bash
run: |
full_commit="${{ inputs.COMMIT || (github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha) }}"
commit=$(echo $full_commit | cut -c1-7)

python scripts/ci/generate_prerelease_pip_index.py \
--commit ${{ github.sha }} \
--upload
--title "Commit: $commit" \
--dir "commit/$commit/wheels" \
--upload \
--check
95 changes: 22 additions & 73 deletions .github/workflows/reusable_publish_wheels.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
name: Build and publish wheels

# To run this manually:
# 1. Build each platform using `scripts/ci/build_and_upload_wheels.py`
# 2. (optional) Generate index using `scripts/ci/generate_prerelease_pip_index.py`
# 3. Publish to PyPI using `scripts/ci/publish_wheels.py`

on:
workflow_call:
inputs:
Expand Down Expand Up @@ -42,45 +47,49 @@ jobs:
build-linux:
name: "Linux: Build Wheels"
needs: [get-commit-sha]
uses: ./.github/workflows/reusable_build_wheels.yml
uses: ./.github/workflows/reusable_build_and_upload_wheels.yml
with:
CONCURRENCY: wheels-build-linux-${{ inputs.concurrency }}
PLATFORM: linux
WHEEL_ARTIFACT_NAME: ${{ inputs.linux-wheel-name }}
RELEASE_COMMIT: ${{ inputs.release-commit }}
MODE: "pypi"
secrets: inherit

build-windows:
name: "Windows: Build Wheels"
needs: [get-commit-sha]
uses: ./.github/workflows/reusable_build_wheels.yml
uses: ./.github/workflows/reusable_build_and_upload_wheels.yml
with:
CONCURRENCY: wheels-build-windows-${{ inputs.concurrency }}
PLATFORM: windows
WHEEL_ARTIFACT_NAME: windows-wheel
RELEASE_COMMIT: ${{ inputs.release-commit }}
MODE: "pypi"
secrets: inherit

build-macos-arm:
name: "Macos-Arm: Build Wheels"
needs: [get-commit-sha]
uses: ./.github/workflows/reusable_build_wheels.yml
uses: ./.github/workflows/reusable_build_and_upload_wheels.yml
with:
CONCURRENCY: wheels-build-macos-arm-${{ inputs.concurrency }}
PLATFORM: macos-arm
WHEEL_ARTIFACT_NAME: macos-arm-wheel
RELEASE_COMMIT: ${{ inputs.release-commit }}
MODE: "pypi"
secrets: inherit

build-macos-intel:
name: "Macos-Intel: Build Wheels"
needs: [get-commit-sha]
uses: ./.github/workflows/reusable_build_wheels.yml
uses: ./.github/workflows/reusable_build_and_upload_wheels.yml
with:
CONCURRENCY: wheels-build-macos-intel-${{ inputs.concurrency }}
PLATFORM: macos-intel
WHEEL_ARTIFACT_NAME: "macos-intel-wheel"
RELEASE_COMMIT: ${{ inputs.release-commit }}
MODE: "pypi"
secrets: inherit

## Test
Expand All @@ -107,57 +116,9 @@ jobs:
RELEASE_COMMIT: ${{ inputs.release-commit }}
secrets: inherit

## Upload

upload-wheels-linux:
name: "Linux: Upload Wheels"
needs: [test-linux]
uses: ./.github/workflows/reusable_upload_wheels.yml
with:
CONCURRENCY: wheels-upload-linux-${{ inputs.concurrency }}
WHEEL_ARTIFACT_NAME: ${{ inputs.linux-wheel-name }}
RELEASE_COMMIT: ${{ inputs.release-commit }}
secrets: inherit

upload-wheels-windows:
name: "Windows: Upload Wheels"
needs: [test-windows]
uses: ./.github/workflows/reusable_upload_wheels.yml
with:
CONCURRENCY: wheels-upload-windows-${{ inputs.concurrency }}
WHEEL_ARTIFACT_NAME: windows-wheel
RELEASE_COMMIT: ${{ inputs.release-commit }}
secrets: inherit

upload-wheels-macos-arm:
name: "Macos-Arm: Upload Wheels"
needs: [build-macos-arm]
uses: ./.github/workflows/reusable_upload_wheels.yml
with:
CONCURRENCY: wheels-upload-macos-arm-${{ inputs.concurrency }}
WHEEL_ARTIFACT_NAME: macos-arm-wheel
RELEASE_COMMIT: ${{ inputs.release-commit }}
secrets: inherit

upload-wheels-macos-intel:
name: "Macos-Intel: Upload Wheels"
needs: [build-macos-intel]
uses: ./.github/workflows/reusable_upload_wheels.yml
with:
CONCURRENCY: wheels-upload-macos-intel-${{ inputs.concurrency }}
WHEEL_ARTIFACT_NAME: macos-intel-wheel
RELEASE_COMMIT: ${{ inputs.release-commit }}
secrets: inherit

generate-wheel-index:
name: "Generate Pip Index"
needs:
[
upload-wheels-linux,
upload-wheels-windows,
upload-wheels-macos-arm,
upload-wheels-macos-intel,
]
needs: [build-linux, build-windows, build-macos-arm, build-macos-intel]
uses: ./.github/workflows/reusable_pip_index.yml
with:
CONCURRENCY: generate-wheel-index-${{ inputs.concurrency }}
Expand Down Expand Up @@ -186,28 +147,16 @@ jobs:
with:
version: ">= 363.0.0"

- name: Install packaging
- name: Install dependencies
shell: bash
run: |
python3 -m pip install packaging google-cloud-storage
python3 -m pip install packaging==23.1 google-cloud-storage==2.9.0

- name: Download wheels from Google Cloud Storage
shell: bash
run: |
mkdir wheels
gsutil cp "gs://rerun-builds/commit/${{ needs.get-commit-sha.outputs.short-sha }}/wheels/*.whl" wheels/

- name: Verify wheels match the expected release
- name: Publish to PyPI
shell: bash
run: |
python3 scripts/ci/verify_wheels.py --folder wheels --version ${{ inputs.release-version }}

- name: Publish to PyPI
uses: PyO3/maturin-action@v1
env:
# These are both set in the GitHub project configuration
MATURIN_REPOSITORY: ${{ vars.PYPI_REPOSITORY }}
MATURIN_PYPI_TOKEN: ${{ secrets.MATURIN_PYPI_TOKEN }}
with:
command: upload
args: --skip-existing wheels/*
python3 scripts/ci/publish_wheels.py \
--version ${{ inputs.release-version }} \
--dir "commit/${{ needs.get-commit-sha.outputs.short-sha }}/wheels" \
--repository "${{ vars.PYPI_REPOSITORY }}" \
--token "${{ secrets.MATURIN_PYPI_TOKEN }}" \
Loading
Loading