Skip to content

Commit

Permalink
Binaries update (#8)
Browse files Browse the repository at this point in the history
* removed bintray mentions and added bonus configuration in the release yaml that requires testing

Signed-off-by: Georgi Georgiev <[email protected]>

* changed action provider for prerelease

Signed-off-by: Georgi Georgiev <[email protected]>

* removed creating pre-release

Signed-off-by: Georgi Georgiev <[email protected]>

* update gradelev

Signed-off-by: Georgi Georgiev <[email protected]>

* added echo command for arch

Signed-off-by: Georgi Georgiev <[email protected]>

* added line

Signed-off-by: Georgi Georgiev <[email protected]>

* fix

Signed-off-by: Georgi Georgiev <[email protected]>

* trying

Signed-off-by: Georgi Georgiev <[email protected]>

* added missing line

Signed-off-by: Georgi Georgiev <[email protected]>

* switched sopaces for tabs

Signed-off-by: Georgi Georgiev <[email protected]>

* small changes

Signed-off-by: Georgi Georgiev <[email protected]>

* typo

Signed-off-by: Georgi Georgiev <[email protected]>

* added a separate file for the mac release

Signed-off-by: Georgi Georgiev <[email protected]>

* 2nd try with arch

Signed-off-by: Georgi Georgiev <[email protected]>

* distribution

Signed-off-by: Georgi Georgiev <[email protected]>

* added additional file for building the dylibs

Signed-off-by: Georgi Georgiev <[email protected]>

* nerf eddition level

Signed-off-by: Georgi Georgiev <[email protected]>

* another nerf

Signed-off-by: Georgi Georgiev <[email protected]>

* aded file for dylib generation

Signed-off-by: Georgi Georgiev <[email protected]>

* /testing

Signed-off-by: Georgi Georgiev <[email protected]>

* changed generation command

Signed-off-by: Georgi Georgiev <[email protected]>

* changed release action

Signed-off-by: Georgi Georgiev <[email protected]>

* added rustup target

Signed-off-by: Georgi Georgiev <[email protected]>

* typo

Signed-off-by: Georgi Georgiev <[email protected]>

* typo

Signed-off-by: Georgi Georgiev <[email protected]>

* testing

Signed-off-by: Georgi Georgiev <[email protected]>

* testing

Signed-off-by: Georgi Georgiev <[email protected]>

* testing

Signed-off-by: Georgi Georgiev <[email protected]>

* testing

Signed-off-by: Georgi Georgiev <[email protected]>

* testing

Signed-off-by: Georgi Georgiev <[email protected]>

* changed all the yamls to activate on release to test everything together

Signed-off-by: Georgi Georgiev <[email protected]>

* added some logs as well

Signed-off-by: Georgi Georgiev <[email protected]>

* removed the 32 linux platform as github doesnt support such images and wasmer-vm causes crash when trying to cross-compile

Signed-off-by: Georgi Georgiev <[email protected]>

* change to on push

Signed-off-by: Georgi Georgiev <[email protected]>

* the aarch64v linux is incompatible too

Signed-off-by: Georgi Georgiev <[email protected]>

* removed slashes

Signed-off-by: Georgi Georgiev <[email protected]>

* deleted the outdated commandd in makefile

Signed-off-by: Georgi Georgiev <[email protected]>

* undo deleting the makefile rust build commands as it is apperantly used by the test yaml as well

Signed-off-by: Georgi Georgiev <[email protected]>

* Package all natives in a single jar. (#9)

* Adapt dynamic_libs.yaml so that it uploads libs as artifacts.

* Add condition when copying native libs to build dir.
Test download artifacts in release.yaml.

* Test fix pattern.

* Test fix pattern.

* Remove matrix.

* Test remove pattern from artifact download.

* Refactor dynamic_libs.yaml so that it's callable from release.yaml.

* Add needs flag to release.yaml

* Test list structure in native-libs directory.

* Rework dynamic_libs.yaml so that it's reusable.
Adapt release.yaml to use dynamic_libs_reusable.yaml.
Executing release.yaml from a branch uploads the jar with all the possible native libs inside the workflow artifacts.
Executing it from a tag uploads it to the tag's release.

* Test param passs fix.

* test

* test

* Remove github.event from the reusable workflow.

* Use github.ref.type instead of github.ref

* test

* test

* test

* Remove test step from dynamic_libs_reusable.yaml.
Use startsWith expression in release.yaml.

* Add docs.
Change name of JAR.

* Test using randomizes artifacts dir.

* Fix export syntax.

* Add section in README.md for env variable.
Rename GH_ARTIFACTS_DIR to EXT_ARTIFACTS_DIR

* Change 'native-libs' to using env var.

* test

* test

* Push EXT_ARTIFACTS_DIR to gh env.

* Add mkdir.

* Fix mkdir.

* Fix mkdir.

* Fix usage of env var in "with" section of step.

* Test

* Remove comments.

* Remove leftovers.

* fix: use "uname -m" when retrieving os arch in Native.java. Change win32 to windows.

* fix: translate x86_64 to amd64 to keep uniform naming of artifacts.

* Substitute random uuid for mktemp command.

* Test fix env var assign

* Test fix env var assign

* Test remove cache steps.

* Revert cache removal.

---------

Signed-off-by: Georgi Georgiev <[email protected]>
Co-authored-by: Yordan Atanasov <[email protected]>
  • Loading branch information
georg-getz and Zurcusa authored Jun 10, 2024
1 parent cb4fafe commit db50e67
Show file tree
Hide file tree
Showing 11 changed files with 232 additions and 257 deletions.
134 changes: 134 additions & 0 deletions .github/workflows/build_publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# This workflow compiles the native wasmer_jni lib into various OS and architectures using dynamic_libs_reusable.yaml.
# Then it builds and publishes the JAR based on the GITHUB_REF that calls the workflow. There are 2 options:
# 1. The workflow is executed from a branch. In that case the JAR is available in the GitHub action as an artifact.
# 2. The workflow is executed from a tag. In that case the JAR is published in the corresponding GitHub release.
name: Build and publish

on:
push:
branches:
- '*' # Trigger on push to any branch
tags:
- '*' # Trigger on push to any tag

jobs:
upload_dynamic_libs:
strategy:
matrix:
platform:
- os: 'macos-latest'
target: 'aarch64-apple-darwin'
artifact: 'darwin-arm64'
lib_name: 'libwasmer_jni.dylib'

- os: 'macos-latest'
target: 'x86_64-apple-darwin'
artifact: 'darwin-amd64'
lib_name: 'libwasmer_jni.dylib'

- os: 'ubuntu-latest'
target: 'x86_64-unknown-linux-gnu'
artifact: 'linux-amd64'
lib_name: 'libwasmer_jni.so'

- os: 'windows-latest'
target: 'x86_64-pc-windows-msvc'
artifact: 'windows-amd64'
lib_name: 'wasmer_jni.dll'
uses: ./.github/workflows/dynamic_libs_reusable.yaml
with:
platform_os: ${{ matrix.platform.os }}
platform_target: ${{ matrix.platform.target }}
platform_artifact: ${{ matrix.platform.artifact }}
platform_lib_name: ${{ matrix.platform.lib_name }}

publish_jar:
name: Publish the JARs
runs-on: ubuntu-latest
needs: [upload_dynamic_libs]

steps:
- name: Check out code
uses: actions/checkout@v2

- name: Set up Java 21
uses: actions/setup-java@v1
with:
java-version: 21

- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
default: true
override: true

- name: Cache Cargo registry
uses: actions/cache@v1
with:
path: ~/.cargo/registry
key: cargo-registry-${{ hashFiles('**/Cargo.lock') }}

- name: Cache Cargo bin
uses: actions/cache@v1
with:
path: ~/.cargo/bin
key: cargo-bin-${{ hashFiles('**/Cargo.lock') }}

- name: Cache Cargo build
uses: actions/cache@v1
with:
path: target
key: cargo-build-target-${{ hashFiles('**/Cargo.lock') }}

- name: Setup wasmer-jni artifacts dir
shell: bash
run: |
echo "EXT_ARTIFACTS_DIR=$(mktemp -d)" >> $GITHUB_ENV
- name: Download wasmer_jni artifacts
uses: actions/download-artifact@v4
with:
path: ${{ env.EXT_ARTIFACTS_DIR }}

- name: Display structure of downloaded files
run: ls -R $EXT_ARTIFACTS_DIR

- name: Run all the tests
shell: bash
run: |
export PATH="$HOME/.cargo/bin:$PATH"
make test
- name: Create the JAR
id: create_jar
shell: bash
run: |
export PATH="$HOME/.cargo/bin:$PATH"
make package
- name: Upload JAR as workflow artifact
if: startsWith(github.ref, 'refs/heads/')
uses: actions/upload-artifact@v4
with:
name: ${{ steps.create_jar.outputs.name }}
path: ${{ steps.create_jar.outputs.path }}
retention-days: 1

- name: Get release info
id: get_release_info
if: startsWith(github.ref, 'refs/tags/')
uses: bruceadams/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload JAR as Github pre-release asset
if: startsWith(github.ref, 'refs/tags/')
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.get_release_info.outputs.upload_url }}
asset_path: ${{ steps.create_jar.outputs.path }}
asset_name: ${{ steps.create_jar.outputs.name }}
asset_content_type: application/java-archive
53 changes: 53 additions & 0 deletions .github/workflows/dynamic_libs_reusable.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# This workflow cross compiles a rust library into a native based on a provided target.
# The compiled library is then uploaded as a GitHub artifact.
name: upload_dynamic_libs

on:
workflow_call:
inputs:
platform_os:
description: Operating system that the runner will use.
type: string
required: true
platform_target:
description: The architecture that rust will compile the libs for.
type: string
required: true
platform_artifact:
description: The name of the artifact that will be uploaded.
type: string
required: true
platform_lib_name:
description: Name of the native library to be uploaded in the artifact.
type: string
required: true


jobs:
publish_dlibs:
name: Publish the dynamic libraries
runs-on: ${{ inputs.platform_os }}
steps:
- name: Check out code
uses: actions/checkout@v3

- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
default: true
override: true

- name: Create the dynamic libs
shell: bash
run: |
export PATH="$HOME/.cargo/bin:$PATH"
rustup target add ${{ inputs.platform_target }}
cargo build --release --target=${{ inputs.platform_target }}
- name: Upload the dynamic libs
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.platform_artifact }}
path: ./target/${{ inputs.platform_target }}/release/${{ inputs.platform_lib_name }}
retention-days: 1
130 changes: 0 additions & 130 deletions .github/workflows/release.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/test.yml → .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ jobs:
strategy:
matrix:
# The job runs on 3 different OS.
os: [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-latest, macos-13, windows-latest]
# The job runs on different Java versions (LTS).
java: [8]
java: [21]
# As soon as one job fails in the matrix, all the other
# in-progress jobs are canceled.
fail-fast: true
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
[package]
publish = false
name = "wasmer-jni"
version = "0.3.0"
authors = ["Ivan Enderlin <[email protected]>"]
edition = "2018"
version = "1.1.0"
edition = "2021"

[lib]
crate-type = ["cdylib"]
Expand Down
4 changes: 0 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,6 @@ javadoc:
package:
"./gradlew" --info jar

# Publish the package artifact to a public repository
publish:
"./gradlew" --info uploadToBintray

# Run a specific example, with `make run-example EXAMPLE=Simple` for instance.
run-example:
$(eval JAR := $(shell find ./build/libs/ -name "wasmer-jni-*.jar"))
Expand Down
Loading

0 comments on commit db50e67

Please sign in to comment.