Merge pull request #232 from unum-cloud/main-dev #134
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: Release | |
on: | |
push: | |
branches: ["main"] | |
env: | |
BUILD_TYPE: Release | |
GH_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN }} | |
PYTHONUTF8: 1 | |
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | |
permissions: | |
contents: write | |
pages: write | |
id-token: write | |
jobs: | |
versioning: | |
name: Semantic Release | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
persist-credentials: false | |
- uses: actions/setup-node@v3 | |
- run: npm install --save-dev @semantic-release/exec @semantic-release/git conventional-changelog-eslint semantic-release && npx semantic-release | |
rebase: | |
name: Rebase Development Branch | |
needs: versioning | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the latest code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Perform rebase | |
run: | | |
git checkout main-dev | |
git rebase main | |
- name: Push changes | |
uses: CasperWA/push-protected@v2 | |
with: | |
token: ${{ secrets.SEMANTIC_REBASE_TOKEN }} | |
branch: main-dev | |
unprotect_reviews: True | |
force: True | |
publish_hashes: | |
name: Add hashes to release notes | |
runs-on: ubuntu-latest | |
needs: versioning | |
steps: | |
- name: Get last release ID | |
id: last_release | |
run: | | |
response=$(curl -s -H "Authorization: Bearer ${{ secrets.SEMANTIC_RELEASE_TOKEN }}" \ | |
"https://api.github.com/repos/${{ github.repository }}/releases/latest") | |
echo "last_release_id=$(echo "$response" | jq -r '.id')" >> $GITHUB_OUTPUT | |
- uses: robinraju/[email protected] | |
name: Download release assets | |
with: | |
latest: true | |
fileName: "*" | |
out-file-path: "downloads" | |
tarBall: true | |
zipBall: true | |
- name: Calculate source hashes | |
id: hashes | |
run: | | |
source_zip_path=$(find $GITHUB_WORKSPACE/downloads -name "*.zip") | |
zip_hash=$(sha256sum "$source_zip_path" | awk '{print $1}') | |
source_tar_path=$(find $GITHUB_WORKSPACE/downloads -name "*.tar.gz" ! -name "docs.tar.gz") | |
tar_hash=$(sha256sum "$source_tar_path" | awk '{print $1}') | |
echo "zip_hash=$zip_hash" >> $GITHUB_OUTPUT | |
echo "tar_hash=$tar_hash" >> $GITHUB_OUTPUT | |
- name: Upload hashes to release | |
uses: irongut/[email protected] | |
with: | |
token: ${{ secrets.SEMANTIC_RELEASE_TOKEN }} | |
id: ${{ steps.last_release.outputs.last_release_id }} | |
prerelease: false | |
replacebody: false | |
body: | | |
## Hashes | |
* Source code (zip) : `${{ steps.hashes.outputs.zip_hash }}` | |
* Source code (tar.gz) : `${{ steps.hashes.outputs.tar_hash }}` | |
build_wheels: | |
name: Build Wheels for ${{ matrix.os }} | |
needs: versioning | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-20.04, macOS-11, windows-2022] | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: 'main' | |
- uses: actions/setup-python@v3 | |
- name: Setup Docker | |
if: matrix.os == 'ubuntu-20.04' | |
uses: crazy-max/[email protected] | |
with: | |
version: 23.0.1 | |
- name: Setup QEMU | |
if: matrix.os == 'ubuntu-20.04' | |
uses: docker/[email protected] | |
- name: Install CIBuildWheel | |
run: python -m pip install cibuildwheel | |
- name: Build wheels | |
run: python -m cibuildwheel | |
- uses: actions/upload-artifact@v3 | |
with: | |
path: ./wheelhouse/*.whl | |
publish_python: | |
name: Publish Python | |
needs: build_wheels | |
runs-on: ubuntu-20.04 | |
environment: | |
name: pypi | |
url: https://pypi.org/p/usearch | |
permissions: | |
id-token: write | |
steps: | |
- name: Download artifacts | |
uses: actions/[email protected] | |
with: | |
path: ./dist/ | |
- name: Publish to PyPi | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
packages-dir: ./dist/artifact | |
verbose: true | |
print-hash: true | |
publish_javascript: | |
name: Publish JavaScript | |
needs: versioning | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: 'main' | |
- run: git submodule update --init --recursive | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- run: npm install | |
- run: npm ci | |
- run: npm test | |
- uses: JS-DevTools/npm-publish@v2 | |
with: | |
token: ${{ secrets.NPM_TOKEN }} | |
publish_rust: | |
name: Publish Rust | |
needs: versioning | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: 'main' | |
- run: git submodule update --init --recursive | |
- uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
override: true | |
- uses: katyo/publish-crates@v2 | |
with: | |
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
publish_java: | |
name: Publish Java | |
needs: versioning | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: 'main' | |
- run: git submodule update --init --recursive | |
- uses: actions/setup-java@v3 | |
with: | |
java-version: '11' | |
distribution: 'adopt' | |
- name: Setup Gradle | |
uses: gradle/[email protected] | |
- name: Execute Gradle build | |
run: gradle clean build | |
- name: Publish package | |
run: gradle publish | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
publish_swift: | |
name: Publish ObjC & Swift | |
needs: versioning | |
runs-on: macos-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: 'main' | |
- run: git submodule update --init --recursive | |
- name: Build | |
run: swift build | |
- name: Run tests | |
run: swift test | |
# Publishes to both Docker Hub and GitHub Container Registry | |
# https://docs.github.com/en/actions/publishing-packages/publishing-docker-images#publishing-images-to-docker-hub-and-github-packages | |
publish_docker: | |
name: Publish Docker Image | |
needs: versioning | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: 'main' | |
- run: git submodule update --init --recursive | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Log in to GitHub Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Extract tags & labels for Docker | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
unum/usearch | |
ghcr.io/${{ github.repository }} | |
- name: Build and push | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
build_csharp: | |
name: Build NuGet | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
runs-on: ${{ matrix.os }} | |
defaults: | |
run: | |
shell: bash | |
steps: | |
- uses: actions/checkout@v3 | |
- run: git submodule update --init --recursive | |
- name: Ubuntu/macOS build usearch shared obj | |
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' | |
run: ./build_lib.sh | |
working-directory: ${{ github.workspace }}/csharp/eng | |
- name: Windows MSVC build usearch dll | |
if: matrix.os == 'windows-latest' | |
run: | | |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" | |
where cl | |
cl /EHsc /std:c++14 /O2 /LD /Fe:libusearch_c.dll lib.cpp /I. /I../include/ /I../fp16/include/ | |
working-directory: ${{ github.workspace }}/c | |
shell: cmd | |
- name: Windows copy dll | |
if: matrix.os == 'windows-latest' | |
run: | | |
mkdir -p "${GITHUB_WORKSPACE}/csharp/lib/runtimes/win-x64/native" | |
cp "${GITHUB_WORKSPACE}/c/libusearch_c.dll" "${GITHUB_WORKSPACE}/csharp/lib/runtimes/win-x64/native" | |
shell: bash | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: usearch-libs | |
path: ${{ github.workspace }}/csharp/lib/**/* | |
publish_csharp: | |
name: Publish C# | |
runs-on: ubuntu-latest | |
needs: [build_csharp] | |
env: | |
USEARCH_LIBS: ${{ github.workspace }}/csharp/lib | |
NUGET_DIR: ${{ github.workspace }}/csharp/packages | |
# NUGET_SOURCE: https://apiint.nugettest.org/v3/index.json | |
NUGET_SOURCE: https://api.nuget.org/v3/index.json | |
SOLUTION_DIR: ${{ github.workspace }}/csharp | |
steps: | |
- uses: actions/checkout@v3 | |
- run: git submodule update --init --recursive | |
- name: Download usearch libs artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: usearch-libs | |
path: ${{ env.USEARCH_LIBS }} | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: 7.0.x | |
- name: Pack project | |
run: | | |
VERSION_CONTENT=$(< VERSION) | |
dotnet pack "${{ env.SOLUTION_DIR }}" -c Release -p:Version="$VERSION_CONTENT" --output ${{ env.NUGET_DIR }} | |
working-directory: ${{ github.workspace }} | |
- name: Publish NuGet packages | |
run: | | |
dotnet nuget push "${{ env.NUGET_DIR }}/*.nupkg" --api-key "${{ secrets.NUGET_APIKEY }}" --source "${{ env.NUGET_SOURCE }}" | |
build_docs: | |
name: Build Docs | |
runs-on: ubuntu-22.04 | |
if: ${{ always() }} | |
needs: [publish_python, publish_javascript, publish_rust, publish_java, publish_swift, publish_docker, publish_csharp] | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
ref: 'main' | |
- name: Install dependencies | |
run: | | |
sudo apt update && | |
sudo apt install -y doxygen graphviz dia git && | |
pip install sphinx==5.3.0 sphinx-js==3.2.1 breathe==4.35.0 furo==2023.3.27 m2r2==0.3.3.post2 sphinxcontrib-googleanalytics==0.2.dev20220708 sphinxcontrib-jquery==4.1 && | |
npm install -g jsdoc | |
- name: Install USearch from PyPi | |
run: pip install usearch | |
- name: Build documentation | |
run: cd docs && doxygen conf.dox && make html | |
- name: Copy assets | |
run: cp -r assets build/docs/html/ | |
- name: Compress assets | |
run: tar -czvf docs.tar.gz build/docs/html/ | |
- name: Upload docs to release | |
uses: xresloader/upload-to-github-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
file: docs.tar.gz | |
update_latest_release: true | |
deploy_docs_pages: | |
name: Deploy GitHub Pages | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-22.04 | |
if: ${{ always() }} | |
needs: build_docs | |
steps: | |
- uses: robinraju/[email protected] | |
with: | |
latest: true | |
fileName: docs.tar.gz | |
- name: Unpack docs | |
run: tar -xf ./docs.tar.gz | |
- name: Setup GitHub Pages | |
uses: actions/configure-pages@v2 | |
- name: Upload artifacts | |
uses: actions/upload-pages-artifact@v1 | |
with: | |
path: ./build/docs/html | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v1 | |
deploy_docs_vercel: | |
name: Deploy Vercel | |
runs-on: ubuntu-22.04 | |
if: ${{ always() }} | |
needs: build_docs | |
steps: | |
- name: Notify Vercel | |
uses: fjogeleit/http-request-action@v1 | |
with: | |
url: ${{ secrets.DOCS_VERCEL }} | |
method: 'POST' |