Skip to content

Commit 8f71725

Browse files
committed
CI/CD: Add Build and Publish Script
1 parent c6477ab commit 8f71725

5 files changed

Lines changed: 379 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
name: Build Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions:
9+
contents: write
10+
id-token: write
11+
attestations: write
12+
13+
jobs:
14+
15+
build:
16+
17+
strategy:
18+
fail-fast: false
19+
20+
matrix:
21+
include:
22+
23+
- os: ubuntu-latest
24+
target_os: linux
25+
arch: amd64
26+
rust_target: x86_64-unknown-linux-gnu
27+
28+
- os: ubuntu-latest
29+
target_os: linux
30+
arch: arm64
31+
rust_target: aarch64-unknown-linux-gnu
32+
33+
- os: windows-latest
34+
target_os: windows
35+
arch: x64
36+
rust_target: x86_64-pc-windows-msvc
37+
38+
- os: windows-latest
39+
target_os: windows
40+
arch: arm64
41+
rust_target: aarch64-pc-windows-msvc
42+
43+
- os: macos-13
44+
target_os: macos
45+
arch: x64
46+
rust_target: x86_64-apple-darwin
47+
48+
- os: macos-14
49+
target_os: macos
50+
arch: arm64
51+
rust_target: aarch64-apple-darwin
52+
53+
runs-on: ${{ matrix.os }}
54+
55+
steps:
56+
57+
- name: Checkout
58+
uses: actions/checkout@v4
59+
60+
- name: Setup Java
61+
uses: actions/setup-java@v4
62+
with:
63+
distribution: temurin
64+
java-version: 21
65+
66+
- name: Setup Node
67+
uses: actions/setup-node@v4
68+
with:
69+
node-version: 24
70+
71+
- name: Setup Rust
72+
uses: dtolnay/rust-toolchain@stable
73+
with:
74+
targets: ${{ matrix.rust_target }}
75+
76+
- name: Install Linux Dependencies
77+
if: runner.os == 'Linux'
78+
run: |
79+
sudo apt update
80+
sudo apt install -y ruby ruby-dev rpm
81+
sudo gem install fpm
82+
cargo install cargo-cyclonedx || true
83+
84+
- name: Install Windows Dependencies
85+
if: runner.os == 'Windows'
86+
run: |
87+
choco install nsis -y
88+
89+
- name: Build
90+
shell: bash
91+
run: |
92+
chmod +x build.sh
93+
94+
export RUST_TARGET="${{ matrix.rust_target }}"
95+
96+
./build.sh
97+
98+
- name: Package
99+
shell: bash
100+
run: |
101+
chmod +x package.sh
102+
103+
VERSION=${GITHUB_REF#refs/tags/v}
104+
105+
./package.sh \
106+
"$VERSION" \
107+
"${{ matrix.target_os }}" \
108+
"${{ matrix.arch }}"
109+
110+
- name: Upload Artifact
111+
uses: actions/upload-artifact@v4
112+
with:
113+
name: ${{ matrix.target_os }}-${{ matrix.arch }}
114+
path: target/**
115+
116+
release:
117+
118+
needs: build
119+
120+
runs-on: ubuntu-latest
121+
122+
steps:
123+
124+
- name: Download Artifacts
125+
uses: actions/download-artifact@v4
126+
with:
127+
path: artifacts
128+
129+
- name: Create Release
130+
uses: softprops/softprops/gh-release@v2
131+
with:
132+
files: artifacts/**/*
133+
134+
- name: Generate Provenance
135+
uses: actions/attest-build-provenance@v2
136+
with:
137+
subject-path: artifacts/**/*

build.sh

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
PROJECT_NAME="OmegaCode"
6+
7+
ROOT_DIR="$(pwd)"
8+
9+
CONSOLE_UI_DIR="$ROOT_DIR/console/console-ui"
10+
CONSOLE_PANEL_DIR="$ROOT_DIR/console/console-panel"
11+
MCP_SERVER_DIR="$ROOT_DIR/mcp-server"
12+
13+
BUILD_DIR="$ROOT_DIR/build"
14+
BUNDLE_DIR="$BUILD_DIR/release_bundle"
15+
16+
RUST_TARGET="${RUST_TARGET:-}"
17+
18+
echo "=================================="
19+
echo "Build Started"
20+
echo "=================================="
21+
22+
rm -rf "$BUILD_DIR"
23+
mkdir -p "$BUNDLE_DIR"
24+
25+
echo "[UI] Building"
26+
27+
pushd "$CONSOLE_UI_DIR"
28+
29+
npm ci
30+
npm run build
31+
32+
if [ ! -d dist ]; then
33+
echo "dist directory not found"
34+
exit 1
35+
fi
36+
37+
popd
38+
39+
echo "[JAVA] Building"
40+
41+
pushd "$CONSOLE_PANEL_DIR"
42+
43+
mvn -B clean package
44+
45+
PANEL_JAR=$(find target -type f -name "*.jar" \
46+
! -name "*sources.jar" \
47+
! -name "*javadoc.jar" \
48+
| head -n 1)
49+
50+
if [ ! -f "$PANEL_JAR" ]; then
51+
echo "Jar not found"
52+
exit 1
53+
fi
54+
55+
popd
56+
57+
echo "[RUST] Building"
58+
59+
if [ -n "$RUST_TARGET" ]; then
60+
61+
cargo build \
62+
--release \
63+
--target "$RUST_TARGET"
64+
65+
RELEASE_DIR="$ROOT_DIR/target/$RUST_TARGET/release"
66+
67+
else
68+
69+
cargo build --release
70+
71+
RELEASE_DIR="$ROOT_DIR/target/release"
72+
73+
fi
74+
75+
EXECUTABLE="$RELEASE_DIR/OmegaCode"
76+
77+
if [ -f "$EXECUTABLE.exe" ]; then
78+
EXECUTABLE="$EXECUTABLE.exe"
79+
fi
80+
81+
if [ ! -f "$EXECUTABLE" ]; then
82+
echo "OmegaCode executable not found"
83+
exit 1
84+
fi
85+
86+
echo "[BUNDLE]"
87+
88+
mkdir -p "$BUNDLE_DIR/ui"
89+
90+
cp "$EXECUTABLE" \
91+
"$BUNDLE_DIR/"
92+
93+
cp "$PANEL_JAR" \
94+
"$BUNDLE_DIR/console_panel.jar"
95+
96+
cp -R "$CONSOLE_UI_DIR/dist/"* \
97+
"$BUNDLE_DIR/ui/"
98+
99+
cp -R "$MCP_SERVER_DIR" \
100+
"$BUNDLE_DIR/"
101+
102+
mkdir -p "$BUNDLE_DIR/sbom"
103+
104+
if command -v cargo-cyclonedx >/dev/null 2>&1; then
105+
cargo cyclonedx \
106+
--format json \
107+
--output-file "$BUNDLE_DIR/sbom/rust-bom.json" || true
108+
fi
109+
110+
echo "Build Finished"
111+
112+
find "$BUNDLE_DIR"

console/console-panel/pom.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,21 @@
168168
</execution>
169169
</executions>
170170
</plugin>
171+
<plugin>
172+
<groupId>org.cyclonedx</groupId>
173+
<artifactId>cyclonedx-maven-plugin</artifactId>
174+
<version>2.9.1</version>
175+
176+
<executions>
177+
<execution>
178+
<phase>package</phase>
179+
<goals>
180+
<goal>makeAggregateBom</goal>
181+
</goals>
182+
</execution>
183+
</executions>
184+
185+
</plugin>
171186
</plugins>
172187
</build>
173188

installer.nsi

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
!define PRODUCT_NAME "OmegaCode"
2+
3+
OutFile "${PRODUCT_NAME}_${VERSION}_windows_${ARCH}.exe"
4+
5+
InstallDir "$PROGRAMFILES64\OmegaCode"
6+
7+
RequestExecutionLevel admin
8+
9+
Page directory
10+
Page instfiles
11+
12+
Section
13+
14+
SetOutPath "$INSTDIR"
15+
16+
File /r "build\release_bundle\*"
17+
18+
WriteUninstaller "$INSTDIR\uninstall.exe"
19+
20+
SectionEnd
21+
22+
Section "Uninstall"
23+
24+
Delete "$INSTDIR\uninstall.exe"
25+
26+
RMDir /r "$INSTDIR"
27+
28+
SectionEnd

package.sh

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
VERSION="$1"
6+
TARGET_OS="$2"
7+
TARGET_ARCH="$3"
8+
9+
PROJECT_NAME="OmegaCode"
10+
11+
ROOT_DIR="$(pwd)"
12+
13+
BUILD_DIR="$ROOT_DIR/build"
14+
BUNDLE_DIR="$BUILD_DIR/release_bundle"
15+
16+
OUTPUT_DIR="$ROOT_DIR/target/${PROJECT_NAME}-${VERSION}"
17+
18+
mkdir -p "$OUTPUT_DIR"
19+
20+
echo "Packaging..."
21+
echo "Version : $VERSION"
22+
echo "OS : $TARGET_OS"
23+
echo "Arch : $TARGET_ARCH"
24+
25+
tar -czf \
26+
"$OUTPUT_DIR/${PROJECT_NAME}_${VERSION}_${TARGET_OS}_${TARGET_ARCH}.tar.gz" \
27+
-C "$BUILD_DIR" \
28+
release_bundle
29+
30+
if [ "$TARGET_OS" = "linux" ]; then
31+
32+
fpm \
33+
-s dir \
34+
-t deb \
35+
-n "$PROJECT_NAME" \
36+
-v "$VERSION" \
37+
--architecture "$TARGET_ARCH" \
38+
"$BUNDLE_DIR=/usr/local/OmegaCode"
39+
40+
mv ./*.deb "$OUTPUT_DIR/" 2>/dev/null || true
41+
42+
fpm \
43+
-s dir \
44+
-t rpm \
45+
-n "$PROJECT_NAME" \
46+
-v "$VERSION" \
47+
--architecture "$TARGET_ARCH" \
48+
"$BUNDLE_DIR=/usr/local/OmegaCode"
49+
50+
mv ./*.rpm "$OUTPUT_DIR/" 2>/dev/null || true
51+
52+
fi
53+
54+
if [ "$TARGET_OS" = "windows" ]; then
55+
56+
makensis \
57+
-DVERSION="$VERSION" \
58+
-DARCH="$TARGET_ARCH" \
59+
installer.nsi
60+
61+
mv ./*.exe "$OUTPUT_DIR/" 2>/dev/null || true
62+
63+
fi
64+
65+
if [ "$TARGET_OS" = "macos" ]; then
66+
67+
DMG_NAME="${PROJECT_NAME}_${VERSION}_macOS_${TARGET_ARCH}.dmg"
68+
69+
hdiutil create \
70+
-volname "$PROJECT_NAME" \
71+
-srcfolder "$BUNDLE_DIR" \
72+
-ov \
73+
-format UDZO \
74+
"$OUTPUT_DIR/$DMG_NAME"
75+
76+
fi
77+
78+
if [ -d "$BUNDLE_DIR/sbom" ]; then
79+
80+
tar -czf \
81+
"$OUTPUT_DIR/${PROJECT_NAME}_${VERSION}_sbom.tar.gz" \
82+
-C "$BUNDLE_DIR" \
83+
sbom
84+
85+
fi
86+
87+
echo "Packaging Finished"

0 commit comments

Comments
 (0)