-
-
Notifications
You must be signed in to change notification settings - Fork 17
141 lines (137 loc) · 5.08 KB
/
build.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
name: mdbook-pdf build
on:
workflow_dispatch: # Allow manual triggers
push:
branches: [ main ]
# Publish `v1.2.3` tags as releases.
tags:
- v*
pull_request:
branches: [ main ]
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- target: "x86_64-apple-darwin"
os: "macos-latest"
- target: "aarch64-apple-darwin"
os: "macos-latest"
- target: "x86_64-unknown-linux-gnu"
os: "ubuntu-latest"
- target: "x86_64-unknown-linux-musl"
os: "ubuntu-latest"
# - target: "i686-unknown-linux-gnu"
# os: "ubuntu-latest"
- target: "i686-unknown-linux-musl"
os: "ubuntu-latest"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- uses: Swatinem/rust-cache@v2
- name: Get latest tag
run: |
echo "VERSION=$(git -c 'versionsort.suffix=-' ls-remote \
--tags --sort='-v:refname' https://github.com/HollowMan6/mdbook-pdf \
| cut -d '/' -f3 | head -1)" >> $GITHUB_ENV
- name: Add target
run: |
rustup target add ${{ matrix.target }}
- name: Build mdbook-pdf Release
run: |
cargo build --release --target ${{ matrix.target }}
- name: Upload Binary File to release
if: startsWith(github.ref, 'refs/tags/v')
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
asset_name: mdbook-pdf-${{ env.VERSION }}-${{ matrix.target }}
file: target/${{ matrix.target }}/release/mdbook-pdf
tag: ${{ env.VERSION }}
overwrite: true
- name: Upload Binary File to Artifact
uses: actions/upload-artifact@v3
with:
name: mdbook-pdf-${{ env.VERSION }}-${{ matrix.target }}
path: target/${{ matrix.target }}/release/mdbook-pdf
build-windows:
runs-on: "windows-latest"
strategy:
fail-fast: false
matrix:
target: ["x86_64-pc-windows-msvc", "x86_64-pc-windows-gnu", "aarch64-pc-windows-msvc", "i686-pc-windows-msvc"]
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- uses: Swatinem/rust-cache@v2
- name: Get latest tag
run: |
$c = git -c 'versionsort.suffix=-' ls-remote `
--tags --sort='-v:refname' https://github.com/HollowMan6/mdbook-pdf `
| select -first 1
$tag = $c -split "/" | select -last 1
echo "VERSION=$tag" >> $env:GITHUB_ENV
- name: Add target
run: |
rustup target add ${{ matrix.target }}
- name: Build mdbook-pdf Release
run: |
cargo build --release --target ${{ matrix.target }}
- name: Upload Binary File to release
if: startsWith(github.ref, 'refs/tags/v')
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
asset_name: mdbook-pdf-${{ env.VERSION }}-${{ matrix.target }}.exe
file: target/${{ matrix.target }}/release/mdbook-pdf.exe
tag: ${{ env.VERSION }}
overwrite: true
- name: Upload Binary File to Artifact
uses: actions/upload-artifact@v3
with:
name: mdbook-pdf-${{ env.VERSION }}-${{ matrix.target }}
path: target/${{ matrix.target }}/release/mdbook-pdf.exe
build-linux-aarch64:
strategy:
fail-fast: false
matrix:
target: ["aarch64-unknown-linux-musl", "aarch64-unknown-linux-gnu"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Get latest tag
run: |
echo "VERSION=$(git -c 'versionsort.suffix=-' ls-remote \
--tags --sort='-v:refname' https://github.com/HollowMan6/mdbook-pdf \
| cut --delimiter='/' --fields=3 | head --lines=1)" >> $GITHUB_ENV
- name: Build mdbook-pdf Release
run: |
mkdir .cargo
echo "[net]" >> .cargo/config.toml
echo "git-fetch-with-cli = true" >> .cargo/config.toml
docker run -i -v /usr/bin/qemu-aarch64-static:/usr/bin/qemu-aarch64-static \
-v `pwd`:/build \
-w /build --platform arm64 rust bash -c \
"rustup target add ${{ matrix.target }} && cargo build --release --target ${{ matrix.target }}"
- name: Upload Binary File to release
if: startsWith(github.ref, 'refs/tags/v')
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
asset_name: mdbook-pdf-${{ env.VERSION }}-${{ matrix.target }}
file: target/${{ matrix.target }}/release/mdbook-pdf
tag: ${{ env.VERSION }}
overwrite: true
- name: Upload Binary File to Artifact
uses: actions/upload-artifact@v3
with:
name: mdbook-pdf-${{ env.VERSION }}-${{ matrix.target }}
path: target/${{ matrix.target }}/release/mdbook-pdf