Skip to content

Commit aa755ab

Browse files
committed
adjust CI
add openSSL to envs that don't ship with it. add workflow to build binaries (intended for release and nightly). fix git.rs unit tests don't let maturin CI fail fast use openssl-vendored feature for build envs that can't use native openssl
1 parent bdfac71 commit aa755ab

File tree

8 files changed

+269
-58
lines changed

8 files changed

+269
-58
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
*.sh text eol=lf
99
*.cpp text eol=lf
1010
*.hpp text eol=lf
11+
*.patch text eol=lf

.github/workflows/binary-builds.yml

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
name: Binary executable builds
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
push:
8+
branches: [main]
9+
tags:
10+
- v[0-9]+.*
11+
pull_request:
12+
branches: [main]
13+
14+
env:
15+
CARGO_INCREMENTAL: 0
16+
CARGO_NET_GIT_FETCH_WITH_CLI: true
17+
CARGO_NET_RETRY: 10
18+
CARGO_TERM_COLOR: always
19+
RUST_BACKTRACE: 1
20+
RUSTFLAGS: -D warnings
21+
RUSTUP_MAX_RETRIES: 10
22+
23+
defaults:
24+
run:
25+
shell: bash
26+
27+
jobs:
28+
29+
create-assets:
30+
name: ${{ matrix.target }}
31+
strategy:
32+
fail-fast: false
33+
matrix:
34+
include:
35+
- target: aarch64-unknown-linux-gnu
36+
os: ubuntu-latest
37+
- target: aarch64-unknown-linux-musl
38+
os: ubuntu-latest
39+
- target: x86_64-unknown-linux-gnu
40+
os: ubuntu-latest
41+
- target: x86_64-unknown-linux-musl
42+
os: ubuntu-latest
43+
- target: aarch64-apple-darwin
44+
os: macos-latest
45+
- target: x86_64-apple-darwin
46+
os: macos-latest
47+
- target: x86_64-pc-windows-msvc
48+
os: windows-latest
49+
runs-on: ${{ matrix.os }}
50+
permissions:
51+
contents: write
52+
steps:
53+
- name: Calculate Release Version
54+
id: calc-version
55+
run: |
56+
if [ "${{ github.event_name }}" = "pull_request" ]; then
57+
short_sha=$(echo "${{ github.sha }}" | awk '{print substr($0,0,5)}')
58+
echo "RELEASE_VERSION=nightly-$(date '+%Y-%m-%d')-$short_sha" >> $GITHUB_OUTPUT
59+
else
60+
echo "RELEASE_VERSION=${{ github.ref_name }}" >> $GITHUB_OUTPUT
61+
fi
62+
63+
- name: Install native OpenSSL on Linux
64+
if: runner.os == 'Linux' && !(startsWith(matrix.target, 'aarch64') || endsWith(matrix.target, 'musl'))
65+
run: sudo apt-get install -y openssl openssl-dev
66+
- name: Install GCC for aarch64 (for compiling openssl)
67+
if: runner.os == 'Linux' && startsWith(matrix.target, 'aarch64')
68+
run: |
69+
if [ "${{matrix.target}}" == *musl ]; then
70+
sudo apt-get install aarch64-linux-musl-gcc
71+
else
72+
sudo apt-get install aarch64-linux-gnu-gcc
73+
fi
74+
- name: Install musl-gcc (form compiling openssl)
75+
if: matrix.target == 'x86_64-unknown-linux-musl'
76+
run: sudo apt-get install musl-tools
77+
78+
- name: Calculate openssl-vendored
79+
shell: bash
80+
id: is-openssl-vendored
81+
run: |
82+
case "${{ matrix.target }}" in
83+
"aarch64-apple-darwin" | "x86_64-apple-darwin" | "aarch64-unknown-linux-gnu" | "aarch64-unknown-linux-musl" | "x86_64-unknown-linux-musl")
84+
echo "enabled=true" >> $GITHUB_OUTPUT
85+
;;
86+
*)
87+
echo "enabled=false" >> $GITHUB_OUTPUT
88+
;;
89+
esac
90+
91+
- name: Checkout
92+
uses: actions/checkout@v4
93+
94+
- name: Setup Rust
95+
uses: dtolnay/rust-toolchain@stable
96+
with:
97+
target: ${{ matrix.target }}
98+
99+
- name: Build (openssl-vendored)
100+
if: steps.is-openssl-vendored.outputs.enabled == 'true'
101+
run: cargo build --release --target ${{ matrix.target }} --features openssl-vendored
102+
- name: Build (no openssl-vendored)
103+
if: steps.is-openssl-vendored.outputs.enabled == 'false'
104+
run: cargo build --release --target ${{ matrix.target }}
105+
106+
- name: Prepare artifacts [Windows]
107+
shell: bash
108+
if: matrix.os == 'windows-latest'
109+
id: prep-artifacts-windows
110+
run: |
111+
release_dir="cpp-linter-cli-${{ steps.calc-version.outputs.RELEASE_VERSION }}"
112+
artifact_path="cpp-linter-cli-${{ steps.calc-version.outputs.RELEASE_VERSION }}-${{ matrix.target }}.zip"
113+
echo "ARTIFACT_PATH=$artifact_path" >> $GITHUB_OUTPUT
114+
mkdir $release_dir
115+
cp target/${{ matrix.target }}/release/cpp-linter-cli.exe $release_dir/
116+
cp LICENSE $release_dir/
117+
7z a -tzip $artifact_path $release_dir/
118+
- name: Prepare artifacts [Unix]
119+
shell: bash
120+
id: prep-artifacts-unix
121+
if: matrix.os != 'windows-latest'
122+
run: |
123+
release_dir="cpp-linter-cli-${{ steps.calc-version.outputs.RELEASE_VERSION }}"
124+
artifact_path="cpp-linter-cli-${{ steps.calc-version.outputs.RELEASE_VERSION }}-${{ matrix.target }}.tar.gz"
125+
echo "ARTIFACT_PATH=$artifact_path" >> $GITHUB_OUTPUT
126+
mkdir $release_dir
127+
cp target/${{ matrix.target }}/release/cpp-linter-cli $release_dir/
128+
cp LICENSE $release_dir
129+
tar -czvf $artifact_path $release_dir/
130+
- name: Upload artifacts
131+
uses: actions/upload-artifact@v4
132+
with:
133+
name: ${{ steps.prep-artifacts-unix.outputs.ARTIFACT_PATH || steps.prep-artifacts-windows.outputs.ARTIFACT_PATH }}
134+
path: ${{ steps.prep-artifacts-unix.outputs.ARTIFACT_PATH || steps.prep-artifacts-windows.outputs.ARTIFACT_PATH }}
135+
if-no-files-found: error
136+
137+
create-release:
138+
if: startswith(github.ref, 'refs/tags')
139+
runs-on: ubuntu-latest
140+
needs: [create-assets]
141+
permissions:
142+
contents: write
143+
steps:
144+
- uses: actions/checkout@v4
145+
with:
146+
persist-credentials: false
147+
- name: Install Rust
148+
run: rustup update stable --no-self-update
149+
- run: cargo package
150+
- name: Create a Github Release
151+
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
152+
env:
153+
GH_TOKEN: ${{ github.token }}
154+
run: gh release create ${{ github.ref_name }} --generate-notes
155+
- run: cargo publish
156+
env:
157+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
158+
159+
upload-assets:
160+
needs: [create-release]
161+
runs-on: ubuntu-latest
162+
strategy:
163+
matrix:
164+
include:
165+
- target: aarch64-unknown-linux-gnu
166+
- target: aarch64-unknown-linux-musl
167+
- target: x86_64-unknown-linux-gnu
168+
- target: x86_64-unknown-linux-musl
169+
- target: aarch64-apple-darwin
170+
- target: x86_64-apple-darwin
171+
- target: universal-apple-darwin
172+
- target: x86_64-pc-windows-msvc
173+
steps:
174+
- name: Download build asset
175+
uses: actions/download-artifact@v4
176+
with:
177+
name: cpp-linter-cli-${{ matrix.target }}
178+
path: dist
179+
- name: Upload release assets
180+
env:
181+
GH_TOKEN: ${{ github.token }}
182+
run: gh release upload ${{ github.ref_name }} dist/cpp-linter-cli${{ contains(matrix.target, 'windows') || '.exe' }}%#%cpp-linter-cli_${{ matrix.target }} --clobber

.github/workflows/python-packaging.yml

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
# This file is autogenerated by maturin v1.2.3
2-
# To update, run
3-
#
4-
# maturin generate-ci github
5-
#
61
name: Python packaging
72

83
on:
@@ -22,29 +17,40 @@ jobs:
2217
linux:
2318
runs-on: ubuntu-latest
2419
strategy:
20+
fail-fast: false
2521
matrix:
2622
target: [x86_64, x86, aarch64, armv7, s390x, ppc64le]
2723
steps:
2824
- uses: actions/checkout@v4
2925
- uses: actions/setup-python@v5
3026
with:
3127
python-version: '3.10'
28+
3229
- name: Build wheels
3330
uses: PyO3/maturin-action@v1
3431
with:
3532
target: ${{ matrix.target }}
36-
args: --release --out dist --find-interpreter
37-
sccache: 'true'
33+
# x86 and x86_64 use rust-cross docker containers, thus we can't use `sudo apt install openssl`
34+
args: --release --out dist --find-interpreter ${{ startsWith(matrix.target, 'x86') || '--features openssl-vendored' }}
3835
manylinux: auto
36+
# aarch64, armv7, s390x, and ppc64le targets use manylinux docker containers, thus we can use `sudo apt install openssl`
37+
before-script-linux: |
38+
case "${{ matrix.target }}" in
39+
"aarch64" | "armv7" | "s390x" | "ppc64le")
40+
sudo apt-get update
41+
sudo apt-get install -y openssl openssl-dev
42+
;;
43+
esac
3944
- name: Upload wheels
4045
uses: actions/upload-artifact@v4
4146
with:
42-
name: wheels
43-
path: dist
47+
name: wheels-linux-${{ matrix.target }}
48+
path: dist/*
4449

4550
windows:
4651
runs-on: windows-latest
4752
strategy:
53+
fail-fast: false
4854
matrix:
4955
target: [x64, x86]
5056
steps:
@@ -58,16 +64,16 @@ jobs:
5864
with:
5965
target: ${{ matrix.target }}
6066
args: --release --out dist --find-interpreter
61-
sccache: 'true'
6267
- name: Upload wheels
6368
uses: actions/upload-artifact@v4
6469
with:
65-
name: wheels
66-
path: dist
70+
name: wheels-windows-${{ matrix.target }}
71+
path: dist/*
6772

6873
macos:
6974
runs-on: macos-latest
7075
strategy:
76+
fail-fast: false
7177
matrix:
7278
target: [x86_64, aarch64]
7379
steps:
@@ -79,13 +85,12 @@ jobs:
7985
uses: PyO3/maturin-action@v1
8086
with:
8187
target: ${{ matrix.target }}
82-
args: --release --out dist --find-interpreter
83-
sccache: 'true'
88+
args: --release --out dist --find-interpreter --features openssl-vendored
8489
- name: Upload wheels
8590
uses: actions/upload-artifact@v4
8691
with:
87-
name: wheels
88-
path: dist
92+
name: wheels-macos-${{ matrix.target }}
93+
path: dist/*
8994

9095
sdist:
9196
runs-on: ubuntu-latest
@@ -99,8 +104,8 @@ jobs:
99104
- name: Upload sdist
100105
uses: actions/upload-artifact@v4
101106
with:
102-
name: wheels
103-
path: dist
107+
name: wheels-sdist
108+
path: dist/*
104109

105110
release:
106111
name: Release
@@ -110,11 +115,11 @@ jobs:
110115
steps:
111116
- uses: actions/download-artifact@v4
112117
with:
113-
name: wheels
118+
path: dist
114119
- name: Publish to PyPI
115120
uses: PyO3/maturin-action@v1
116121
env:
117122
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
118123
with:
119124
command: upload
120-
args: --non-interactive --skip-existing *
125+
args: --non-interactive --skip-existing dist/*

0 commit comments

Comments
 (0)