-
Notifications
You must be signed in to change notification settings - Fork 2
99 lines (85 loc) · 3.22 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
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: cargo build --release
- name: Artifact (Unix)
if: matrix.target != 'x86_64-pc-windows-msvc'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.target }}
path: target/release/mdbook-embedify
- name: Artifact (Windows)
if: matrix.target == 'x86_64-pc-windows-msvc'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.target }}
path: target/release/mdbook-embedify.exe
- name: Publish crate
if: matrix.target == 'x86_64-unknown-linux-gnu'
uses: katyo/publish-crates@v2
with:
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
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-embedify-${{ steps.get_version.outputs.VERSION }}-x86_64-unknown-linux-gnu
mv x86_64-apple-darwin mdbook-embedify-${{ steps.get_version.outputs.VERSION }}-x86_64-apple-darwin
mv x86_64-pc-windows-msvc mdbook-embedify-${{ steps.get_version.outputs.VERSION }}-x86_64-pc-windows-msvc
- name: Compress binaries
run: |
chmod u+x mdbook-embedify-*/mdbook-embedify*
upx --best mdbook-embedify-*/mdbook-embedify*
zip -r mdbook-embedify-${{ steps.get_version.outputs.VERSION }}-x86_64-unknown-linux-gnu{.zip,}
zip -r mdbook-embedify-${{ steps.get_version.outputs.VERSION }}-x86_64-apple-darwin{.zip,}
zip -r mdbook-embedify-${{ 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-embedify-${{ steps.get_version.outputs.VERSION }}-x86_64-unknown-linux-gnu.zip
mdbook-embedify-${{ steps.get_version.outputs.VERSION }}-x86_64-apple-darwin.zip
mdbook-embedify-${{ steps.get_version.outputs.VERSION }}-x86_64-pc-windows-msvc.zip