-
Notifications
You must be signed in to change notification settings - Fork 17
165 lines (157 loc) · 4.66 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
name: Rust
on:
push:
branches: ["master", "remove-gitlab"]
tags:
- "v*"
pull_request:
branches: ["master"]
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
BINARY_NAME: mlc
jobs:
test_own_readme:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Cache
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Run
run: cargo run -- ./README.md -d
build_linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run tests
run: cargo test --verbose
- uses: awalsh128/cache-apt-pkgs-action@v1
with:
packages: musl-tools # provides musl-gcc
version: 1.0
- name: "Get the Rust toolchain"
uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-unknown-linux-musl
components: rustfmt, clippy
- name: Cache
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Build
run: cargo build --release --verbose --target=x86_64-unknown-linux-musl
- uses: actions/upload-artifact@v3
with:
name: linux
path: ./target/x86_64-unknown-linux-musl/release/${{ env.BINARY_NAME }}
build_windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Run tests
run: cargo test --verbose
- name: Build
run: cargo build --verbose --release
- uses: actions/upload-artifact@v3
with:
name: windows
path: ./target/release/${{ env.BINARY_NAME }}.exe
build_osx:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: aarch64-apple-darwin
- name: Run tests
run: cargo test --verbose
- name: Build
run: |
cargo build --verbose --release --target aarch64-apple-darwin
ls ./target
- uses: actions/upload-artifact@v3
with:
name: apple-darwin
path: target/aarch64-apple-darwin/release/${{ env.BINARY_NAME }}
release:
runs-on: ubuntu-latest
needs: [release_docker]
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/download-artifact@v3
with:
name: linux
path: mlc-x86_64-linux
- uses: actions/download-artifact@v3
with:
name: windows
path: mlc-x86_64-windows
- uses: actions/download-artifact@v3
with:
name: apple-darwin
path: mlc-x86_64-apple-darwin
- name: Rename files
run: |
ls
ls mlc-x86_64-linux
ls mlc-x86_64-apple-darwin
ls mlc-x86_64-windows
mv ./mlc-x86_64-linux/mlc mlc
rm -rd ./mlc-x86_64-linux
mv ./mlc mlc-x86_64-linux
mv ./mlc-x86_64-apple-darwin/mlc mlc
rm -rd ./mlc-x86_64-apple-darwin
mv ./mlc mlc-x86_64-apple-darwin
mv ./mlc-x86_64-windows/mlc.exe mlc-x86_64-windows.exe
rm -rd ./mlc-x86_64-windows
ls
- name: GitHub Release
uses: softprops/action-gh-release@v1
with:
files: |
mlc-x86_64-linux
mlc-x86_64-apple-darwin
mlc-x86_64-windows.exe
release_docker:
runs-on: ubuntu-latest
needs: [build_osx, build_windows, build_linux]
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v4
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: linux
path: ./target/release
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Set env
run: |
version=${GITHUB_REF#refs/*/}
version=${version:1}
echo "RELEASE_VERSION=$version" >> $GITHUB_ENV
- run: echo Push docker image $RELEASE_VERSION
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PW }}
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: becheran/mlc:latest,becheran/mlc:${{ env.RELEASE_VERSION }}