From 3e24b3d34a10e218bcb20b94554dfc2a7cf54b1f Mon Sep 17 00:00:00 2001 From: Evan Simkowitz Date: Tue, 15 Aug 2023 11:41:32 -0700 Subject: [PATCH] Publish CLI binaries for cargo-binstall (#1358) * add test release pipeline * fix * debug * oops forgot checkout * debug * fix if * blah * fix working dir * fix cargo build path * add publish step * add cache * fix path * use package instead of working dir * fix cache path * fix typo in checksum * fix upload artifact loop * add more comments * add binstall metadata * test simplified action * fix target * remove dispatch * fix permissions * remove mac arm config * update comments * update comment * replace unmaintained actions-rs --- .github/workflows/cli_release.yml | 54 +++++++++++++++++++++++++++++++ packages/cli/Cargo.toml | 6 ++++ 2 files changed, 60 insertions(+) create mode 100644 .github/workflows/cli_release.yml diff --git a/.github/workflows/cli_release.yml b/.github/workflows/cli_release.yml new file mode 100644 index 000000000..c6c2b81e8 --- /dev/null +++ b/.github/workflows/cli_release.yml @@ -0,0 +1,54 @@ +name: Build CLI for Release + +# Will run automatically on every new release +on: + release: + types: [published] + +jobs: + build-and-upload: + permissions: + contents: write + runs-on: ${{ matrix.platform.os }} + strategy: + matrix: + platform: + - { + target: x86_64-pc-windows-msvc, + os: windows-latest, + toolchain: "1.70.0", + } + - { + target: x86_64-apple-darwin, + os: macos-latest, + toolchain: "1.70.0", + } + - { + target: x86_64-unknown-linux-gnu, + os: ubuntu-latest, + toolchain: "1.70.0", + } + steps: + - uses: actions/checkout@v3 + - name: Install stable + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ matrix.platform.toolchain }} + targets: ${{ matrix.platform.target }} + + # Setup the Github Actions Cache for the CLI package + - name: Setup cache + uses: Swatinem/rust-cache@v2 + with: + workspaces: packages/cli -> ../../target + + # This neat action can build and upload the binary in one go! + - name: Build and upload binary + uses: taiki-e/upload-rust-binary-action@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + target: ${{ matrix.platform.target }} + bin: dx + archive: dx-${{ matrix.platform.target }} + checksum: sha256 + manifest_path: packages/cli/Cargo.toml diff --git a/packages/cli/Cargo.toml b/packages/cli/Cargo.toml index 892399a9d..a37798eee 100644 --- a/packages/cli/Cargo.toml +++ b/packages/cli/Cargo.toml @@ -100,3 +100,9 @@ name = "dx" [dev-dependencies] tempfile = "3.3" + +[package.metadata.binstall] +pkg-url = "{ repo }/releases/download/v{ version }/dx-{ target }{ archive-suffix }" + +[package.metadata.binstall.overrides.x86_64-pc-windows-msvc] +pkg-fmt = "zip"