Updated: Version to 4.0.0 #107
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Rust Build, Test & Publish | |
on: | |
push: | |
branches: [ main, master, optimize-for-size ] | |
tags: | |
- '*' | |
pull_request: | |
branches: [ main, master, optimize-for-size ] | |
workflow_dispatch: | |
jobs: | |
test-native: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
- id: test-rust | |
uses: Reloaded-Project/reloaded-project-configurations-rust/.github/actions/test-and-coverage@v1 # upgrade if needed | |
with: | |
rust_project_path: src-rust | |
upload_coverage: true | |
rust_branch: nightly | |
test-wine: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
- id: test-rust | |
uses: Reloaded-Project/reloaded-project-configurations-rust/.github/actions/test-in-wine@v1 # upgrade if needed | |
with: | |
rust_project_path: src-rust | |
rust_branch: nightly | |
build-c-libs: | |
strategy: | |
matrix: | |
include: | |
- os: ubuntu-latest | |
target: x86_64-unknown-linux-gnu | |
features: "c_exports" | |
- os: ubuntu-latest | |
target: i686-unknown-linux-gnu | |
features: "c_exports" | |
- os: ubuntu-latest | |
target: aarch64-unknown-linux-gnu | |
features: "c_exports" | |
- os: windows-latest | |
target: x86_64-pc-windows-msvc | |
features: "c_exports" | |
- os: windows-latest | |
target: i686-pc-windows-msvc | |
features: "c_exports" | |
- os: windows-latest | |
target: aarch64-pc-windows-msvc | |
features: "c_exports" | |
- os: macos-latest | |
target: x86_64-apple-darwin | |
features: "c_exports" | |
- os: macos-latest | |
target: aarch64-apple-darwin | |
features: "c_exports" | |
- os: ubuntu-latest | |
target: x86_64-unknown-linux-gnu | |
features: "c_exports,size_opt" | |
- os: ubuntu-latest | |
target: i686-unknown-linux-gnu | |
features: "c_exports,size_opt" | |
- os: ubuntu-latest | |
target: aarch64-unknown-linux-gnu | |
features: "c_exports,size_opt" | |
- os: windows-latest | |
target: x86_64-pc-windows-msvc | |
features: "c_exports,size_opt" | |
- os: windows-latest | |
target: i686-pc-windows-msvc | |
features: "c_exports,size_opt" | |
- os: windows-latest | |
target: aarch64-pc-windows-msvc | |
features: "c_exports,size_opt" | |
- os: macos-latest | |
target: x86_64-apple-darwin | |
features: "c_exports,size_opt" | |
- os: macos-latest | |
target: aarch64-apple-darwin | |
features: "c_exports,size_opt" | |
- os: ubuntu-latest | |
target: x86_64-unknown-linux-gnu | |
features: "c_exports,size_opt,no_format" | |
- os: ubuntu-latest | |
target: i686-unknown-linux-gnu | |
features: "c_exports,size_opt,no_format" | |
- os: ubuntu-latest | |
target: aarch64-unknown-linux-gnu | |
features: "c_exports,size_opt,no_format" | |
- os: windows-latest | |
target: x86_64-pc-windows-msvc | |
features: "c_exports,size_opt,no_format" | |
- os: windows-latest | |
target: i686-pc-windows-msvc | |
features: "c_exports,size_opt,no_format" | |
- os: windows-latest | |
target: aarch64-pc-windows-msvc | |
features: "c_exports,size_opt,no_format" | |
- os: macos-latest | |
target: x86_64-apple-darwin | |
features: "c_exports,size_opt,no_format" | |
- os: macos-latest | |
target: aarch64-apple-darwin | |
features: "c_exports,size_opt,no_format" | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
- id: build-libs | |
uses: Reloaded-Project/reloaded-project-configurations-rust/.github/actions/build-c-library@v1 # upgrade if needed | |
with: | |
rust_project_path: src-rust | |
target: ${{ matrix.target }} | |
features: ${{ matrix.features }} | |
build-c-headers: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
- name: Generate C++ bindings | |
uses: Reloaded-Project/reloaded-project-configurations-rust/.github/actions/generate-bindings@v1 | |
with: | |
rust_project_path: src-rust | |
config_file: cbindgen_cpp.toml | |
header_file: bindings_cpp.hpp | |
- name: Generate C bindings | |
uses: Reloaded-Project/reloaded-project-configurations-rust/.github/actions/generate-bindings@v1 | |
with: | |
rust_project_path: src-rust | |
config_file: cbindgen_c.toml | |
header_file: bindings_c.h | |
publish-artifacts: | |
needs: ["build-c-headers", "build-c-libs", "test-wine", "test-native"] | |
# Publish only on tags | |
if: startsWith(github.ref, 'refs/tags/') | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
- name: ↙️ Download Artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
path: artifacts | |
- name: Compress Artifacts | |
shell: bash | |
run: | | |
dir="artifacts" # Replace with your subdirectory | |
for subdir in "$dir"/*; do | |
if [ -d "$subdir" ]; then | |
base=$(basename "$subdir") | |
zip -r "$dir/$base.zip" "$subdir" | |
rm -r "$subdir" | |
fi | |
done | |
ls -A ./artifacts | |
- name: GitHub Release Artifacts | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: | | |
artifacts/* | |
- name: Publish to crates.io | |
uses: Reloaded-Project/reloaded-project-configurations-rust/.github/actions/publish-crate@v1 | |
with: | |
rust_project_path: src-rust | |
token: ${{ secrets.CRATES_IO_TOKEN }} |