-
Notifications
You must be signed in to change notification settings - Fork 0
131 lines (118 loc) · 3.8 KB
/
build.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
name: Build and release binary
on:
push:
branches:
#- main
- mpw/bin-release
pull_request: null
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
REPOSITORY: ${{ github.event.repository.name }}
BINARY_NAME: hub
jobs:
build:
runs-on: '${{ matrix.os }}'
strategy:
matrix:
include:
- os: macos-latest
target: x86_64-apple-darwin
suffix: ''
- os: macos-latest-xlarge
target: aarch64-apple-darwin
suffix: ''
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
suffix: ''
- os: windows-latest
target: x86_64-pc-windows-msvc
suffix: .exe
steps:
- uses: actions/checkout@master
with:
lfs: true
- id: get_version
run: echo ::set-output "name=VERSION::$(IFS=\=;cat Cargo.toml | grep version | head -n1 | awk {'print $3'})"
shell: bash
- name: Debug matrix.os
run: echo "OS is ${{ matrix.os }}"
- name: Install dependencies
if: startsWith(matrix.os, 'ubuntu')
run: |
sudo apt-get update -y && \
sudo apt-get install -y --no-install-recommends \
cmake \
clang \
liburing-dev \
g++ \
libsasl2-dev \
libssl-dev \
libudev-dev \
pkg-config
- name: Install dependencies
if: startsWith(matrix.os, 'macOS')
run: |
brew install cmake gcc [email protected] pkg-config protobuf
- name: Install dependencies windows
if: startsWith(matrix.os, 'windows')
run: |
choco install cmake openssl protoc
- name: Get protoc from github releases
if: startsWith(matrix.os, 'ubuntu')
run: |
sudo ./ci/get-protoc.sh
- uses: actions/cache@v1
with:
path: ~/.cargo/registry
key: '${{ runner.os }}-cargo-registry-${{ hashFiles(''**/Cargo.lock'') }}'
- uses: actions/cache@v1
with:
path: ~/.cargo/git
key: '${{ runner.os }}-cargo-index-${{ hashFiles(''**/Cargo.lock'') }}'
- uses: actions/cache@v1
with:
path: target
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
env:
VERSION: '${{ steps.get_version.outputs.VERSION }}'
with:
command: build
args: '--release'
- name: Rename binary
run: |
cp ./target/release/${{ env.BINARY_NAME }}${{matrix.suffix}} ./target/release/${{ env.REPOSITORY }}${{ matrix.suffix }}
- uses: actions/upload-artifact@v2
with:
name: ${{ env.REPOSITORY }}-${{ matrix.target }}
path: ./target/release/${{ env.REPOSITORY }}${{ matrix.suffix }}
if-no-files-found: error
release:
needs:
- build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
with:
lfs: true
- uses: actions/download-artifact@v3
- name: Release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.ACTIONS_TOKEN }}
with:
generate_release_notes: true
draft: true
fail_on_unmatched_files: true
files: |
./${{ env.REPOSITORY }}/${{ env.REPOSITORY }}-x86_64-apple-darwin
./${{ env.REPOSITORY }}/${{ env.REPOSITORY }}-x86_64-unknown-linux-gnu
./${{ env.REPOSITORY }}/${{ env.REPOSITORY }}-x86_64-pc-windows-msvc
./${{ env.REPOSITORY }}/${{ env.REPOSITORY }}-aarch64-apple-darwin