Skip to content

Commit d2c0290

Browse files
committed
chore: git-action sample 추가
1 parent e094cca commit d2c0290

1 file changed

Lines changed: 192 additions & 0 deletions

File tree

.github/workflows/java-release.yml

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
name: Release Universal JAR
2+
3+
on:
4+
#태그를 트리거로 사용하시려면 주석을 제거하시고 사용하시면 됩니다#
5+
#push:
6+
# tags:
7+
# - 'v*'
8+
workflow_dispatch:
9+
inputs:
10+
version:
11+
description: 'The version to release (e.g., 1.0.11)'
12+
required: true
13+
default: '1.0.11'
14+
15+
jobs:
16+
build-native-libs:
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
include:
21+
- os: windows-latest
22+
rust_target: x86_64-pc-windows-msvc
23+
lib_name: braillify.dll
24+
artifact_name: braillify-dll
25+
native_path: windows-x86_64
26+
27+
- os: ubuntu-latest
28+
rust_target: x86_64-unknown-linux-gnu
29+
lib_name: libbraillify.so
30+
artifact_name: braillify-so
31+
native_path: linux-x86_64
32+
33+
- os: macos-15-intel
34+
rust_target: x86_64-apple-darwin
35+
lib_name: libbraillify.dylib
36+
artifact_name: braillify-dylib-x86
37+
native_path: darwin-x86_64
38+
39+
- os: macos-latest
40+
rust_target: aarch64-apple-darwin
41+
lib_name: libbraillify.dylib
42+
artifact_name: braillify-dylib-aarch64
43+
native_path: darwin-aarch64
44+
45+
runs-on: ${{ matrix.os }}
46+
defaults:
47+
run:
48+
working-directory: packages/java
49+
steps:
50+
- name: Checkout required subtree only
51+
uses: actions/checkout@v4
52+
with:
53+
fetch-depth: 1
54+
sparse-checkout: |
55+
packages/java
56+
sparse-checkout-cone-mode: true
57+
58+
59+
- name: Set version
60+
id: set_version
61+
shell: bash
62+
run: |
63+
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
64+
VERSION="${{ github.event.inputs.version }}"
65+
else
66+
VERSION="${GITHUB_REF#refs/tags/v}"
67+
fi
68+
echo "version=$VERSION" >> $GITHUB_OUTPUT
69+
70+
- name: Update Cargo.toml on Windows
71+
if: runner.os == 'Windows'
72+
shell: pwsh
73+
run: |
74+
$version = "${{ steps.set_version.outputs.version }}"
75+
(Get-Content src/main/java/com/devfive/Cargo.toml) |
76+
ForEach-Object {
77+
$_ `
78+
-replace '^(version\s*=\s*)".*"', "`$1`"$version`"" `
79+
-replace '^(braillify\s*=\s*)".*"', "`$1`"$version`""
80+
} |
81+
Set-Content src/main/java/com/devfive/Cargo.toml
82+
83+
- name: Update Cargo.toml on Linux/macOS
84+
if: runner.os != 'Windows'
85+
shell: bash
86+
run: |
87+
VERSION="${{ steps.set_version.outputs.version }}"
88+
sed -i'' \
89+
-e "s/^\(version\s*=\s*\)\".*\"/\1\"${VERSION}\"/" \
90+
-e "s/^\(braillify\s*=\s*\)\".*\"/\1\"${VERSION}\"/" \
91+
src/main/java/com/devfive/Cargo.toml
92+
93+
- name: Set up JDK 8
94+
uses: actions/setup-java@v4
95+
with:
96+
java-version: '8'
97+
distribution: 'temurin'
98+
99+
- name: Set up Rust toolchain
100+
uses: dtolnay/rust-toolchain@stable
101+
with:
102+
targets: ${{ matrix.rust_target }}
103+
104+
- name: Grant execute permission for gradlew
105+
if: runner.os != 'Windows'
106+
run: chmod +x gradlew
107+
108+
- name: Build native library (Windows)
109+
if: runner.os == 'Windows'
110+
shell: cmd
111+
run: gradlew.bat cargoBuild --no-daemon
112+
113+
- name: Build native library (Unix)
114+
if: runner.os != 'Windows'
115+
shell: bash
116+
run: ./gradlew cargoBuild --no-daemon
117+
118+
- name: native output
119+
shell: bash
120+
run: |
121+
echo "Expected:"
122+
echo "src/main/java/com/devfive/target/${{ matrix.rust_target }}/release/${{ matrix.lib_name }}"
123+
ls -R src/main/java/com/devfive/target || true
124+
125+
- name: Upload native library artifact
126+
uses: actions/upload-artifact@v4
127+
with:
128+
name: ${{ matrix.artifact_name }}
129+
path: src/main/java/com/devfive/target/${{ matrix.rust_target }}/release/${{ matrix.lib_name }}
130+
if-no-files-found: error
131+
132+
assemble-jar:
133+
runs-on: ubuntu-latest
134+
needs: build-native-libs
135+
136+
steps:
137+
- name: Checkout repository
138+
uses: actions/checkout@v4
139+
140+
- name: Set version
141+
id: set_version
142+
shell: bash
143+
run: |
144+
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
145+
VERSION="${{ github.event.inputs.version }}"
146+
else
147+
VERSION="${GITHUB_REF#refs/tags/v}"
148+
fi
149+
echo "version=$VERSION" >> $GITHUB_OUTPUT
150+
151+
- name: Set up JDK8
152+
uses: actions/setup-java@v4
153+
with:
154+
java-version: '8'
155+
distribution: 'temurin'
156+
157+
- name: Download native library artifacts
158+
uses: actions/download-artifact@v4
159+
with:
160+
path: native-libs
161+
162+
- name: downloaded artifacts
163+
shell: bash
164+
run: ls -R native-libs
165+
166+
- name: Move native libraries
167+
shell: bash
168+
run: |
169+
mkdir -p src/main/resources/natives/windows-x86_64
170+
mv native-libs/braillify-dll/braillify.dll src/main/resources/natives/windows-x86_64/
171+
172+
mkdir -p src/main/resources/natives/linux-x86_64
173+
mv native-libs/braillify-so/libbraillify.so src/main/resources/natives/linux-x86_64/
174+
175+
mkdir -p src/main/resources/natives/darwin-x86_64
176+
mv native-libs/braillify-dylib-x86/libbraillify.dylib src/main/resources/natives/darwin-x86_64/
177+
178+
mkdir -p src/main/resources/natives/darwin-aarch64
179+
mv native-libs/braillify-dylib-aarch64/libbraillify.dylib src/main/resources/natives/darwin-aarch64/
180+
181+
- name: Grant execute permission for gradlew
182+
run: chmod +x gradlew
183+
184+
- name: Assemble Universal JAR
185+
run: ./gradlew deployJar -PreleaseVersion=${{ steps.set_version.outputs.version }} --no-daemon
186+
187+
- name: Upload Universal JAR
188+
uses: actions/upload-artifact@v4
189+
with:
190+
name: braillify-universal-jar
191+
path: build/libs/braillify-${{ steps.set_version.outputs.version }}.jar
192+
if-no-files-found: error

0 commit comments

Comments
 (0)