-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathaction.yml
86 lines (82 loc) · 2.99 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
name: cargo-get
author: n.unrein@gmail.com
branding:
color: red
icon: upload
description: Get cargo package metadata
inputs:
flags:
description: "Flags to pass to cargo get (default: package name)"
required: false
options:
description: "Options to pass to cargo get"
required: false
default: ""
subcommand:
description: "Subcommand to run"
required: false
default: ""
outputs:
metadata:
description: "Cargo package metadata"
value: ${{ steps.cargo-get.outputs.metadata }}
runs:
using: composite
steps:
- if: runner.os == 'Linux'
name: Install cargo-get
run: |
download_cargo_get() {
current_target=$(rustc -Vv | grep host | cut -d ' ' -f 2)
download_link=$(curl -s https://api.github.com/repos/nicolaiunrein/cargo-get/releases/latest | grep x86_64-unknown-linux-musl\" | grep browser_download_url | cut -d: -f2,3 | tr -d '\"\ ')
mkdir -p ~/.cargo/bin/
curl -sSfLo ~/.cargo/bin/cargo-get "$download_link"
chmod +x ~/.cargo/bin/cargo-get
}
download_cargo_get || echo "Failed for some reason!"
shell: bash
- if: runner.os == 'macOS'
name: Install cargo-get
run: |
download_cargo_get() {
current_target=$(rustc -Vv | grep host | cut -d ' ' -f 2)
download_link=$(curl -s https://api.github.com/repos/nicolaiunrein/cargo-get/releases/latest | grep x86_64-apple-darwin\" | grep browser_download_url | cut -d: -f2,3 | tr -d '\"\ ')
mkdir -p ~/.cargo/bin/
curl -sSfLo ~/.cargo/bin/cargo-get "$download_link"
chmod +x ~/.cargo/bin/cargo-get
}
download_cargo_get || echo "Failed for some reason!"
shell: bash
- if: runner.os == 'Windows'
name: Install cargo-get
run: |
download_cargo_get() {
current_target=$(rustc -Vv | grep host | cut -d ' ' -f 2)
download_link=$(curl -s https://api.github.com/repos/nicolaiunrein/cargo-get/releases/latest | grep x86_64-pc-windows-gnu\" | grep browser_download_url | cut -d: -f2,3 | tr -d '\"\ ')
mkdir -p ~/.cargo/bin/
curl -sSfLo ~/.cargo/bin/cargo-get.exe "$download_link"
chmod +x ~/.cargo/bin/cargo-get.exe
}
download_cargo_get || echo "Failed for some reason!"
shell: bash
- name: Resort to building the binary if we can't find a prebuilt one
run: |
install_cargo_get() {
if [ -n "$CARGO_GET_VERSION" ]; then
cargo install cargo-get --version "$CARGO_GET_VERSION"
else
cargo install cargo-get
fi
}
if [ -x "$(command -v cargo-get)" ]; then
echo "cargo-get is already installed"
else
install_cargo_get
fi
shell: bash
- id: cargo-get
name: Cargo get metadata
run: |
metadata=$(cargo get ${{ inputs.flags }} ${{ inputs.options }} ${{ inputs.subcommand }})
echo "metadata=$metadata" >> $GITHUB_OUTPUT
shell: bash