-
-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ci: Distribute compiled binary files via GitHub release #89
Conversation
UPDATE: See #91 for the currently recommended install script. To install latest release: # get latest release and host toolchain
version=$(curl -LsSf https://api.github.com/repos/taiki-e/cargo-hack/releases/latest | jq -r '.name')
host=$(rustc -Vv | grep host | sed 's/host: //')
# linux/macos
curl -LsSf https://github.com/taiki-e/cargo-hack/releases/download/v${version}/cargo-hack-v${version}-${host}.tar.gz | tar xzf -
# windows
curl -LsSf https://github.com/taiki-e/cargo-hack/releases/download/v${version}/cargo-hack-v${version}-${host}.zip -o cargo-hack.zip
7z x cargo-hack.zip |
fdb8cb2
to
59b085b
Compare
bors r+ |
Build succeeded: |
I will say, we think alike. I've been contemplating whether to file a PR for a couple days for this exact thing 😁 |
For those (like myself) looking for a single script to download it, I just added some conditionals to the above. version=$(curl -LsSf https://api.github.com/repos/taiki-e/cargo-hack/releases/latest | jq -r '.name')
host=$(rustc -Vv | grep host | sed 's/host: //')
if [ $host = 'x86_64-pc-windows-msvc' ]; then
curl -LsSf https://github.com/taiki-e/cargo-hack/releases/download/v${version}/cargo-hack-v${version}-${host}.zip -o cargo-hack.zip
7z x cargo-hack.zip
elif [ $host = 'x86_64-apple-darwin' ] || [ $host = 'x86_64-unknown-linux-gnu' ]; then
curl -LsSf https://github.com/taiki-e/cargo-hack/releases/download/v${version}/cargo-hack-v${version}-${host}.tar.gz | tar xzf -
else
echo "unsupported operating system"
exit 1
fi
Use freely, of course. |
@jhpratt Thanks, that script is really useful:) |
FWIW, if don't care about the exact name of the toolchain (usually there is no problem), using - if [ $host = 'x86_64-pc-windows-msvc' ]; then
+ if [[ $host =~ windows ]]; then
curl -LsSf https://github.com/taiki-e/cargo-hack/releases/download/v${version}/cargo-hack-v${version}-${host}.zip -o cargo-hack.zip
7z x cargo-hack.zip
- elif [ $host = 'x86_64-apple-darwin' ] || [ $host = 'x86_64-unknown-linux-gnu' ]; then
+ elif [[ $host =~ darwin|linux ]]; then |
That would definitely make things simpler. I'm currently looking into how I can still add |
And completely unrelated to my previous comment, it might be worth |
I don't know if that's the idiomatic way, but I think creating a new directory and adding that directory to mkdir ci-bin
mv cargo-hack ci-bin/
echo "$(pwd)/ci-bin" >> "${GITHUB_PATH}"
I think that's definitely a good idea, I'll try that. EDIT: filed #90 |
90: ci: Strip release binary r=taiki-e a=taiki-e #89 (comment) Co-authored-by: Taiki Endo <[email protected]>
I've no idea if you're familiar with the way the PATH env var works in Windows, but I certainly don't. Just reporting that doing the following fails on CI (I use Linux personally, and my household doesn't have any Windows machines). - name: Install cargo-hack
shell: bash
run: |
version=$(curl -LsSf https://api.github.com/repos/taiki-e/cargo-hack/releases/latest | jq -r '.name')
host=$(rustc -Vv | grep host | sed 's/host: //')
if [[ $host =~ windows ]]; then
curl -LsSf https://github.com/taiki-e/cargo-hack/releases/download/v${version}/cargo-hack-v${version}-${host}.zip -o cargo-hack.zip
7z x cargo-hack.zip
elif [[ $host =~ darwin|linux ]]; then
curl -LsSf https://github.com/taiki-e/cargo-hack/releases/download/v${version}/cargo-hack-v${version}-${host}.tar.gz | tar xzf -
else
echo "unsupported operating system"
exit 1
fi
mkdir __cargo_hack_bin
mv cargo-hack __cargo_hack_bin
echo "$(pwd)/__cargo_hack_bin" >> $GITHUB_PATH And I see that you've already implemented stripping, but given that the download is <1 second on CI in the previous link, it turns out that minor optimization will probably have an extremely small effect. |
Hmm, it's odd that mv cargo-hack $HOME/.cargo/bin/ |
Oh, this seems to be because the Unix style absolute path ( 7z x cargo-hack.zip
+ echo "$(pwd)/__cargo_hack_bin" | sed 's/^\///' | sed 's/\//:\\/' >> $GITHUB_PATH
elif [[ $host =~ darwin|linux ]]; then
curl -LsSf https://github.com/taiki-e/cargo-hack/releases/download/v${version}/cargo-hack-v${version}-${host}.tar.gz | tar xzf -
+ echo "$(pwd)/__cargo_hack_bin" >> $GITHUB_PATH
else mkdir __cargo_hack_bin
mv cargo-hack __cargo_hack_bin
- echo "$(pwd)/__cargo_hack_bin" >> $GITHUB_PATH However, the way mentioned in my comments above is simpler. version=$(curl -LsSf https://api.github.com/repos/taiki-e/cargo-hack/releases/latest | jq -r '.name')
host=$(rustc -Vv | grep host | sed 's/host: //')
if [[ $host =~ windows ]]; then
curl -LsSf https://github.com/taiki-e/cargo-hack/releases/download/v${version}/cargo-hack-v${version}-${host}.zip -o cargo-hack.zip
7z x cargo-hack.zip
elif [[ $host =~ darwin|linux ]]; then
curl -LsSf https://github.com/taiki-e/cargo-hack/releases/download/v${version}/cargo-hack-v${version}-${host}.tar.gz | tar xzf -
else
echo "unsupported operating system"
exit 1
fi
mv cargo-hack $HOME/.cargo/bin/ |
That's some odd behavior. I pulled the version=$(curl -LsSf https://api.github.com/repos/taiki-e/cargo-hack/releases/latest | jq -r '.name')
host=$(rustc -Vv | grep host | sed 's/host: //')
if [[ $host =~ windows ]]; then
curl -LsSf https://github.com/taiki-e/cargo-hack/releases/download/v${version}/cargo-hack-v${version}-${host}.zip -o cargo-hack.zip
7z x cargo-hack.zip -o~/.cargo/bin
elif [[ $host =~ darwin|linux ]]; then
curl -LsSf https://github.com/taiki-e/cargo-hack/releases/download/v${version}/cargo-hack-v${version}-${host}.tar.gz | tar xzf - -C ~/.cargo/bin
else
echo "unsupported operating system"
exit 1
fi |
Hmm, maybe it is better not to include the version number in the release binary. cross-rs/cross#457 version=$(curl -LsSf https://api.github.com/repos/taiki-e/cargo-hack/releases/latest | jq -r '.name')
curl -LsSf https://github.com/taiki-e/cargo-hack/releases/download/v${version}/cargo-hack-v${version}-x86_64-unknown-linux-gnu.tar.gz | tar xzf - -C ~/.cargo/bin after: curl -LsSf https://github.com/taiki-e/cargo-hack/releases/latest/download/cargo-hack-x86_64-unknown-linux-gnu.tar.gz | tar xzf - -C ~/.cargo/bin That said, this will break the CI that depends on the current URL. However, this issue can be avoided by distributing under both names until the next major version (0.5). UPDATE: filed #91 and released in 0.4.4 |
91: ci: Remove version number from release binaries r=taiki-e a=taiki-e See also #89 (comment) This allows installing cargo-hack with one command if you know the host os. before(current): ```sh version=$(curl -LsSf https://api.github.com/repos/taiki-e/cargo-hack/releases/latest | jq -r '.name') curl -LsSf https://github.com/taiki-e/cargo-hack/releases/download/v${version}/cargo-hack-v${version}-x86_64-unknown-linux-gnu.tar.gz | tar xzf - -C ~/.cargo/bin ``` after: ```sh curl -LsSf https://github.com/taiki-e/cargo-hack/releases/latest/download/cargo-hack-x86_64-unknown-linux-gnu.tar.gz | tar xzf - -C ~/.cargo/bin ``` Script for cross-platform installing to be also a bit simpler. before(current): #89 (comment) after: ```sh host=$(rustc -Vv | grep host | sed 's/host: //') if [[ $host =~ windows ]]; then curl -LsSf https://github.com/taiki-e/cargo-hack/releases/latest/download/cargo-hack-${host}.zip -o cargo-hack.zip 7z x cargo-hack.zip -o~/.cargo/bin elif [[ $host =~ darwin|linux ]]; then curl -LsSf https://github.com/taiki-e/cargo-hack/releases/latest/download/cargo-hack-${host}.tar.gz | tar xzf - -C ~/.cargo/bin else echo "unsupported operating system" exit 1 fi ``` To prevent breaking the CI that depends on the current URL, we will distribute under both names until the next major version (0.5). Co-authored-by: Taiki Endo <[email protected]>
) ## Motivation Closes #648 ## Solution Install cargo-hack from GitHub release instead of using cache. See also taiki-e/cargo-hack#89 and taiki-e/cargo-hack#91.
CI is currently busted due to [issues with caching `cargo-hack`][1]. Currently, we cache the `cargo-hack` executable to speed up builds by avoiding the overhead of compiling it from source in every build. Recently, `cargo-hack` has started publishing binaries on GitHub Releases. Rather than compiling it on CI and caching it, we can just download the binary instead. This ought to fix the build. See also taiki-e/cargo-hack#89 and taiki-e/cargo-hack#91. [1]: https://github.com/tower-rs/tower/runs/1425940763
CI is currently busted due to [issues with caching `cargo-hack`][1]. Currently, we cache the `cargo-hack` executable to speed up builds by avoiding the overhead of compiling it from source in every build. Recently, `cargo-hack` has started publishing binaries on GitHub Releases. Rather than compiling it on CI and caching it, we can just download the binary instead. This ought to fix the build. See also taiki-e/cargo-hack#89 and taiki-e/cargo-hack#91. [1]: https://github.com/tower-rs/tower/runs/1425940763
) Closes #648 Install cargo-hack from GitHub release instead of using cache. See also taiki-e/cargo-hack#89 and taiki-e/cargo-hack#91.
) Closes #648 Install cargo-hack from GitHub release instead of using cache. See also taiki-e/cargo-hack#89 and taiki-e/cargo-hack#91.
CI is currently busted due to [issues with caching `cargo-hack`][1]. Currently, we cache the `cargo-hack` executable to speed up builds by avoiding the overhead of compiling it from source in every build. Recently, `cargo-hack` has started publishing binaries on GitHub Releases. Rather than compiling it on CI and caching it, we can just download the binary instead. This ought to fix the build. See also taiki-e/cargo-hack#89 and taiki-e/cargo-hack#91. [1]: https://github.com/tower-rs/tower/runs/1425940763
If you install locally, I basically recommend using
cargo install
, but given that one of cargo-hack's main purposes is to use it in CI, it makes sense to distribute the compiled binary files.