-
-
Notifications
You must be signed in to change notification settings - Fork 28
137 lines (118 loc) · 4.39 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
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
135
136
137
name: Rust
on:
push:
tags: ["v*"]
branches: ["main"]
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
os: ubuntu-latest
output: dum
archive: tar.gz
- target: arm-unknown-linux-musleabihf
os: ubuntu-latest
output: dum
archive: tar.gz
- target: aarch64-unknown-linux-musl
os: ubuntu-latest
output: dum
archive: tar.gz
- target: x86_64-apple-darwin
os: macos-latest
output: dum
archive: zip
- target: aarch64-apple-darwin
os: macos-latest
output: dum
archive: zip
# Failing
# - target: arm-unknown-linux-musleabihf
# os: ubuntu-latest
# output: dum
# archive: tgz
- target: x86_64-pc-windows-msvc
os: windows-latest
output: dum.exe
archive: zip
- target: aarch64-pc-windows-msvc
os: windows-latest
output: dum.exe
archive: zip
steps:
- uses: actions/checkout@v4
- uses: FranzDiebold/[email protected]
- name: Install coreutils for macOS
if: matrix.os == 'macos-latest'
run: brew install coreutils
- name: Setup Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: ${{ matrix.target }}
- name: Install Cross
if: matrix.os == 'ubuntu-latest'
run: cargo install cross
- name: Run Tests
run: cargo test
- name: Build release (non-Linux)
if: matrix.os != 'ubuntu-latest'
run: cargo build --target ${{ matrix.target }} --release
- name: Build release (Linux)
if: matrix.os == 'ubuntu-latest'
run: cross build --target ${{ matrix.target }} --release
- name: Copy and rename utility
run: cp target/${{ matrix.target }}/release/${{ matrix.output }} ${{ matrix.output }}
- name: Create archive (linux)
if: ${{ matrix.os != 'macos-latest' && matrix.os != 'windows-latest' }}
run: |
tar -czvf dum-${{ matrix.target }}.${{ matrix.archive }} ${{ matrix.output }}
sha256sum dum-${{ matrix.target }}.${{ matrix.archive }} > dum-${{ matrix.target }}-sha256sum.txt
- name: Create archive (windows)
if: ${{ matrix.os == 'windows-latest' }}
run: |
tar.exe -a -c -f dum-${{ matrix.target }}.${{ matrix.archive }} ${{ matrix.output }}
sha256sum.exe dum-${{ matrix.target }}.${{ matrix.archive }} > dum-${{ matrix.target }}-sha256sum.txt
- name: Create archive (macos)
if: ${{ matrix.os == 'macos-latest' }}
run: |
zip dum-${{ matrix.target }}.${{ matrix.archive }} ${{ matrix.output }}
sha256sum dum-${{ matrix.target }}.${{ matrix.archive }} > dum-${{ matrix.target }}-sha256sum.txt
- name: Upload artifacts archive
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
uses: actions/upload-artifact@v4
with:
name: dum-${{ matrix.target }}.${{ matrix.archive }}
path: dum-${{ matrix.target }}.${{ matrix.archive }}
- name: Upload artifacts checksum
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
uses: actions/upload-artifact@v4
with:
name: dum-${{ matrix.target }}-sha256sum.txt
path: dum-${{ matrix.target }}-sha256sum.txt
- 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: dum-${{ matrix.target }}.${{ matrix.archive }}
asset_name: dum-${{ matrix.target }}.${{ matrix.archive }}
tag: ${{ github.ref }}
overwrite: true
- name: Upload checksum to release
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: dum-${{ matrix.target }}-sha256sum.txt
asset_name: dum-${{ matrix.target }}-sha256sum.txt
tag: ${{ github.ref }}
overwrite: true