forked from wasmerio/wasmer-java
-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Package all natives in a single jar. #9
Merged
Merged
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
29a0539
Adapt dynamic_libs.yaml so that it uploads libs as artifacts.
Zurcusa c493df0
Add condition when copying native libs to build dir.
Zurcusa db2deda
Test fix pattern.
Zurcusa 7222d93
Test fix pattern.
Zurcusa 844cb9f
Remove matrix.
Zurcusa 2e75294
Test remove pattern from artifact download.
Zurcusa f940624
Refactor dynamic_libs.yaml so that it's callable from release.yaml.
Zurcusa 90b86e3
Add needs flag to release.yaml
Zurcusa a47ec64
Test list structure in native-libs directory.
Zurcusa 7354687
Rework dynamic_libs.yaml so that it's reusable.
Zurcusa 6b62a7d
Test param passs fix.
Zurcusa c2b3680
test
Zurcusa 8d99d9b
test
Zurcusa e12ede0
Remove github.event from the reusable workflow.
Zurcusa 67c552f
Use github.ref.type instead of github.ref
Zurcusa c414ee4
test
Zurcusa 09ed8bd
test
Zurcusa 3736a81
test
Zurcusa a49e03e
Remove test step from dynamic_libs_reusable.yaml.
Zurcusa bcf195d
Add docs.
Zurcusa 257a9b5
Test using randomizes artifacts dir.
Zurcusa bdc6e44
Fix export syntax.
Zurcusa 80e6301
Add section in README.md for env variable.
Zurcusa c18d01f
Change 'native-libs' to using env var.
Zurcusa a247e8b
test
Zurcusa c326cb8
test
Zurcusa 3ccfb91
Push EXT_ARTIFACTS_DIR to gh env.
Zurcusa 618b740
Add mkdir.
Zurcusa 78e7574
Fix mkdir.
Zurcusa 7106719
Fix mkdir.
Zurcusa 4479461
Fix usage of env var in "with" section of step.
Zurcusa 78b3643
Test
Zurcusa bac7a89
Remove comments.
Zurcusa 01fb7d7
Remove leftovers.
Zurcusa c8a3b3c
fix: use "uname -m" when retrieving os arch in Native.java. Change wi…
Zurcusa 92de665
fix: translate x86_64 to amd64 to keep uniform naming of artifacts.
Zurcusa b77263d
Substitute random uuid for mktemp command.
Zurcusa cc1f341
Test fix env var assign
Zurcusa bd53621
Test fix env var assign
Zurcusa 2963391
Test remove cache steps.
Zurcusa 59d0a33
Revert cache removal.
Zurcusa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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 |
This file was deleted.
Oops, something went wrong.
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
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 |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left the workflow trigger to "on push" because the Workflow UI would only update when this is merged to master branch. From what I see that doesn't happen often.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Manual invocation wold be better imo.