From c6cba64f779001af26db2a538e08a3d6862a2855 Mon Sep 17 00:00:00 2001 From: ryan Date: Thu, 31 Dec 2020 20:04:42 +1300 Subject: [PATCH 1/5] add a basic test on each platform --- .github/workflows/rust.yml | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 0297e174..45666e94 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -134,3 +134,40 @@ jobs: release_name: Release ${{ github.ref }} body: Release ${{ github.ref }} + test: + + runs-on: ${{ matrix.os }} + continue-on-error: ${{ matrix.experimental }} + + strategy: + fail-fast: false + matrix: + include: + - target: x86_64-unknown-linux-gnu + os: ubuntu-latest + output: cargo-binstall + - target: x86_64-apple-darwin + os: macos-latest + output: cargo-binstall + - target: armv7-unknown-linux-gnueabihf + os: ubuntu-20.04 + output: cargo-binstall + - target: x86_64-pc-windows-msvc + os: windows-latest + output: cargo-binstall.exe + + + steps: + - uses: actions/checkout@v2 + - uses: FranzDiebold/github-env-vars-action@v1.2.1 + + - uses: actions/download-artifact@v2 + with: + name: cargo-binstall-${{ matrix.target }}.tgz + + - name: "Extract build artifact" + run: tar -xvf cargo-binstall-${{ matrix.target }}.tgz + + - name: "Run binstall" + run: ${{ matrix.output }} cargo-binstall --manifest-path . + From 80a217b0cd2093debb7f28ebea284ed79305b0bd Mon Sep 17 00:00:00 2001 From: ryan Date: Thu, 31 Dec 2020 20:05:35 +1300 Subject: [PATCH 2/5] remove armv7 from testing --- .github/workflows/rust.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 45666e94..f47a2be2 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -149,9 +149,6 @@ jobs: - target: x86_64-apple-darwin os: macos-latest output: cargo-binstall - - target: armv7-unknown-linux-gnueabihf - os: ubuntu-20.04 - output: cargo-binstall - target: x86_64-pc-windows-msvc os: windows-latest output: cargo-binstall.exe From fd16c171e2cb94743ec9aa92ab9ba191bab1f4e1 Mon Sep 17 00:00:00 2001 From: ryan Date: Thu, 31 Dec 2020 20:27:34 +1300 Subject: [PATCH 3/5] update readme, reorder tests --- .github/workflows/rust.yml | 37 ++++++++----------- README.md | 76 +++++++++++++++++--------------------- 2 files changed, 49 insertions(+), 64 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index f47a2be2..7d01a8c8 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -14,7 +14,6 @@ jobs: build: runs-on: ${{ matrix.os }} - continue-on-error: ${{ matrix.experimental }} strategy: fail-fast: false @@ -23,19 +22,15 @@ jobs: - target: x86_64-unknown-linux-gnu os: ubuntu-latest output: cargo-binstall - experimental: false - target: x86_64-apple-darwin os: macos-latest output: cargo-binstall - experimental: false - target: armv7-unknown-linux-gnueabihf os: ubuntu-20.04 output: cargo-binstall - experimental: true - target: x86_64-pc-windows-msvc os: windows-latest output: cargo-binstall.exe - experimental: true steps: - uses: actions/checkout@v2 @@ -118,26 +113,9 @@ jobs: tag: ${{ github.ref }} overwrite: true - release: - name: Upload firmware artifacts to release - runs-on: ubuntu-latest - if: ${{ startsWith(github.ref, 'refs/tags/v') }} - steps: - - - name: Create Release - uses: actions/create-release@v1 - id: create_release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ github.ref }} - release_name: Release ${{ github.ref }} - body: Release ${{ github.ref }} - test: runs-on: ${{ matrix.os }} - continue-on-error: ${{ matrix.experimental }} strategy: fail-fast: false @@ -168,3 +146,18 @@ jobs: - name: "Run binstall" run: ${{ matrix.output }} cargo-binstall --manifest-path . + release: + name: Upload firmware artifacts to release + runs-on: ubuntu-latest + if: ${{ startsWith(github.ref, 'refs/tags/v') }} + steps: + + - name: Create Release + uses: actions/create-release@v1 + id: create_release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + body: Release ${{ github.ref }} diff --git a/README.md b/README.md index a626ee77..2ee2e539 100644 --- a/README.md +++ b/README.md @@ -19,9 +19,9 @@ To support `binstall` maintainers must add configuration values to `Cargo.toml` ## Features - Manifest discovery - - [x] Fetch crate/manifest via crates.io - - [ ] Fetch crate/manifest via git - - [x] Use local crate/manifest (`--manifest-path`) + - [x] Fetch crate / manifest via crates.io + - [ ] Fetch crate / manifest via git + - [x] Use local crate / manifest (`--manifest-path`) - Package formats - [x] Tgz - [x] Tar @@ -38,6 +38,32 @@ To support `binstall` maintainers must add configuration values to `Cargo.toml` `binstall` works with existing CI-built binary outputs, with configuration via `[package.metadata.binstall]` keys in the relevant crate manifest. When configuring `binstall` you can test against a local manifest with `--manifest-path=PATH` argument to use the crate and manifest at the provided `PATH`, skipping crate discovery and download. +To get started, add a `[package.metadata.binstall]` section to your `Cargo.toml. As an example, the default configuration would be: + +```toml +[package.metadata.binstall] +pkg-url = "{ repo }/releases/download/v{ version }/{ name }-{ target }-v{ version }.{ format }" +bin-dir = "{ name }-{ target }-v{ version }/{ bin }{ format }" +pkg-fmt = "tgz" +``` + +With the following configuration keys: + +- `pkg-url` specifies the package download URL for a given target/version, templated +- `bin-path` specifies the binary path within the package, templated (with an `.exe` suffix on windows) +- `pkg-fmt` overrides the package format for download/extraction (defaults to: `tgz`) + + +`pkg-url` and `bin-path` are templated to support different names for different versions / architectures / etc. +Template variables use the format `{ VAR }` where `VAR` is the name of the variable, with the following variables available: +- `name` is the name of the crate / package +- `version` is the crate version (per `--version` and the crate manifest) +- `repo` is the repository linked in `Cargo.toml` +- `bin` is the name of a specific binary, inferred from the crate configuration +- `target` is the rust target name (defaults to your architecture, but can be overridden using the `--target` command line option if required(). + + +### Defaults By default `binstall` is setup to work with github releases, and expects to find: @@ -49,43 +75,11 @@ By default `binstall` is setup to work with github releases, and expects to find - so that prior binary files are not overwritten when manually executing `tar -xvf ...` - containing binary files in the form `{ bin }{ format }` (where `bin` is the cargo binary name and `format` is `.exe` on windows and empty on other platforms) - -These defaults can be overridden using the following configuration keys: - -- `pkg-url` specifies the binary package URL for a given target/version, templated (defaults to: `{ repo }/releases/download/v{ version }/{ name }-{ target }-v{ version }.{ format }`) -- `bin-path` specifies the binary path within the package, templated (defaults to: `{ name }-{ target }-v{ version }/{ bin }` with a `.exe` suffix on windows) -- `pkg-fmt` overrides the package format for download/extraction (defaults to: `tgz`) - - -Template variables use the format `{ VAR }` where `VAR` is the name of the variable, with the following variables available: -- `name` is the name of the crate / package -- `version` is the crate version (per `--version` and the crate manifest) -- `repo` is the repository linked in `Cargo.toml` -- `bin` is the name of a specific binary, inferred from the crate configuration -- `target` is the rust target name (defaults to your architecture, but can be overridden using the `--target` command line option if required(). - - -### Operation - -- Lookup a viable crate version (currently via `crates.io`, in future via git tags too) -- Download crate snapshot (currently via `crates.io`) -- Parse configuration metadata and binary information from the downloaded snapshot -- Download and extract binary package using configured URL (`pkg-url`, `pkg-fmt`) -- Install versioned binary files to the relevant install dir -- Generate symlinks to versioned binaries +If your package already uses this approach, you shouldn't need to set anything. ### Examples -For example, the default configuration (if specified in `Cargo.toml`) would be: - -```toml -[package.metadata.binstall] -pkg-url = "{ repo }/releases/download/v{ version }/{ name }-{ target }-v{ version }.{ format }" -bin-dir = "{ name }-{ target }-v{ version }/{ bin }{ format }" -pkg-fmt = "tgz" -``` - -For a crate called `radio-sx128x` ( at version `v0.14.1-alpha.5` on x86_64 linux), this would be interpolated to: +For example, the default configuration (as shown above) for a crate called `radio-sx128x` (version: `v0.14.1-alpha.5` on x86_64 linux) would be interpolated to: - A download URL of `https://github.com/rust-iot/rust-radio-sx128x/releases/download/v0.14.1-alpha.5/rust-radio-sx128x-x86_64-unknown-linux-gnu-v0.14.1-alpha.5.tgz` - Containing a single binary file `rust-radio-sx128x-x86_64-unknown-linux-gnu-v0.14.1-alpha.5/rust-radio-x86_64-unknown-linux-gnu` @@ -94,7 +88,7 @@ For a crate called `radio-sx128x` ( at version `v0.14.1-alpha.5` on x86_64 linux #### If the package name does not match the crate name -As is common with libraries / utilities (and the `radio-sx128x` example), this can be overridden by specifying: +As is common with libraries / utilities (and the `radio-sx128x` example), this can be overridden by specifying the `pkg-url`: ```toml [package.metadata.binstall] @@ -106,16 +100,14 @@ Which provides a download URL of: `https://github.com/rust-iot/rust-radio-sx128x #### If the package structure differs from the default -While it's nice to have the default format discussed above, often it's not the case... - -Were the package to contain binaries in the form `name-target[.exe]`, this could be specified as: +Were the package to contain binaries in the form `name-target[.exe]`, this could be overridden using the `bin-dir` key: ```toml [package.metadata.binstall] bin-dir = "{ bin }-{ target }{ format }" ``` -Which provides a binary path of: `sx128x-util-x86_64-unknown-linux-gnu[.exe]` (binary names are inferred from the crate, so long as cargo builds them this _should_ just work). +Which provides a binary path of: `sx128x-util-x86_64-unknown-linux-gnu[.exe]`. It is worth noting that binary names are inferred from the crate, so long as cargo builds them this _should_ just work. --- From f8f64a7a560014b846e73d37825738e2644f2564 Mon Sep 17 00:00:00 2001 From: ryan Date: Thu, 31 Dec 2020 20:30:15 +1300 Subject: [PATCH 4/5] add needs between ci steps --- .github/workflows/rust.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 7d01a8c8..2e383256 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -12,7 +12,6 @@ env: jobs: build: - runs-on: ${{ matrix.os }} strategy: @@ -116,7 +115,7 @@ jobs: test: runs-on: ${{ matrix.os }} - + needs: build strategy: fail-fast: false matrix: @@ -149,6 +148,7 @@ jobs: release: name: Upload firmware artifacts to release runs-on: ubuntu-latest + needs: build if: ${{ startsWith(github.ref, 'refs/tags/v') }} steps: From cf01c9e6f21bfc8324a51609a2fef8592db9c522 Mon Sep 17 00:00:00 2001 From: ryan Date: Thu, 31 Dec 2020 20:46:59 +1300 Subject: [PATCH 5/5] cleaning up tests --- .github/workflows/rust.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 2e383256..8cbee35f 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -12,6 +12,7 @@ env: jobs: build: + name: Build runs-on: ${{ matrix.os }} strategy: @@ -63,7 +64,7 @@ jobs: if: ${{ matrix.target == 'armv7-unknown-linux-gnueabihf' }} run: sudo apt install gcc-arm-linux-gnueabihf - - name: Enable cross compilation + - name: Enable cross compilation (armv7) if: ${{ matrix.target == 'armv7-unknown-linux-gnueabihf' }} run: | echo "PKG_CONFIG_ALLOW_CROSS=1" >> $GITHUB_ENV @@ -83,7 +84,7 @@ jobs: uses: actions/cache@v2 with: key: ${{ matrix.os }}-${{ matrix.target }} - path: C:/vcpkg/installed + path: C:/vcpkg - name: Build release uses: actions-rs/cargo@v1 @@ -112,8 +113,9 @@ jobs: tag: ${{ github.ref }} overwrite: true - test: + test: + name: Test runs-on: ${{ matrix.os }} needs: build strategy: @@ -130,7 +132,6 @@ jobs: os: windows-latest output: cargo-binstall.exe - steps: - uses: actions/checkout@v2 - uses: FranzDiebold/github-env-vars-action@v1.2.1 @@ -143,12 +144,13 @@ jobs: run: tar -xvf cargo-binstall-${{ matrix.target }}.tgz - name: "Run binstall" - run: ${{ matrix.output }} cargo-binstall --manifest-path . + run: ./${{ matrix.output }} cargo-binstall --manifest-path . --no-confirm + release: name: Upload firmware artifacts to release runs-on: ubuntu-latest - needs: build + needs: test if: ${{ startsWith(github.ref, 'refs/tags/v') }} steps: