-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathaction.yml
68 lines (60 loc) · 2.18 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
name: 'Rust Toolchain'
description: 'Set the Rust Toolchain to a specific version'
inputs:
components: # id of input
description: 'Extra components to install'
required: false
default: ''
packages:
description: 'Extra packages to install'
required: false
default: ''
runs:
using: "composite"
steps:
- name: Get Rust Version from Cargo.toml
if: "${{ env.RUST_VERSION == '' }}"
run: |
set -e
# Install toml to json cli
npm i -g toml-cli
echo "RUST_VERSION=$(cat Cargo.toml 2>/dev/null | toml | jq -r 'try(.package."rust-version") // try(.package."rust") // "stable"')" >> $GITHUB_ENV
echo "PKG_VERSION=$(cat Cargo.toml 2>/dev/null | toml | jq -r '.package.version')" >> $GITHUB_ENV
# Clean older versions of rustfmt and cargo-fmt to prevent warnings
rm -f /home/runner/.cargo/bin/rustfmt
rm -f /home/runner/.cargo/bin/cargo-fmt
shell: bash
- run: |
curl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused -fsSL "https://sh.rustup.rs" | sh -s -- --default-toolchain none -y
echo "${CARGO_HOME:-$HOME/.cargo}/bin" >> $GITHUB_PATH
shell: bash
- if: "${{ inputs.components == '' }}"
name: Install Rust toolchain
id: toolchain
run: |
rustup toolchain install ${{ env.RUST_VERSION }} --no-self-update
rustup default ${{ env.RUST_VERSION }}
shell: bash
- if: "${{ inputs.components != '' }}"
name: Install Rust toolchain and components
id: toolchain_components
run: |
rustup toolchain install ${{ env.RUST_VERSION }} --component ${{ inputs.components }} --no-self-update
rustup default ${{ env.RUST_VERSION }}
shell: bash
- name: Display Rust Version
run: |
rustc --version --verbose
cargo --version --verbose
shell: bash
- name: Install Protoc
uses: sbtaylor15/[email protected]
with:
version: '3.x'
repo-token: ${{ github.token }}
- if: "${{ inputs.packages != '' }}"
name: Install Additional Packages
id: toolchain_packages
run: |
cargo install ${{ inputs.packages }}
shell: bash