Skip to content

Commit 060fe3b

Browse files
committed
Add workflow for package generation (#65)
* Ignore artifacts folder * Update build script - Updated to v2.11.0 version. - Skipped compilation of the plugins - The artifact nameis sent to a text file, to access it easily in GitHub Actions. * Add GH action to build min packages * Remove commented code * Remove unused code
1 parent 5eb93d0 commit 060fe3b

File tree

4 files changed

+85
-32
lines changed

4 files changed

+85
-32
lines changed

.github/workflows/build.yml

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Build slim packages
2+
3+
# This workflow runs when any of the following occur:
4+
# - Run manually
5+
on:
6+
workflow_dispatch:
7+
8+
9+
# Used to run locally using https://github.com/nektos/act
10+
env:
11+
ACT:
12+
VERSION: 2.11.0
13+
SNAPSHOT: false
14+
PLATFORM: linux
15+
BUILD: bash scripts/build.sh
16+
17+
18+
jobs:
19+
build:
20+
runs-on: ubuntu-latest
21+
# Permissions to upload the package
22+
permissions:
23+
packages: write
24+
contents: read
25+
strategy:
26+
matrix:
27+
# act is resource-heavy. Avoid running parallel builds with it:
28+
# DISTRIBUTION: [ rpm ]
29+
# ARCHITECTURE: [ x64 ]
30+
DISTRIBUTION: [ tar, rpm, deb ]
31+
ARCHITECTURE: [ x64, arm64 ]
32+
steps:
33+
- uses: actions/checkout@v4
34+
- uses: actions/setup-java@v3
35+
with:
36+
distribution: temurin
37+
java-version: 11
38+
39+
- name: Setup Gradle
40+
uses: gradle/[email protected]
41+
42+
- name: Execute build script
43+
run: |
44+
$BUILD -v $VERSION -s $SNAPSHOT -p $PLATFORM -a ${{ matrix.ARCHITECTURE }} -d ${{ matrix.DISTRIBUTION }}
45+
46+
# The package name is stored in the artifacts/artifact_name.txt file
47+
- name: Read package name
48+
id: package_name
49+
run: |
50+
echo $(ls -la)
51+
echo "package_name=$(cat artifacts/artifact_name.txt)" >> $GITHUB_OUTPUT
52+
echo "$(cat artifacts/artifact_name.txt)"
53+
54+
- name: Upload artifact
55+
uses: actions/upload-artifact@v3
56+
with:
57+
name: ${{ steps.package_name.outputs.package_name }}
58+
path: artifacts/dist/${{ steps.package_name.outputs.package_name }}
59+
if-no-files-found: error
60+
61+
# assemble:
62+
# release:

.github/workflows/gradle_build.yml

-19
This file was deleted.

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# build files
2+
artifacts/
13

24
# intellij files
35
.idea/

scripts/build.sh

+21-13
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,19 @@ fi
7070

7171
[ -z "$OUTPUT" ] && OUTPUT=artifacts
7272

73+
echo "Creating output directory $OUTPUT/maven/org/opensearch if it doesn't already exist"
7374
mkdir -p $OUTPUT/maven/org/opensearch
7475

7576
# Build project and publish to maven local.
77+
echo "Building and publishing OpenSearch project to Maven Local"
7678
./gradlew publishToMavenLocal -Dbuild.snapshot=$SNAPSHOT -Dbuild.version_qualifier=$QUALIFIER
7779

7880
# Publish to existing test repo, using this to stage release versions of the artifacts that can be released from the same build.
81+
echo "Publishing OpenSearch to Test Repository"
7982
./gradlew publishNebulaPublicationToTestRepository -Dbuild.snapshot=$SNAPSHOT -Dbuild.version_qualifier=$QUALIFIER
8083

8184
# Copy maven publications to be promoted
85+
echo "Copying Maven publications to $OUTPUT/maven/org"
8286
cp -r ./build/local-test-repo/org/opensearch "${OUTPUT}"/maven/org
8387

8488
# Assemble distribution artifact
@@ -103,6 +107,20 @@ case $PLATFORM-$DISTRIBUTION-$ARCHITECTURE in
103107
TARGET="$PLATFORM-arm64-$PACKAGE"
104108
SUFFIX="$PLATFORM-arm64"
105109
;;
110+
linux-deb-x64)
111+
PACKAGE="deb"
112+
EXT="deb"
113+
TYPE="packages"
114+
TARGET="deb"
115+
SUFFIX="amd64"
116+
;;
117+
linux-deb-arm64)
118+
PACKAGE="deb"
119+
EXT="deb"
120+
TYPE="packages"
121+
TARGET="arm64-deb"
122+
SUFFIX="arm64"
123+
;;
106124
linux-rpm-x64)
107125
PACKAGE="rpm"
108126
EXT="rpm"
@@ -142,20 +160,10 @@ echo "Building OpenSearch for $PLATFORM-$DISTRIBUTION-$ARCHITECTURE"
142160
./gradlew :distribution:$TYPE:$TARGET:assemble -Dbuild.snapshot=$SNAPSHOT -Dbuild.version_qualifier=$QUALIFIER
143161

144162
# Copy artifact to dist folder in bundle build output
163+
echo "Copying artifact to ${OUTPUT}/dist"
145164
[[ "$SNAPSHOT" == "true" ]] && IDENTIFIER="-SNAPSHOT"
146165
ARTIFACT_BUILD_NAME=`ls distribution/$TYPE/$TARGET/build/distributions/ | grep "opensearch-min.*$SUFFIX.$EXT"`
166+
# [WAZUH] Used by the GH workflow to upload the artifact
167+
echo "$ARTIFACT_BUILD_NAME" > "$OUTPUT/artifact_name.txt"
147168
mkdir -p "${OUTPUT}/dist"
148169
cp distribution/$TYPE/$TARGET/build/distributions/$ARTIFACT_BUILD_NAME "${OUTPUT}"/dist/$ARTIFACT_BUILD_NAME
149-
150-
echo "Building core plugins..."
151-
mkdir -p "${OUTPUT}/core-plugins"
152-
cd plugins
153-
../gradlew assemble -Dbuild.snapshot="$SNAPSHOT" -Dbuild.version_qualifier=$QUALIFIER
154-
cd ..
155-
for plugin in plugins/*; do
156-
PLUGIN_NAME=$(basename "$plugin")
157-
if [ -d "$plugin" ] && [ "examples" != "$PLUGIN_NAME" ]; then
158-
PLUGIN_ARTIFACT_BUILD_NAME=`ls "$plugin"/build/distributions/ | grep "$PLUGIN_NAME.*$IDENTIFIER.zip"`
159-
cp "$plugin"/build/distributions/"$PLUGIN_ARTIFACT_BUILD_NAME" "${OUTPUT}"/core-plugins/"$PLUGIN_ARTIFACT_BUILD_NAME"
160-
fi
161-
done

0 commit comments

Comments
 (0)