-
-
Notifications
You must be signed in to change notification settings - Fork 6
129 lines (125 loc) · 3.82 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
name: Build
on:
push:
branches:
- main
pull_request:
release:
types: [published]
workflow_dispatch:
jobs:
build:
strategy:
matrix:
include:
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
- target: aarch64-unknown-linux-musl
os: ubuntu-latest
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
- target: aarch64-apple-darwin
os: macos-latest
- target: x86_64-apple-darwin
os: macos-latest
- target: x86_64-pc-windows-msvc
os: windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Update local toolchain
run: |
rustup update
- name: Add target
run: |
rustup target add ${{ matrix.target }}
- name: install cross
uses: taiki-e/install-action@cross
- name: Toolchain info
run: |
rustc --version
cargo --version --verbose
cross --version --verbose
- name: Build
run: |
cross build --release --all-features --target ${{ matrix.target }}
- name: Rename
run: |
mv target/${{ matrix.target }}/release/mdbook-alerts ./mdbook-alerts-${{ matrix.target }}
if: ${{ runner.os != 'Windows' }}
- name: Rename
run: |
mv target/${{ matrix.target }}/release/mdbook-alerts.exe ./mdbook-alerts-${{ matrix.target }}.exe
if: ${{ runner.os == 'Windows' }}
- uses: actions/upload-artifact@v4
with:
name: mdbook-alerts-${{ matrix.target }}
path: |
./mdbook-alerts-${{ matrix.target }}
./mdbook-alerts-${{ matrix.target }}.exe
if-no-files-found: error
release:
if: ${{ github.event_name == 'release' }}
needs: [build]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: ./artifacts
- run: find .
- uses: ncipollo/[email protected]
with:
allowUpdates: true
artifactErrorsFailBuild: true
artifacts: ./artifacts/mdbook-alerts-*/mdbook-alerts-*
removeArtifacts: true
publish:
if: ${{ github.event_name == 'release' }}
needs: [build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Update local toolchain
run: |
rustup update
- name: Toolchain info
run: |
rustc --version
cargo --version --verbose
- name: Apply version
run: |
sed -i "s/^version = \"0.0.0\"/version = \"${{ github.event.release.tag_name }}\"/" Cargo.toml
sed -i "s/^version = \"v\(.*\)\"/version = \"\1\"/" Cargo.toml
- name: Publish (Dry run)
run: |
cargo publish --allow-dirty --dry-run
if: ${{ github.event.release.prerelease == true }}
- name: Publish
run: |
cargo publish --allow-dirty
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
if: ${{ github.event.release.prerelease == false }}