Skip to content

Commit 192622a

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 192622a

File tree

8 files changed

+272
-57
lines changed

8 files changed

+272
-57
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 pkg-config libssl-dev
66+
- name: Install GCC for aarch64 (for cross-compiling openssl)
67+
if: runner.os == 'Linux' && startsWith(matrix.target, 'aarch64')
68+
run: |
69+
if [[ "${{matrix.target}}" == *musl ]]; then
70+
sudo apt-get install musl-dev musl-tools
71+
else
72+
sudo apt-get install gcc-11-aarch64-linux-gnu binutils-aarch64-linux-gnu
73+
fi
74+
- name: Install musl-gcc (fom 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: 28 additions & 19 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,44 @@ 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 }}
3633
args: --release --out dist --find-interpreter
37-
sccache: 'true'
3834
manylinux: auto
35+
before-script-linux: |
36+
case "${{ matrix.target }}" in
37+
"aarch64" | "armv7" | "s390x" | "ppc64le")
38+
# NOTE: pypa/manylinux docker images are Debian based
39+
sudo apt-get update
40+
sudo apt-get install -y pkg-config libssl-dev
41+
;;
42+
"x86" | "x86_64")
43+
# NOTE: rust-cross/manylinux docker images are CentOS based
44+
yum update -y
45+
yum install -y openssl openssl-devel
46+
;;
47+
esac
3948
- name: Upload wheels
4049
uses: actions/upload-artifact@v4
4150
with:
42-
name: wheels
43-
path: dist
51+
name: wheels-linux-${{ matrix.target }}
52+
path: dist/*
4453

4554
windows:
4655
runs-on: windows-latest
4756
strategy:
57+
fail-fast: false
4858
matrix:
4959
target: [x64, x86]
5060
steps:
@@ -58,16 +68,16 @@ jobs:
5868
with:
5969
target: ${{ matrix.target }}
6070
args: --release --out dist --find-interpreter
61-
sccache: 'true'
6271
- name: Upload wheels
6372
uses: actions/upload-artifact@v4
6473
with:
65-
name: wheels
66-
path: dist
74+
name: wheels-windows-${{ matrix.target }}
75+
path: dist/*
6776

6877
macos:
6978
runs-on: macos-latest
7079
strategy:
80+
fail-fast: false
7181
matrix:
7282
target: [x86_64, aarch64]
7383
steps:
@@ -79,13 +89,12 @@ jobs:
7989
uses: PyO3/maturin-action@v1
8090
with:
8191
target: ${{ matrix.target }}
82-
args: --release --out dist --find-interpreter
83-
sccache: 'true'
92+
args: --release --out dist --find-interpreter --features openssl-vendored
8493
- name: Upload wheels
8594
uses: actions/upload-artifact@v4
8695
with:
87-
name: wheels
88-
path: dist
96+
name: wheels-macos-${{ matrix.target }}
97+
path: dist/*
8998

9099
sdist:
91100
runs-on: ubuntu-latest
@@ -99,8 +108,8 @@ jobs:
99108
- name: Upload sdist
100109
uses: actions/upload-artifact@v4
101110
with:
102-
name: wheels
103-
path: dist
111+
name: wheels-sdist
112+
path: dist/*
104113

105114
release:
106115
name: Release
@@ -110,11 +119,11 @@ jobs:
110119
steps:
111120
- uses: actions/download-artifact@v4
112121
with:
113-
name: wheels
122+
path: dist
114123
- name: Publish to PyPI
115124
uses: PyO3/maturin-action@v1
116125
env:
117126
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
118127
with:
119128
command: upload
120-
args: --non-interactive --skip-existing *
129+
args: --non-interactive --skip-existing dist/*

0 commit comments

Comments
 (0)