-
Notifications
You must be signed in to change notification settings - Fork 58
172 lines (152 loc) · 4.64 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
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
name: Release
on:
push:
create:
tags:
- 'v*'
jobs:
# Build CLI tool.
build:
env:
CARGO_TERM_COLOR: always
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
build:
- linux
- macos
- windows
include:
- build: linux
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
vcpkg_openssl_triplet: x64-linux-release
args: "--features=openssl-static"
- build: macos
os: macos-latest
target: x86_64-apple-darwin
vcpkg_openssl_triplet: x64-osx-release
args: "--features=openssl-static"
- build: windows
os: windows-latest
target: x86_64-pc-windows-msvc
vcpkg_openssl_triplet: x64-windows-static
args: ""
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install dependencies
id: vcpkg
uses: johnwason/vcpkg-action@v6
with:
pkgs: openssl
triplet: ${{ matrix.vcpkg_openssl_triplet }}
token: ${{ github.token }}
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- name: Build
run: cargo build --bin yr --profile release-lto --target ${{ matrix.target }} ${{ matrix.args }}
env:
RUSTFLAGS: "-C target-feature=+crt-static"
OPENSSL_DIR: "${{ github.workspace }}/vcpkg/installed/${{ matrix.vcpkg_openssl_triplet }}"
- name: Build archive
shell: bash
run: |
set -ex
pkgname=yara-x-${{ github.ref_name }}-${{ matrix.target }}
if [ "${{ matrix.build }}" = "windows" ]; then
7z a $pkgname.zip ./target/${{ matrix.target }}/release-lto/yr.exe
else
tar czf $pkgname.gzip -C target/${{ matrix.target }}/release-lto yr
fi
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: yr-${{ matrix.target }}
path: yara-x-*
# Build Python extension.
build-py:
runs-on: ${{ format('{0}-latest', matrix.os) }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu, macos, windows ]
python-version: [ 'cp310', 'pp37', 'pp38', 'pp39' ]
arch: [ main, alt ]
include:
- os: ubuntu
platform: linux
- os: windows
ls: dir
- os: macos
arch: alt
alt_arch_name: 'arm64 universal2'
exclude:
- os: windows
arch: alt
- os: macos
python-version: 'pp37'
arch: alt
- os: macos
python-version: 'pp38'
arch: alt
- os: macos
python-version: 'pp39'
arch: alt
- os: ubuntu
arch: alt
steps:
- name: Checkout sources
- uses: actions/checkout@v3
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- name: Install Python dependencies
run: pip install -U setuptools wheel twine cibuildwheel platformdirs
- name: Build sdist
if: matrix.os == 'ubuntu' && matrix.python-version == 'cp310'
run: |
pip install maturin build
python -m build --sdist -o wheelhouse
- name: Build ${{ matrix.platform || matrix.os }} binaries
run: cibuildwheel --output-dir wheelhouse
env:
CIBW_BUILD: '${{ matrix.python-version }}-*'
# rust doesn't seem to be available for musl linux on i686
CIBW_SKIP: '*-musllinux_i686'
# we build for "alt_arch_name" if it exists, else 'auto'
CIBW_ARCHS: ${{ matrix.alt_arch_name || 'auto' }}
CIBW_ENVIRONMENT: 'PATH="$HOME/.cargo/bin:$PATH" CARGO_TERM_COLOR="always"'
CIBW_ENVIRONMENT_WINDOWS: 'PATH="$UserProfile\.cargo\bin;$PATH"'
CIBW_BEFORE_BUILD: rustup show
CIBW_BEFORE_BUILD_LINUX: >
curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=stable --profile=minimal -y &&
rustup show
CIBW_TEST_COMMAND: 'pytest {project}/test'
CIBW_TEST_REQUIRES: pytest requests
CIBW_TEST_SKIP: '*-macosx_arm64 *-macosx_universal2:arm64'
CIBW_BUILD_VERBOSITY: 1
publish:
needs: [ build, build-py ]
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
pattern: yr-*
- name: ls
shell: bash
run: ls
- name: Release
uses: softprops/action-gh-release@v2
with:
draft: true
files: yr-*/yara-x-*