Skip to content

Commit 90d5929

Browse files
authored
feat(cli.rs): add support to cargo-binstall, closes #4651 (#4817)
1 parent f21cbec commit 90d5929

File tree

6 files changed

+126
-0
lines changed

6 files changed

+126
-0
lines changed

.changes/cli-binstall.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"cli.rs": patch
3+
---
4+
5+
Add support to cargo-binstall.

.github/workflows/covector-version-or-publish.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,3 +171,13 @@ jobs:
171171
token: ${{ secrets.TAURI_BOT_PAT }}
172172
repository: tauri-apps/tauri
173173
event-type: publish-clijs
174+
175+
- name: Trigger cli.rs publishing workflow
176+
if: |
177+
steps.covector.outputs.successfulPublish == 'true' &&
178+
contains(steps.covector.outputs.packagesPublished, 'cli.rs')
179+
uses: peter-evans/repository-dispatch@v1
180+
with:
181+
token: ${{ secrets.TAURI_BOT_PAT }}
182+
repository: tauri-apps/tauri
183+
event-type: publish-clirs
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: publish cli.rs
2+
env:
3+
MACOSX_DEPLOYMENT_TARGET: '10.13'
4+
on:
5+
workflow_dispatch:
6+
repository_dispatch:
7+
types: [publish-clirs]
8+
9+
jobs:
10+
build:
11+
runs-on: ${{ matrix.target.platform }}
12+
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
target:
17+
- {
18+
name: 'x86_64-unknown-linux-gnu',
19+
platform: 'ubuntu-18.04',
20+
ext: ''
21+
}
22+
- { name: 'x86_64-apple-darwin', platform: 'macos-latest', ext: '' }
23+
- {
24+
name: 'x86_64-pc-windows-msvc',
25+
platform: 'windows-latest',
26+
ext: '.exe'
27+
}
28+
29+
steps:
30+
- name: Checkout
31+
uses: actions/checkout@v3
32+
33+
- name: install stable
34+
uses: actions-rs/toolchain@v1
35+
with:
36+
toolchain: stable
37+
38+
- name: install Linux dependencies
39+
if: matrix.target.platform == 'ubuntu-latest'
40+
run: |
41+
sudo apt-get update
42+
sudo apt-get install -y libgtk-3-dev
43+
44+
- name: build CLI
45+
uses: actions-rs/cargo@v1
46+
with:
47+
command: build
48+
args: --manifest-path ./tooling/cli/Cargo.toml --release
49+
50+
- name: Upload CLI
51+
uses: actions/upload-artifact@v3
52+
with:
53+
name: cargo-tauri-${{ matrix.target.name }}${{ matrix.target.ext }}
54+
path: tooling/cli/target/release/cargo-tauri${{ matrix.target.ext }}
55+
if-no-files-found: error
56+
57+
upload:
58+
needs: build
59+
runs-on: ubuntu-latest
60+
61+
steps:
62+
- name: Checkout
63+
uses: actions/checkout@v3
64+
65+
- name: Download built CLIs
66+
uses: actions/download-artifact@v3
67+
with:
68+
path: outputs
69+
70+
- name: Pack archives
71+
run: ./.scripts/ci/pack-cli.sh
72+
73+
- name: Get CLI version
74+
run: echo "CLI_VERSION=$(cat tooling/cli/metadata.json | jq '."cli.js".version' -r)" >> $GITHUB_ENV
75+
76+
- name: Publish release
77+
uses: softprops/action-gh-release@50195ba7f6f93d1ac97ba8332a178e008ad176aa
78+
with:
79+
tag_name: cli.rs-v${{ env.CLI_VERSION }}
80+
files: |
81+
outputs/cargo-tauri-*.zip
82+
outputs/cargo-tauri-*.tgz

.scripts/ci/pack-cli.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
set -euxo pipefail
3+
4+
for o in outputs/*; do
5+
pushd "$o"
6+
7+
chmod +x cargo-tauri*
8+
cp ../../tooling/cli/LICENSE* ../../tooling/cli/README.md .
9+
10+
target=$(basename "$o" | cut -d. -f1)
11+
if grep -qE '(apple|windows)' <<< "$target"; then
12+
zip "../${target}.zip" *
13+
else
14+
tar cv * | gzip -9 > "../${target}.tgz"
15+
fi
16+
17+
popd
18+
done

tooling/cli/Cargo.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,14 @@ url = { version = "2.2", features = [ "serde" ] }
8585

8686
[profile.release]
8787
lto = true
88+
89+
[package.metadata.binstall]
90+
pkg-url = "{ repo }/releases/download/cli.rs-v{ version }/{ bin }-{ target }.{ archive-format }"
91+
bin-dir = "{ bin }{ binary-ext }"
92+
pkg-fmt = "tgz"
93+
94+
[package.metadata.binstall.overrides.x86_64-pc-windows-msvc]
95+
pkg-fmt = "zip"
96+
97+
[package.metadata.binstall.overrides.x86_64-apple-darwin]
98+
pkg-fmt = "zip"

0 commit comments

Comments
 (0)