Skip to content

Commit 46da6f1

Browse files
authored
added initial ci/cd (#6)
* added initial ci/cd
1 parent b53fa70 commit 46da6f1

File tree

1 file changed

+142
-0
lines changed

1 file changed

+142
-0
lines changed

.github/workflows/publish.yml

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
name: Release Build Pipeline
2+
3+
on:
4+
release:
5+
types: [published, created]
6+
workflow_dispatch:
7+
8+
jobs:
9+
build-native:
10+
name: Build Native Library (${{ matrix.os }} - ${{ matrix.arch }})
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
matrix:
14+
include:
15+
- os: ubuntu-22.04
16+
arch: x86_64
17+
OUT_OS_NAME: linux
18+
- os: ubuntu-22.04
19+
arch: aarch64
20+
OUT_OS_NAME: linux
21+
- os: macos-12
22+
arch: x86_64
23+
OUT_OS_NAME: darwin
24+
- os: macos-12
25+
arch: arm64
26+
OUT_OS_NAME: darwin
27+
- os: windows-2022
28+
arch: x86_64
29+
OUT_OS_NAME: windows
30+
fail-fast: false
31+
32+
steps:
33+
- name: Checkout code
34+
uses: actions/checkout@v4
35+
36+
# Add debug info for testing context
37+
- name: Show Release Info
38+
if: ${{ github.event_name == 'release' }}
39+
run: |
40+
echo "Release ID: ${{ github.event.release.id }}"
41+
echo "Draft Status: ${{ github.event.release.draft }}"
42+
echo "Tag: ${{ github.event.release.tag_name }}"
43+
44+
# Existing build steps remain unchanged
45+
- name: Setup Julia
46+
uses: julia-actions/setup-julia@v2
47+
with:
48+
version: '1.10'
49+
50+
- name: Setup JDK
51+
uses: actions/setup-java@v4
52+
with:
53+
distribution: 'temurin'
54+
java-version: '21'
55+
56+
- name: Install dependencies
57+
shell: bash
58+
run: |
59+
if [[ "$RUNNER_OS" == "Linux" ]]; then
60+
sudo apt-get update
61+
sudo apt-get install -y cmake make swig gcc g++
62+
elif [[ "$RUNNER_OS" == "macOS" ]]; then
63+
brew update
64+
brew install cmake make swig
65+
elif [[ "$RUNNER_OS" == "Windows" ]]; then
66+
choco install cmake make swig
67+
fi
68+
69+
- name: Build native library
70+
shell: bash
71+
run: |
72+
cd swig
73+
cmake .
74+
make install
75+
cd ..
76+
echo "Library built at: $(pwd)/src/main/resources/native/64/${{ matrix.OUT_OS_NAME }}"
77+
78+
# Add artifact retention period based on release type
79+
- name: Upload artifact
80+
uses: actions/upload-artifact@v4
81+
with:
82+
name: native-${{ matrix.OUT_OS_NAME }}-${{ matrix.arch }}
83+
path: src/main/resources/native/64/${{ matrix.OUT_OS_NAME }}/
84+
retention-days: ${{ github.event.release.draft && 7 || 1 }}
85+
86+
build-java:
87+
name: Build Java Library
88+
runs-on: ubuntu-22.04
89+
needs: build-native
90+
if: ${{ !cancelled() }} # Run unless previous jobs were cancelled
91+
92+
steps:
93+
- name: Checkout code
94+
uses: actions/checkout@v4
95+
96+
- name: Setup JDK
97+
uses: actions/setup-java@v4
98+
with:
99+
distribution: 'temurin'
100+
java-version: '21'
101+
102+
- name: Download native artifacts
103+
uses: actions/download-artifact@v4
104+
with:
105+
path: native-artifacts
106+
107+
- name: Assemble native libraries
108+
shell: bash
109+
run: |
110+
for artifact in native-artifacts/*; do
111+
os_arch=$(basename $artifact)
112+
os=$(echo $os_arch | cut -d'-' -f2)
113+
mkdir -p "src/main/resources/native/64/$os"
114+
cp -R "$artifact"/* "src/main/resources/native/64/$os/"
115+
done
116+
echo "Assembled native libraries:"
117+
find src/main/resources/native -type f
118+
119+
- name: Build Java library
120+
run: ./gradlew build
121+
122+
# Test artifact before final upload
123+
- name: Test JAR (Example)
124+
run: |
125+
java -jar build/libs/*.jar --version
126+
# Add your real validation commands here
127+
128+
# Conditional artifact upload
129+
- name: Upload Java artifact
130+
if: ${{ github.event.release.draft || github.event_name == 'workflow_dispatch' }}
131+
uses: actions/upload-artifact@v4
132+
with:
133+
name: java-library
134+
path: build/libs/*.jar
135+
retention-days: 7
136+
137+
# Only attach to release when published
138+
- name: Attach to Release
139+
if: ${{ github.event_name == 'release' && !github.event.release.draft }}
140+
uses: softprops/action-gh-release@v2
141+
with:
142+
files: build/libs/*.jar

0 commit comments

Comments
 (0)