Build #64
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: Build | |
on: | |
workflow_dispatch: | |
push: | |
tags: | |
- "v*.*.*" | |
# branches: | |
# - main | |
# release: | |
# types: | |
# - published | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
# cf. https://github.com/oxigraph/oxigraph/blob/main/.github/workflows/artifacts.yml | |
jobs: | |
binary_linux: | |
name: 🐧 Build binaries for Linux | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- run: rustup update && rustup target add aarch64-unknown-linux-gnu | |
- run: | | |
sudo apt update && sudo apt install -y g++-aarch64-linux-gnu | |
echo -e "\n\n[target.aarch64-unknown-linux-gnu]\nlinker = \"aarch64-linux-gnu-gcc\"" >> .cargo/config.toml | |
- uses: Swatinem/rust-cache@v2 | |
- run: cargo build --release | |
working-directory: ./cli | |
- run: cargo build --release --target aarch64-unknown-linux-gnu | |
working-directory: ./cli | |
env: | |
BINDGEN_EXTRA_CLANG_ARGS: --sysroot /usr/aarch64-linux-gnu | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: nanopub_x86_64_linux_gnu | |
path: target/release/nanopub-cli | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: nanopub_aarch64_linux_gnu | |
path: target/aarch64-unknown-linux-gnu/release/nanopub-cli | |
- if: startsWith(github.ref, 'refs/tags/') | |
run: | | |
mv target/release/nanopub-cli nanopub_x86_64_linux_gnu | |
mv target/aarch64-unknown-linux-gnu/release/nanopub-cli nanopub_aarch64_linux_gnu | |
- uses: softprops/action-gh-release@v1 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
files: | | |
nanopub_x86_64_linux_gnu | |
nanopub_aarch64_linux_gnu | |
# nanopub_${{ github.event.release.tag_name }}_x86_64_linux_gnu | |
# tag_name: ${{ github.event.release.tag_name }} | |
binary_mac: | |
name: 🍎 Build binaries for MacOS | |
runs-on: macos-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- run: rustup update && rustup target add aarch64-apple-darwin | |
- run: | | |
sudo apt update && sudo apt install -y g++-aarch64-linux-gnu | |
echo -e "\n\n[target.aarch64-unknown-linux-gnu]\nlinker = \"aarch64-linux-gnu-gcc\"" >> .cargo/config.toml | |
- uses: Swatinem/rust-cache@v2 | |
- run: cargo build --release | |
working-directory: ./cli | |
- run: cargo build --release --target aarch64-apple-darwin | |
working-directory: ./cli | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: nanopub_x86_64_apple | |
path: target/release/nanopub-cli | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: nanopub_aarch64_apple | |
path: target/aarch64-apple-darwin/release/nanopub-cli | |
- if: startsWith(github.ref, 'refs/tags/') | |
run: | | |
mv target/release/nanopub-cli nanopub_x86_64_apple | |
mv target/aarch64-apple-darwin/release/nanopub-cli nanopub_aarch64_apple | |
- uses: softprops/action-gh-release@v1 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
files: | | |
nanopub_x86_64_apple | |
nanopub_aarch64_apple | |
binary_windows: | |
name: 🪟 Build binaries for Windows | |
runs-on: windows-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- run: rustup update | |
- uses: Swatinem/rust-cache@v2 | |
- run: cargo build --release | |
working-directory: ./cli | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: nanopub_x86_64_windows_msvc | |
path: target/release/nanopub-cli.exe | |
- if: startsWith(github.ref, 'refs/tags/') | |
run: | | |
mv target/release/nanopub-cli.exe nanopub_x86_64_windows_msvc.exe | |
- uses: softprops/action-gh-release@v1 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
files: | | |
nanopub_x86_64_windows_msvc.exe | |
# https://github.com/pydantic/pydantic-core/blob/main/.github/workflows/ci.yml | |
build_wheels: | |
name: 🐍 Build wheel for ${{ matrix.os }} (${{ matrix.target }} - ${{ matrix.interpreter || 'all' }}${{ matrix.os == 'linux' && format(' - {0}', matrix.manylinux == 'auto' && 'manylinux' || matrix.manylinux) || '' }}) | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [linux, macos, windows] | |
target: [x86_64, aarch64] | |
manylinux: [auto] | |
include: | |
# manylinux for various platforms, plus x86_64 pypy | |
- os: linux | |
manylinux: auto | |
target: i686 | |
- os: linux | |
manylinux: auto | |
target: aarch64 | |
- os: linux | |
manylinux: auto | |
target: armv7 | |
interpreter: 3.8 3.9 3.10 3.11 3.12 | |
- os: linux | |
manylinux: auto | |
target: ppc64le | |
interpreter: 3.8 3.9 3.10 3.11 3.12 | |
- os: linux | |
manylinux: auto | |
target: s390x | |
interpreter: 3.8 3.9 3.10 3.11 3.12 | |
- os: linux | |
manylinux: auto | |
target: x86_64 | |
interpreter: pypy3.9 pypy3.10 | |
# musllinux | |
- os: linux | |
manylinux: musllinux_1_1 | |
target: x86_64 | |
- os: linux | |
manylinux: musllinux_1_1 | |
target: aarch64 | |
# macos; | |
# all versions x86_64 | |
# arm pypy and older pythons which can't be run on the arm hardware for PGO | |
- os: macos | |
target: x86_64 | |
- os: macos | |
target: aarch64 | |
interpreter: 3.8 3.9 pypy3.9 pypy3.10 | |
# windows; | |
# x86_64 pypy builds are not PGO optimized | |
# i686 not supported by pypy | |
# aarch64 only 3.11 and up, also not PGO optimized | |
- os: windows | |
target: x86_64 | |
interpreter: pypy3.9 pypy3.10 | |
- os: windows | |
target: i686 | |
python-architecture: x86 | |
interpreter: 3.8 3.9 3.10 3.11 3.12 | |
- os: windows | |
target: aarch64 | |
interpreter: 3.11 3.12 | |
runs-on: ${{ (matrix.os == 'linux' && 'ubuntu') || matrix.os }}-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
architecture: ${{ matrix.python-architecture || 'x64' }} | |
- run: pip install -U twine 'ruff==0.1.3' typing_extensions | |
# generate self-schema now, so we don't have to do so inside docker in maturin build | |
# - run: python generate_self_schema.py | |
- name: Build wheels | |
uses: PyO3/maturin-action@v1 | |
with: | |
target: ${{ matrix.target }} | |
manylinux: ${{ matrix.manylinux }} | |
args: --release --out dist --interpreter ${{ matrix.interpreter || '3.8 3.9 3.10 3.11 3.12 pypy3.9 pypy3.10' }} | |
rust-toolchain: stable | |
docker-options: -e CI | |
working-directory: python | |
- run: ${{ (matrix.os == 'windows' && 'dir') || 'ls -lh' }} python/dist/ | |
- run: twine check --strict python/dist/* | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: nanopub_wheel_${{ matrix.os }}_${{ matrix.target }}_${{ matrix.interpreter || 'all' }}_${{ matrix.manylinux }} | |
path: python/dist | |
- name: Publish to PyPI | |
if: startsWith(github.ref, 'refs/tags/') | |
run: twine upload python/dist/* | |
env: | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} | |
# - name: Publish to PyPI | |
# uses: PyO3/maturin-action@v1 | |
# env: | |
# MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} | |
# with: | |
# command: upload | |
# args: --non-interactive --skip-existing * | |
npm_tarball: | |
name: 🦊 Build npm package | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- run: rustup update | |
- uses: Swatinem/rust-cache@v2 | |
- name: Install wasm-pack for JS | |
run: cargo install wasm-pack || true | |
- name: Setup NodeJS | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
registry-url: 'https://registry.npmjs.org' | |
cache: npm | |
cache-dependency-path: "./js/package.json" | |
- name: Build npm package | |
run: npm run pack | |
working-directory: ./js | |
- name: Upload tarball | |
uses: actions/upload-artifact@v4 | |
with: | |
name: nanopub_sign_npm | |
path: ./js/pkg | |
- run: npm run release | |
working-directory: ./js | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
if: startsWith(github.ref, 'refs/tags/') | |
publish_crates: | |
name: 📦️ Publish crates to crates.io | |
if: startsWith(github.ref, 'refs/tags/') | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- run: rustup update | |
- run: cargo login $CRATES_IO_TOKEN | |
env: | |
CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }} | |
- run: cargo publish | |
working-directory: ./lib | |
generate-changelog: | |
name: 🏔️ Generate changelog for GitHub release | |
runs-on: ubuntu-latest | |
outputs: | |
release_body: ${{ steps.git-cliff.outputs.content }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Generate a changelog | |
uses: orhun/git-cliff-action@main | |
id: git-cliff | |
with: | |
config: cliff.toml | |
args: -vv --latest --strip header | |
env: | |
OUTPUT: CHANGES.md | |
- name: Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
body_path: CHANGES.md | |
if: startsWith(github.ref, 'refs/tags/') |