forked from fonttools/fontspector
-
Notifications
You must be signed in to change notification settings - Fork 0
145 lines (132 loc) · 4.43 KB
/
rust.yml
File metadata and controls
145 lines (132 loc) · 4.43 KB
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
142
143
144
145
name: Rust
on:
- push
- pull_request
- merge_group
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install protoc
run: sudo apt-get update && sudo apt-get install protobuf-compiler
- uses: actions-rust-lang/setup-rust-toolchain@v1
name: Set up Rust for caching
- name: Build
run: cargo build
- name: Run tests
run: |
cargo test --verbose --workspace --exclude fontspector-web
pip install maturin pytest
cd fontspector-py
maturin build
pip install ../target/wheels/fontspector*.whl
pytest tests --verbose
formatting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: actions-rust-lang/setup-rust-toolchain@v1
name: Set up Rust for caching
- name: Lint for formatting
run: cargo fmt --all -- --check
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install protoc
run: sudo apt-get update && sudo apt-get install protobuf-compiler
- uses: actions-rust-lang/setup-rust-toolchain@v1
name: Set up Rust for caching
- name: Lint for warnings
run: cargo clippy --all-targets --all-features -- -D warnings
deploy-binaries:
name: Build and upload binaries
permissions:
contents: write
id-token: write
runs-on: ${{ matrix.os.os }}
# Only build on main or tag
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
strategy:
fail-fast: false
matrix:
os:
- build: linux
os: ubuntu-22.04
target: x86_64-unknown-linux-gnu
- build: macos
os: macos-latest
target: x86_64-apple-darwin
- build: macos-m1
os: macos-latest
target: aarch64-apple-darwin
- build: windows-gnu
os: windows-latest
target: x86_64-pc-windows-gnu
# python: ["3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: ${{ matrix.os.target }}
cache-key: ${{ runner.os }}-rust-${{ hashFiles('**/Cargo.lock') }}
# - name: Set up python
# uses: actions/setup-python@v5
# with:
# python-version: ${{ matrix.python }}
- name: Install protoc for lang repo
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Build
run: cargo build --verbose --release --target ${{ matrix.os.target }}
- name: Decide on our version name (tag or "dev")
id: version
shell: bash
run: |
if [ -n "$GITHUB_REF" ]; then
if [[ "$GITHUB_REF" == refs/tags/fontspector-v* ]]; then
echo "VERSION=${GITHUB_REF/refs\/tags\/fontspector-/}" >> $GITHUB_ENV
else
echo "VERSION=dev" >> $GITHUB_ENV
fi
else
echo "VERSION=dev" >> $GITHUB_ENV
fi
- name: Build archive
shell: bash
run: |
# dirname="fontspector-${{ env.VERSION }}-${{ matrix.os.target }}-py${{ matrix.python }}"
dirname="fontspector-${{ env.VERSION }}-${{ matrix.os.target }}"
mkdir "$dirname"
if [ "${{ matrix.os.os }}" = "windows-latest" ]; then
mv "target/${{ matrix.os.target }}/release/"*.exe "$dirname"
7z a "$dirname.zip" "$dirname"
echo "ASSET=$dirname.zip" >> $GITHUB_ENV
else
mv "target/${{ matrix.os.target }}/release/fontspector" "$dirname"
tar -czf "$dirname.tar.gz" "$dirname"
echo "ASSET=$dirname.tar.gz" >> $GITHUB_ENV
fi
- uses: actions/upload-artifact@v4
with:
name: ${{ env.ASSET }}
path: ${{ env.ASSET }}
- if: contains(github.ref, 'refs/tags/fontspector-v')
name: Add artefact to release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release upload fontspector-${{ env.VERSION }} ${{ env.ASSET }}