Skip to content

Commit

Permalink
feat(cli.rs): add support to cargo-binstall, closes #4651 (#4817)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog authored Aug 2, 2022
1 parent f21cbec commit 90d5929
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changes/cli-binstall.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"cli.rs": patch
---

Add support to cargo-binstall.
10 changes: 10 additions & 0 deletions .github/workflows/covector-version-or-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,13 @@ jobs:
token: ${{ secrets.TAURI_BOT_PAT }}
repository: tauri-apps/tauri
event-type: publish-clijs

- name: Trigger cli.rs publishing workflow
if: |
steps.covector.outputs.successfulPublish == 'true' &&
contains(steps.covector.outputs.packagesPublished, 'cli.rs')
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.TAURI_BOT_PAT }}
repository: tauri-apps/tauri
event-type: publish-clirs
File renamed without changes.
82 changes: 82 additions & 0 deletions .github/workflows/publish-cli-rs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: publish cli.rs
env:
MACOSX_DEPLOYMENT_TARGET: '10.13'
on:
workflow_dispatch:
repository_dispatch:
types: [publish-clirs]

jobs:
build:
runs-on: ${{ matrix.target.platform }}

strategy:
fail-fast: false
matrix:
target:
- {
name: 'x86_64-unknown-linux-gnu',
platform: 'ubuntu-18.04',
ext: ''
}
- { name: 'x86_64-apple-darwin', platform: 'macos-latest', ext: '' }
- {
name: 'x86_64-pc-windows-msvc',
platform: 'windows-latest',
ext: '.exe'
}

steps:
- name: Checkout
uses: actions/checkout@v3

- name: install stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable

- name: install Linux dependencies
if: matrix.target.platform == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev
- name: build CLI
uses: actions-rs/cargo@v1
with:
command: build
args: --manifest-path ./tooling/cli/Cargo.toml --release

- name: Upload CLI
uses: actions/upload-artifact@v3
with:
name: cargo-tauri-${{ matrix.target.name }}${{ matrix.target.ext }}
path: tooling/cli/target/release/cargo-tauri${{ matrix.target.ext }}
if-no-files-found: error

upload:
needs: build
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Download built CLIs
uses: actions/download-artifact@v3
with:
path: outputs

- name: Pack archives
run: ./.scripts/ci/pack-cli.sh

- name: Get CLI version
run: echo "CLI_VERSION=$(cat tooling/cli/metadata.json | jq '."cli.js".version' -r)" >> $GITHUB_ENV

- name: Publish release
uses: softprops/action-gh-release@50195ba7f6f93d1ac97ba8332a178e008ad176aa
with:
tag_name: cli.rs-v${{ env.CLI_VERSION }}
files: |
outputs/cargo-tauri-*.zip
outputs/cargo-tauri-*.tgz
18 changes: 18 additions & 0 deletions .scripts/ci/pack-cli.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
set -euxo pipefail

for o in outputs/*; do
pushd "$o"

chmod +x cargo-tauri*
cp ../../tooling/cli/LICENSE* ../../tooling/cli/README.md .

target=$(basename "$o" | cut -d. -f1)
if grep -qE '(apple|windows)' <<< "$target"; then
zip "../${target}.zip" *
else
tar cv * | gzip -9 > "../${target}.tgz"
fi

popd
done
11 changes: 11 additions & 0 deletions tooling/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,14 @@ url = { version = "2.2", features = [ "serde" ] }

[profile.release]
lto = true

[package.metadata.binstall]
pkg-url = "{ repo }/releases/download/cli.rs-v{ version }/{ bin }-{ target }.{ archive-format }"
bin-dir = "{ bin }{ binary-ext }"
pkg-fmt = "tgz"

[package.metadata.binstall.overrides.x86_64-pc-windows-msvc]
pkg-fmt = "zip"

[package.metadata.binstall.overrides.x86_64-apple-darwin]
pkg-fmt = "zip"

0 comments on commit 90d5929

Please sign in to comment.