Release v2.0.0 #58
Workflow file for this run
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 | |
run-name: Release ${{github.event.inputs.release-version || github.ref_name}} | |
concurrency: | |
group: ${{github.workflow}}-${{github.ref}} | |
cancel-in-progress: true | |
on: | |
push: | |
tags: | |
- 'v[0-9]+.[0-9]+.[0-9]+' # ex. v1.0.0 | |
- 'v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+' # ex. v1.1.0-rc1 for pre-releases | |
workflow_dispatch: | |
inputs: | |
release-version: | |
description: "Release version (v#.#.#[-rc#])" | |
required: true | |
env: | |
NEW_RELEASE_TAG: ${{github.event.inputs.release-version || github.ref_name}} | |
TEST_RUN: ${{contains(github.event.inputs.release-version || github.ref_name, '-rc')}} | |
CARGO_TERM_COLOR: always | |
RUST_BACKTRACE: 1 | |
RUSTFLAGS: -D warnings | |
jobs: | |
verify: | |
name: Checks core project built in Rust | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Install Rust Toolchain Stable | |
uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af | |
with: | |
toolchain: stable | |
default: true | |
profile: default | |
target: wasm32-unknown-unknown | |
- name: Install Rust Toolchain Nightly | |
uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af | |
with: | |
toolchain: nightly-2023-12-28 | |
default: false | |
profile: default | |
target: wasm32-unknown-unknown | |
- name: Cargo check | |
run: make check | |
- name: Cargo test | |
run: make test | |
- name: Cargo fmt | |
run: make format-check | |
- name: Set Up Cargo Deny | |
run: | | |
cargo install --force cargo-deny | |
cargo generate-lockfile | |
- name: License and Issue Check | |
run: make deny | |
build-artifacts: | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
include: | |
- os: ubuntu-latest | |
java_library: libdsnp_graph_sdk_jni.so | |
node_library: libdsnp_graph_sdk_node.so | |
rust-target: x86_64-unknown-linux-gnu | |
additional-rust-target: aarch64-unknown-linux-gnu | |
- os: windows-latest | |
java_library: dsnp_graph_sdk_jni.dll | |
node_library: dsnp_graph_sdk_node.dll | |
rust-target: x86_64-pc-windows-msvc | |
- os: macos-latest | |
java_library: libdsnp_graph_sdk_jni.dylib | |
node_library: libdsnp_graph_sdk_node.dylib | |
rust-target: aarch64-apple-darwin | |
additional-rust-target: x86_64-apple-darwin | |
name: Build project in ${{ matrix.os }} | |
needs: verify | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Install Rust Toolchain | |
uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af | |
with: | |
toolchain: nightly | |
default: true | |
profile: minimal | |
target: ${{ matrix.rust-target }} | |
- run: rustup target add ${{ matrix.additional-rust-target }} | |
if: ${{ matrix.additional-rust-target != '' }} | |
- name: Set up Java | |
uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 | |
with: | |
java-version: '17' | |
distribution: 'adopt' | |
- name: Set up Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18.x' | |
registry-url: https://registry.npmjs.org/ | |
- name: Build Jni bridge | |
run: | | |
cargo build -p dsnp-graph-sdk-jni --profile production --target ${{ matrix.rust-target }} | |
mkdir -p artifacts/java | |
cp target/${{ matrix.rust-target }}/production/${{ matrix.java_library }} artifacts/java/${{ matrix.rust-target }}_${{ matrix.java_library }} | |
- name: Build Node bridge | |
run: | | |
cargo build -p dsnp-graph-sdk-node --profile production --target ${{ matrix.rust-target }} | |
mkdir -p artifacts/node | |
cp target/${{ matrix.rust-target }}/production/${{ matrix.node_library }} artifacts/node/${{ matrix.rust-target }}_dsnp_graph_sdk_node.node | |
- name: Build additional target for MacOS Jni | |
run: | | |
cargo build -p dsnp-graph-sdk-jni --profile production --target ${{ matrix.additional-rust-target }} | |
mkdir -p artifacts/java | |
cp target/${{ matrix.additional-rust-target }}/production/${{ matrix.java_library }} artifacts/java/${{ matrix.additional-rust-target }}_${{ matrix.java_library }} | |
if: matrix.os == 'macos-latest' && matrix.additional-rust-target != '' | |
- name: Build additional target for MacOS Node | |
run: | | |
cargo build -p dsnp-graph-sdk-node --profile production --target ${{ matrix.additional-rust-target }} | |
cp target/${{ matrix.additional-rust-target }}/production/${{ matrix.node_library }} artifacts/node/${{ matrix.additional-rust-target }}_dsnp_graph_sdk_node.node | |
if: matrix.os == 'macos-latest' && matrix.additional-rust-target != '' | |
- name: Build additional targets for Linux Jni | |
run: | | |
cargo install cross | |
cross build +nightly --target ${{ matrix.additional-rust-target }} -p dsnp-graph-sdk-jni --profile production | |
cp target/${{ matrix.additional-rust-target }}/production/${{ matrix.java_library }} artifacts/java/${{ matrix.additional-rust-target }}_${{ matrix.java_library }} | |
if: matrix.os == 'ubuntu-latest' && matrix.additional-rust-target != '' | |
- name: Build other targets Binary for Linux Node | |
run: | | |
cross build +nightly --target ${{ matrix.additional-rust-target }} -p dsnp-graph-sdk-node --profile production | |
cp target/${{ matrix.additional-rust-target }}/production/${{ matrix.node_library }} artifacts/node/${{ matrix.additional-rust-target }}_dsnp_graph_sdk_node.node | |
if: matrix.os == 'ubuntu-latest' && matrix.additional-rust-target != '' | |
- name: Upload Artifacts Java | |
uses: actions/upload-artifact@v3 | |
with: | |
name: artifacts-java-${{github.run_id}} | |
path: artifacts/java/ | |
- name: Upload Artifacts Node | |
uses: actions/upload-artifact@v3 | |
with: | |
name: artifacts-node-${{github.run_id}} | |
path: artifacts/node/ | |
publish-java: | |
name: Build and Publish JVM | |
runs-on: ubuntu-latest | |
needs: build-artifacts | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Java | |
uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 | |
with: | |
java-version: '17' | |
distribution: 'adopt' | |
- name: Download Binaries | |
id: download-binaries | |
uses: actions/download-artifact@v3 | |
with: | |
name: artifacts-java-${{github.run_id}} | |
path: java/lib/src/main/resources | |
- name: List Downloaded Binaries | |
run: | | |
download_dir=${{steps.download-binaries.outputs.download-path}} | |
echo "Download dir: $download_dir" | |
echo "Downloaded binaries: $(ls -l $download_dir)" | |
- name: Get current version | |
id: version | |
run: | | |
# removing v from in front of tag to get version | |
NEW_VERSION=$(echo '${{ env.NEW_RELEASE_TAG }}' | cut -d 'v' -f 2) | |
echo "New version: $NEW_VERSION" | |
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT | |
- name: Build and Publish with Gradle | |
working-directory: java | |
run: ./gradlew -PprojVersion='${{ steps.version.outputs.version }}' build | |
- name: Publish to GitHub Packages | |
working-directory: java | |
run: ./gradlew -PprojVersion='${{ steps.version.outputs.version }}' publish | |
if: env.TEST_RUN != 'true' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
GITHUB_ACTOR: ${{ github.actor }} | |
publish_npm_package: | |
name: Publish NPM Package | |
runs-on: ubuntu-latest | |
needs: build-artifacts | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18.x' | |
registry-url: https://registry.npmjs.org/ | |
- name: Install NPM Dependencies | |
working-directory: bridge/node | |
run: npm install | |
- name: Get current version | |
id: version | |
working-directory: bridge/node | |
run: echo ::set-output name=version::$(node -p "require('./package.json').version") | |
- name: Show versions | |
working-directory: bridge/node | |
run: | | |
echo "Package: v${{ steps.version.outputs.version }}" | |
echo " Actual: ${{ env.NEW_RELEASE_TAG }}" | |
- name: Use the new version | |
working-directory: bridge/node | |
run: | | |
npm version --new-version "${{ env.NEW_RELEASE_TAG }}" --allow-same-version | |
NEW_VERSION=$(node -p "require('./package.json').version") | |
echo "New version: $NEW_VERSION" | |
env: | |
FULL_SHA: ${{ github.sha }} | |
- name: Build NPM Package | |
working-directory: bridge/node | |
run: | | |
npm run tsc && cp README.md dist/README.md | |
- name: Download Binaries | |
id: download-binaries | |
uses: actions/download-artifact@v3 | |
with: | |
name: artifacts-node-${{github.run_id}} | |
path: bridge/node | |
- name: Copy binaries | |
working-directory: bridge/node | |
run: | | |
cp *_dsnp_graph_sdk_node.node js/ | |
cp *_dsnp_graph_sdk_node.node dist/js/ | |
- name: Publish NPM Package | |
working-directory: bridge/node | |
if: env.TEST_RUN != 'true' | |
run: npm publish --access public | |
env: | |
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} | |
- name: Dry run NPM Package | |
working-directory: bridge/node | |
if: env.TEST_RUN == 'true' | |
run: npm publish --access public --dry-run | |
env: | |
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} | |
generate-docs: | |
name: Generate graph sdk rust docs | |
runs-on: ubuntu-latest | |
needs: build-artifacts | |
permissions: | |
contents: read | |
packages: write | |
pages: write | |
id-token: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Install Rust Toolchain | |
uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af | |
with: | |
toolchain: stable | |
default: true | |
profile: minimal | |
target: wasm32-unknown-unknown | |
- name: Setup Pages | |
uses: actions/configure-pages@v3 | |
- name: Build Docs | |
run: | | |
RUSTC_BOOTSTRAP=1 RUSTDOCFLAGS="--enable-index-page -Zunstable-options" cargo doc --no-deps --all-features | |
- name: Fix file permissions | |
shell: sh | |
run: | | |
chmod -c -R +rX "target/doc" | | |
while read line; do | |
echo "::warning title=Invalid file permissions automatically fixed::$line" | |
done | |
- name: Upload Docs | |
uses: actions/upload-pages-artifact@v1 | |
if: env.TEST_RUN != 'true' | |
with: | |
path: ./target/doc | |
- name: Deploy Docs | |
uses: actions/deploy-pages@v2 | |
if: env.TEST_RUN != 'true' | |
id: deployment | |
release: | |
needs: [publish-java, publish_npm_package, generate-docs] | |
runs-on: ubuntu-latest | |
name: Release generated artifacts | |
permissions: | |
contents: write | |
packages: write | |
steps: | |
- name: Download Java Binaries | |
id: download-binaries-java | |
uses: actions/download-artifact@v3 | |
with: | |
name: artifacts-java-${{github.run_id}} | |
path: downloaded | |
- name: Download Node.js Binaries | |
id: download-binaries-node | |
uses: actions/download-artifact@v3 | |
with: | |
name: artifacts-node-${{github.run_id}} | |
path: downloaded | |
- name: List Downloaded Binaries | |
run: | | |
download_dir=${{steps.download-binaries-node.outputs.download-path}} | |
echo "Download dir: $download_dir" | |
echo "Downloaded binaries: $(ls -l $download_dir)" | |
ls -R | |
- name: creating release | |
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 | |
with: | |
files: | | |
downloaded/* | |
prerelease: ${{ env.TEST_RUN }} | |
name: ${{env.NEW_RELEASE_TAG}} |