diff --git a/.github/actions/setup-cargo-makepad/action.yml b/.github/actions/setup-cargo-makepad/action.yml new file mode 100644 index 00000000..669cde59 --- /dev/null +++ b/.github/actions/setup-cargo-makepad/action.yml @@ -0,0 +1,19 @@ +name: Setup cargo-makepad +description: Resolve Makepad revision from Cargo.lock and install cargo-makepad. +inputs: + lockfile: + description: Path to Cargo.lock + required: false + default: Cargo.lock +runs: + using: composite + steps: + - name: Resolve Makepad revision + id: makepad + shell: bash + run: | + bash "$GITHUB_ACTION_PATH/scripts/resolve-makepad-rev.sh" "${{ inputs.lockfile }}" >> "$GITHUB_OUTPUT" + - name: Install cargo-makepad + shell: bash + run: | + cargo install --force --git "${{ steps.makepad.outputs.repo }}" --rev "${{ steps.makepad.outputs.rev }}" cargo-makepad diff --git a/.github/actions/setup-cargo-makepad/scripts/resolve-makepad-rev.sh b/.github/actions/setup-cargo-makepad/scripts/resolve-makepad-rev.sh new file mode 100644 index 00000000..63253afc --- /dev/null +++ b/.github/actions/setup-cargo-makepad/scripts/resolve-makepad-rev.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +set -euo pipefail + +lockfile="${1:-Cargo.lock}" + +source_line="$( + awk ' + $1 == "name" && $3 == "\"makepad-widgets\"" { in_pkg = 1; next } + in_pkg && $1 == "source" { print $3; exit } + in_pkg && $1 == "[[package]]" { in_pkg = 0 } + ' "$lockfile" +)" + +if [[ -z "$source_line" ]]; then + echo "error=makepad-widgets source not found in $lockfile" >&2 + exit 1 +fi + +source_line="${source_line%\"}" +source_line="${source_line#\"}" +source_line="${source_line#git+}" + +rev="${source_line##*#}" +repo_with_query="${source_line%#*}" +repo="${repo_with_query%%\?*}" + +printf 'repo=%s\n' "$repo" +printf 'rev=%s\n' "$rev" diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml index c332e0ae..eb9f144a 100644 --- a/.github/workflows/builds.yml +++ b/.github/workflows/builds.yml @@ -171,10 +171,8 @@ jobs: run: | rustup toolchain install nightly - - name: Install cargo-makepad - # The git repo and branch MUST MATCH the `makepad-widgets` dependency defined in `Cargo.toml`. - run: | - cargo install --force --git https://github.com/kevinaboos/makepad.git --branch serde_optional cargo-makepad + - name: Setup cargo-makepad + uses: ./.github/actions/setup-cargo-makepad - name: Install iOS toolchain run: | @@ -209,10 +207,8 @@ jobs: - name: Install Rust uses: dtolnay/rust-toolchain@stable - - name: Install cargo-makepad - # The git repo and branch MUST MATCH the `makepad-widgets` dependency defined in `Cargo.toml`. - run: | - cargo install --force --git https://github.com/kevinaboos/makepad.git --branch serde_optional cargo-makepad + - name: Setup cargo-makepad + uses: ./.github/actions/setup-cargo-makepad - name: Install Android toolchain run: | @@ -239,10 +235,8 @@ jobs: - name: Install Rust uses: dtolnay/rust-toolchain@stable - - name: Install cargo-makepad - # The git repo and branch MUST MATCH the `makepad-widgets` dependency defined in `Cargo.toml`. - run: | - cargo install --force --git https://github.com/kevinaboos/makepad.git --branch serde_optional cargo-makepad + - name: Setup cargo-makepad + uses: ./.github/actions/setup-cargo-makepad - name: Install Android toolchain run: | @@ -274,10 +268,8 @@ jobs: with: key: android-windows-build-${{ hashFiles('Cargo.lock') }} - - name: Install cargo-makepad - # The git repo and branch MUST MATCH the `makepad-widgets` dependency defined in `Cargo.toml`. - run: | - cargo install --force --git https://github.com/kevinaboos/makepad.git --branch serde_optional cargo-makepad + - name: Setup cargo-makepad + uses: ./.github/actions/setup-cargo-makepad - name: Install Android toolchain run: | diff --git a/Cargo.toml b/Cargo.toml index f6fc41b1..b4fa5cbb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,9 +16,6 @@ version = "0.0.1-pre-alpha-4" metadata.makepad-auto-version = "zqpv-Yj-K7WNVK2I8h5Okhho46Q=" [dependencies] -## !NOTE! When updating the makepad dependency, be sure to also change the repo and branch -## !!!!!! that are used in `builds.yml` for installing cargo makepad from git. -## !!!!!! The version (git repo + branch) installed in CI actions should the one defined here. makepad-widgets = { git = "https://github.com/kevinaboos/makepad", branch = "serde_optional", features = ["serde"] } # makepad-widgets = { git = "https://github.com/makepad/makepad", branch = "dev", features = ["serde"] }