-
Notifications
You must be signed in to change notification settings - Fork 3
92 lines (76 loc) · 2.47 KB
/
release.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
name: Release
on:
push:
tags: ["v*"]
# on PRs only build and test. Does not upload artifacts anywhere.
pull_request:
branches: ["main"]
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: Build
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-musl # for cargo
target_human: linux_amd64 # for the release artifact
os: ubuntu-latest
- target: aarch64-unknown-linux-musl
target_human: linux_arm64
os: ubuntu-latest
- target: x86_64-apple-darwin
target_human: darwin_amd64
os: macos-latest
- target: aarch64-apple-darwin
target_human: darwin_arm64
os: macos-latest
steps:
- uses: actions/checkout@v2
- uses: FranzDiebold/github-env-vars-action@v2.3.1
- name: Install coreutils for macOS
if: matrix.os == 'macos-latest'
run: brew install coreutils
# Cache files between builds
- name: Setup | Cache Cargo
uses: actions/cache@v2.1.7
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Setup | Rust
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
profile: minimal
target: ${{ matrix.target }}
override: true
- name: Build release
uses: actions-rs/cargo@v1
with:
command: build
args: --target ${{ matrix.target }} --release
use-cross: ${{ matrix.os == 'ubuntu-latest' }}
- name: Copy and rename utility
run: cp target/${{ matrix.target }}/release/ny ny
- name: Create archive
run: |
tar -czvf ny-${{ matrix.target }}.tar.gz ny
- name: Upload artifacts archive
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
uses: actions/upload-artifact@v2
with:
name: ny-${{ matrix.target_human }}.tar.gz
path: ny-${{ matrix.target }}.tar.gz
- name: Upload binary to release
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ny-${{ matrix.target }}.tar.gz
asset_name: ny-${{ matrix.target_human }}.tar.gz
tag: ${{ github.ref }}
overwrite: true