-
Notifications
You must be signed in to change notification settings - Fork 3
98 lines (95 loc) · 3.13 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
name: Rust
on:
push:
tags:
- '*' # Push events to matching v*, i.e. v1.0, v20.15.10
env:
CARGO_TERM_COLOR: always
jobs:
build-amd64-linux:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Install musl
run: sudo apt install musl musl-dev musl-tools make gcc -y
- name: Set env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Install latest nightly
uses: actions-rs/toolchain@v1
with:
target: x86_64-unknown-linux-musl
toolchain: nightly
override: true
components: rustfmt, clippy
- name: Run cargo build
uses: actions-rs/cargo@v1
with:
command: build
args: --release --target=x86_64-unknown-linux-musl
- name: Tar
run: tar -czvf ocipack-${{ env.RELEASE_VERSION }}-amd64_linux.tar.gz -C ./target/x86_64-unknown-linux-musl/release/ ocipack
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: ./ocipack-${{ env.RELEASE_VERSION }}-amd64_linux.tar.gz
build-amd64-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Env
run: SET RELEASE_VERSION=$($env:GITHUB_REF -replace "refs/tags/")
- name: Print Env
run: |
chcp 65001 #set code page to utf-8
echo ("RELEASE_VERSION=" + $env:GITHUB_REF.replace('refs/tags/', '')) >> $env:GITHUB_ENV
- name: Install latest nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
components: rustfmt, clippy
- name: Run cargo build
uses: actions-rs/cargo@v1
with:
command: build
args: --release
- name: Rename
run: cp ./target/release/ocipack.exe ./
- name: Run UPX
uses: crazy-max/ghaction-upx@v2
with:
version: latest
files: |
./ocipack.exe
- name: Zip
run: Compress-Archive ./ocipack.exe ocipack-${{ env.RELEASE_VERSION }}-amd64_windows.zip
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: ./ocipack-${{ env.RELEASE_VERSION }}-amd64_windows.zip
build-amd64-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Set env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Install latest nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
components: rustfmt, clippy
- name: Run cargo build
uses: actions-rs/cargo@v1
with:
command: build
args: --release
- name: Tar
run: tar -czvf ocipack-${{ env.RELEASE_VERSION }}-amd64_darwin.tar.gz -C ./target/release/ ocipack
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: ./ocipack-${{ env.RELEASE_VERSION }}-amd64_darwin.tar.gz