-
Notifications
You must be signed in to change notification settings - Fork 5
135 lines (115 loc) · 3.85 KB
/
rust.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: Rust
on:
push:
branches: [ master ]
tags: [ 'v*' ]
pull_request:
branches: [ master ]
env:
CARGO_TERM_COLOR: always
jobs:
build-util:
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
output: cp2130-util
use_cross: false
experimental: false
- target: armv7-unknown-linux-gnueabihf
os: ubuntu-latest
output: cp2130-util
use_cross: true
experimental: true
- target: x86_64-apple-darwin
os: macos-latest
output: cp2130-util
use_cross: false
experimental: false
- target: x86_64-pc-windows-msvc
os: windows-latest
output: cp2130-util.exe
use_cross: false
experimental: true
steps:
- uses: actions/checkout@v2
- uses: FranzDiebold/[email protected]
- name: Configure toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
target: ${{ matrix.target }}
override: true
- name: Configure caching
uses: actions/cache@v2
with:
key: ${{ matrix.os }}-${{ matrix.target }}
path: |
${{ env.HOME }}/.cargo"
target
- name: Install libusb (brew)
if: ${{ matrix.os == 'macos-latest' }}
run: brew install libusb
- name: Install libusb (apt native)
if: ${{ matrix.os == 'ubuntu-latest' && matrix.target == 'x86_64-unknown-linux-gnu' }}
run: sudo apt install -y libusb-1.0-0 libusb-1.0-0-dev
- name: Install libusb (apt armv7)
if: ${{ matrix.os == 'ubuntu-latest' && matrix.target == 'armv7-unknown-linux-gnueabihf' }}
uses: ryankurte/[email protected]
with:
arch: armhf
packages: libusb-1.0-0:armhf libusb-1.0-0-dev:armhf
- name: Install libusb (vcpkg)
if: ${{ matrix.os == 'windows-latest' }}
run: |
vcpkg integrate install
vcpkg install libusb:x64-windows-static
echo "LIBUSB_DIR=C:/vcpkg/installed/x64-windows-static/" >> $GITHUB_ENV
- name: Cache vcpkg
if: ${{ matrix.os == 'windows-latest' }}
uses: actions/cache@v2
with:
key: ${{ matrix.os }}-${{ matrix.target }}
path: $VCPKG_DIRECTORY
- name: Build release
uses: actions-rs/cargo@v1
with:
use-cross: ${{ matrix.use_cross }}
command: build
args: --target ${{ matrix.target }} --release
- name: Copy / Rename utility
run: |
cp target/${{ matrix.target }}/release/${{ matrix.output }} ${{ matrix.output }}-${{ matrix.target }}
tar -cvf cp2130-util-${{ matrix.target }}.tgz ${{ matrix.output }}-${{ matrix.target }}
- name: Upload utility artifacts
uses: actions/upload-artifact@v1
with:
name: ${{ matrix.output }}-${{ matrix.target }}
path: ${{ matrix.output }}-${{ matrix.target }}
- name: Upload utility binary to release
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: cp2130-util-${{ matrix.target }}.tgz
asset_name: cp2130-util-${{ matrix.target }}.tgz
tag: ${{ github.ref }}
overwrite: true
release:
name: Create release
runs-on: ubuntu-latest
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
steps:
- name: Create Release
uses: actions/create-release@v1
id: create_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: Release ${{ github.ref }}