feat: add visual domain randomization #12
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build Wheel | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - ".github/actions/**" | |
| - ".github/workflows/build-wheel.yml" | |
| - "native/**" | |
| - "pixi.lock" | |
| - "pixi.toml" | |
| - "packages/bricksim-domain-randomization-assets-starter/**" | |
| - "packages/bricksim-domain-randomization-assets-expanded/**" | |
| - "python/**" | |
| - "scripts/build.sh" | |
| - "scripts/materialize_domain_randomization_assets.py" | |
| - "scripts/set_domain_randomization_wheel_version.py" | |
| pull_request: | |
| paths: | |
| - ".github/actions/**" | |
| - ".github/workflows/build-wheel.yml" | |
| - "native/**" | |
| - "pixi.lock" | |
| - "pixi.toml" | |
| - "packages/bricksim-domain-randomization-assets-starter/**" | |
| - "packages/bricksim-domain-randomization-assets-expanded/**" | |
| - "python/**" | |
| - "scripts/build.sh" | |
| - "scripts/materialize_domain_randomization_assets.py" | |
| - "scripts/set_domain_randomization_wheel_version.py" | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| jobs: | |
| build-wheels: | |
| name: cp311_amd64_linux | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| submodules: recursive | |
| - name: Free disk space | |
| uses: ./.github/actions/free-disk-space | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| - name: Install pixi | |
| uses: prefix-dev/setup-pixi@v0.9.3 | |
| with: | |
| pixi-version: v0.67.0 | |
| cache: true | |
| frozen: true | |
| activate-environment: true | |
| - name: Cache BrickSim artifacts | |
| uses: ./.github/actions/cache-bricksim-artifacts | |
| - name: Compute wheel version | |
| id: version | |
| run: | | |
| base_version=$(python - <<'PY' | |
| from pathlib import Path | |
| import tomllib | |
| data = tomllib.loads(Path("python/pyproject.toml").read_text()) | |
| print(data["project"]["version"]) | |
| PY | |
| ) | |
| sequence=$(git rev-list --count --first-parent HEAD) | |
| short_sha=$(git rev-parse --short HEAD) | |
| wheel_version="${base_version}.dev${sequence}+g${short_sha}" | |
| echo "wheel_version=$wheel_version" >> "$GITHUB_OUTPUT" | |
| - name: Apply wheel version | |
| env: | |
| WHEEL_VERSION: ${{ steps.version.outputs.wheel_version }} | |
| run: python scripts/set_domain_randomization_wheel_version.py "$WHEEL_VERSION" | |
| - name: Materialize locked asset payloads | |
| run: | | |
| python scripts/materialize_domain_randomization_assets.py --package starter | |
| python scripts/materialize_domain_randomization_assets.py --package expanded | |
| - name: Build starter asset wheel | |
| working-directory: packages/bricksim-domain-randomization-assets-starter | |
| run: uv build --wheel --out-dir "$GITHUB_WORKSPACE/dist" | |
| - name: Build expanded asset wheel | |
| working-directory: packages/bricksim-domain-randomization-assets-expanded | |
| run: uv build --wheel --out-dir "$GITHUB_WORKSPACE/dist" | |
| - name: Build native extension | |
| run: pixi run build-native | |
| - name: Build runtime wheel | |
| working-directory: python | |
| run: uv build --wheel --out-dir "$GITHUB_WORKSPACE/dist" | |
| - name: Upload wheel artifacts to GitHub Actions | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheels-cp311-linux-amd64 | |
| path: dist/*.whl | |
| if-no-files-found: error | |
| compression-level: 0 | |
| publish-wheels: | |
| needs: build-wheels | |
| if: >- | |
| github.repository == 'intelligent-control-lab/BrickSim' && | |
| github.ref == 'refs/heads/main' && | |
| github.event_name == 'push' | |
| runs-on: ubuntu-22.04 | |
| permissions: | |
| contents: read | |
| id-token: write | |
| env: | |
| CLOUDSMITH_NAMESPACE: bricksim | |
| CLOUDSMITH_REPOSITORY: bricksim | |
| steps: | |
| - name: Download wheel artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: wheels-cp311-linux-amd64 | |
| path: dist | |
| - name: Authenticate with Cloudsmith via OIDC | |
| uses: cloudsmith-io/cloudsmith-cli-action@v2 | |
| with: | |
| oidc-namespace: ${{ env.CLOUDSMITH_NAMESPACE }} | |
| oidc-service-slug: bricksim-github-actions | |
| - name: Upload starter asset wheel to Cloudsmith | |
| run: cloudsmith push python "$CLOUDSMITH_NAMESPACE/$CLOUDSMITH_REPOSITORY" dist/bricksim_domain_randomization_assets_starter-*.whl --republish | |
| - name: Upload expanded asset wheel to Cloudsmith | |
| run: cloudsmith push python "$CLOUDSMITH_NAMESPACE/$CLOUDSMITH_REPOSITORY" dist/bricksim_domain_randomization_assets_expanded-*.whl --republish | |
| - name: Upload runtime wheel to Cloudsmith | |
| run: cloudsmith push python "$CLOUDSMITH_NAMESPACE/$CLOUDSMITH_REPOSITORY" dist/bricksim-*.whl --republish | |
| - name: Upload wheel pointer to Cloudsmith | |
| run: | | |
| wheel_file=$(basename dist/bricksim-*.whl) | |
| wheel_url=$(cloudsmith list packages "$CLOUDSMITH_NAMESPACE/$CLOUDSMITH_REPOSITORY" -F json -q "format:python AND filename:^${wheel_file}$" | python -c 'import json, sys; payload = json.load(sys.stdin); data = payload["data"] if isinstance(payload, dict) and "data" in payload else payload; len(data) == 1 or (_ for _ in ()).throw(SystemExit(f"Expected exactly one Cloudsmith package match, got {len(data)}")); print(data[0]["cdn_url"])') | |
| pointer_dir=$(mktemp -d) | |
| pointer_file="$pointer_dir/wheel-url.txt" | |
| printf '%s\n' "$wheel_url" > "$pointer_file" | |
| cloudsmith push generic "$CLOUDSMITH_NAMESPACE/$CLOUDSMITH_REPOSITORY" "$pointer_file" --filepath "commits/${GITHUB_SHA}/wheel-url.txt" --republish |