From 7da1c0e779638b92b00aa2a180e992f9aadf8566 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lex=20Ruiz?= Date: Wed, 22 Nov 2023 23:21:15 +0100 Subject: [PATCH] Add GH action to build min packages --- .github/workflows/build.yml | 63 ++++++++++++++++++++++++++++++ .github/workflows/gradle_build.yml | 19 --------- scripts/build.sh | 2 +- 3 files changed, 64 insertions(+), 20 deletions(-) create mode 100644 .github/workflows/build.yml delete mode 100644 .github/workflows/gradle_build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000000000..baeef9061e7d5 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,63 @@ +name: Build slim packages + +# This workflow runs when any of the following occur: + # - Run manually +on: + workflow_dispatch: + + +# Used to run locally using https://github.com/nektos/act +env: + ACT: + VERSION: 2.11.0 + SNAPSHOT: false + PLATFORM: linux + BUILD: bash scripts/build.sh + PACKAGE_NAME: + + +jobs: + build: + runs-on: ubuntu-latest + # Permissions to upload the package + permissions: + packages: write + contents: read + strategy: + matrix: + # For act: + # DISTRIBUTION: [ rpm ] + # ARCHITECTURE: [ x64 ] + DISTRIBUTION: [ tar, rpm, deb ] + ARCHITECTURE: [ x64, arm64 ] + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v3 + with: + distribution: temurin + java-version: 11 + + - name: Setup Gradle + uses: gradle/gradle-build-action@v2.9.0 + + - name: Execute build script + run: | + $BUILD -v $VERSION -s $SNAPSHOT -p $PLATFORM -a ${{ matrix.ARCHITECTURE }} -d ${{ matrix.DISTRIBUTION }} + + # The package name is stored in the artifacts/artifact_name.txt file + - name: Read package name + id: package_name + run: | + echo $(ls -la) + echo "package_name=$(cat artifacts/artifact_name.txt)" >> $GITHUB_OUTPUT + echo "$(cat artifacts/artifact_name.txt)" + + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: ${{ steps.package_name.outputs.package_name }} + path: artifacts/dist/${{ steps.package_name.outputs.package_name }} + if-no-files-found: error + + # assemble: + # release: diff --git a/.github/workflows/gradle_build.yml b/.github/workflows/gradle_build.yml deleted file mode 100644 index d7916f852abf1..0000000000000 --- a/.github/workflows/gradle_build.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: Run Gradle Build -on: - schedule: - - cron: '00 8 * * 5' -jobs: - gradle: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-java@v3 - with: - distribution: temurin - java-version: 11 - - - name: Setup Gradle - uses: gradle/gradle-build-action@v2.9.0 - - - name: Execute Gradle build - run: ./gradlew build diff --git a/scripts/build.sh b/scripts/build.sh index a8737386fb3cc..45480c7038de7 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -164,7 +164,7 @@ echo "Copying artifact to ${OUTPUT}/dist" [[ "$SNAPSHOT" == "true" ]] && IDENTIFIER="-SNAPSHOT" ARTIFACT_BUILD_NAME=`ls distribution/$TYPE/$TARGET/build/distributions/ | grep "opensearch-min.*$SUFFIX.$EXT"` # [WAZUH] Used by the GH workflow to upload the artifact -echo "$ARTIFACT_BUILD_NAME" >> "$OUTPUT/artifact_name.txt" +echo "$ARTIFACT_BUILD_NAME" > "$OUTPUT/artifact_name.txt" mkdir -p "${OUTPUT}/dist" cp distribution/$TYPE/$TARGET/build/distributions/$ARTIFACT_BUILD_NAME "${OUTPUT}"/dist/$ARTIFACT_BUILD_NAME