forked from wasmerio/wasmer-java
-
Notifications
You must be signed in to change notification settings - Fork 2
133 lines (116 loc) · 4.09 KB
/
build_publish.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# 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
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