-
Notifications
You must be signed in to change notification settings - Fork 0
100 lines (86 loc) · 3.18 KB
/
release.yaml
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
name: release
on:
push:
tags:
- "*"
jobs:
build:
strategy:
fail-fast: true
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: macos-latest
target: x86_64-apple-darwin
- os: windows-latest
target: x86_64-pc-windows-msvc
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@master
- name: Cahce
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
override: true
toolchain: stable
target: ${{ matrix.target }}
- name: Build release
run: cd backend && cargo build --release
- name: Artifact (Unix)
if: matrix.target != 'x86_64-pc-windows-msvc'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.target }}
path: backend/target/release/mdbook-repl
- name: Artifact (Windows)
if: matrix.target == 'x86_64-pc-windows-msvc'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.target }}
path: backend/target/release/mdbook-repl.exe
- name: Publish crate
if: matrix.target == 'x86_64-unknown-linux-gnu'
run: |
cd backend
cargo login ${{ secrets.CARGO_TOKEN }}
cargo publish
release:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/download-artifact@v4
- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/}
- name: Install packages
run: sudo apt update && sudo apt install -y upx-ucl zip
- name: Rename binaries
run: |
mv x86_64-unknown-linux-gnu mdbook-repl-${{ steps.get_version.outputs.VERSION }}-x86_64-unknown-linux-gnu
mv x86_64-apple-darwin mdbook-repl-${{ steps.get_version.outputs.VERSION }}-x86_64-apple-darwin
mv x86_64-pc-windows-msvc mdbook-repl-${{ steps.get_version.outputs.VERSION }}-x86_64-pc-windows-msvc
- name: Compress binaries
run: |
chmod u+x mdbook-repl-*/mdbook-repl*
upx --best mdbook-repl-*/mdbook-repl*
zip -r mdbook-repl-${{ steps.get_version.outputs.VERSION }}-x86_64-unknown-linux-gnu{.zip,}
zip -r mdbook-repl-${{ steps.get_version.outputs.VERSION }}-x86_64-apple-darwin{.zip,}
zip -r mdbook-repl-${{ steps.get_version.outputs.VERSION }}-x86_64-pc-windows-msvc{.zip,}
- name: Create release
uses: softprops/action-gh-release@v1
with:
name: v${{ steps.get_version.outputs.VERSION }}
files: |
mdbook-repl-${{ steps.get_version.outputs.VERSION }}-x86_64-unknown-linux-gnu.zip
mdbook-repl-${{ steps.get_version.outputs.VERSION }}-x86_64-apple-darwin.zip
mdbook-repl-${{ steps.get_version.outputs.VERSION }}-x86_64-pc-windows-msvc.zip