From d2cef9e644a936976746e7c2464fc1385331e039 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lex=20Ruiz?= Date: Wed, 28 Aug 2024 17:16:49 +0200 Subject: [PATCH] Add build.yml workflow (#28) * Add build.yml * Update build.yml * Fix zip path * Add improvements Upgrade Java. Remove setup-gradle. Add revision. * Rename wazuh.version to just version * Add build_on_push * Fix unspecified version bug * Add back setup-gradle for caching * Unify workflows * Roll back * Upgrade to OpenSearch 2.15.0 --- .github/dependabot.yml | 2 +- .github/workflows/build.yml | 90 ++++++++++++++++++++++++ .github/workflows/build_on_push.yml | 14 ++++ VERSION | 1 + plugins/wazuh-indexer-setup/build.gradle | 12 +++- 5 files changed, 115 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/build_on_push.yml create mode 100644 VERSION diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 5e03af7..22fbfcc 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,5 +1,5 @@ updates: - - directory: / + - directory: /plugins open-pull-requests-limit: 1 package-ecosystem: gradle schedule: diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..e81dcef --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,90 @@ +run-name: Build ${{ inputs.plugin }} plugin | ${{ inputs.id }} +name: Build packages + +# This workflow runs when any of the following occur: +# - Run manually +# - Invoked from another workflow +on: + workflow_dispatch: + inputs: + revision: + description: "Revision" + type: string + default: "0" + plugin: + description: "Name of the plugin to build" + type: string + default: "wazuh-indexer-setup" + id: + description: "ID used to identify the workflow uniquely." + type: string + required: false + workflow_call: + inputs: + revision: + description: "Revision" + type: string + default: "0" + plugin: + description: "Name of the plugin to build" + type: string + default: "wazuh-indexer-setup" + id: + description: "ID used to identify the workflow uniquely." + type: string + required: false + +# ========================== +# Bibliography +# ========================== +# +# * Reusable workflows: limitations +# | https://docs.github.com/en/actions/using-workflows/reusing-workflows#limitations +# * Using matrix in reusable workflows: +# | https://docs.github.com/en/actions/using-workflows/reusing-workflows#using-a-matrix-strategy-with-a-reusable-workflow +# * Reading input from the called workflow +# | https://docs.github.com/en/enterprise-cloud@latest/actions/using-workflows/workflow-syntax-for-github-actions#onworkflow_callinputs +# * Ternary operator +# | https://docs.github.com/en/actions/learn-github-actions/expressions#example + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 21 + + - name: Setup Gradle # Used for caching + uses: gradle/actions/setup-gradle@v4 + + - name: Get version + id: version + run: echo "version=$(> "$GITHUB_OUTPUT" + + - name: Build with Gradle + working-directory: ./plugins/${{ inputs.plugin }} + run: ./gradlew build -Dversion=${{ steps.version.outputs.version }} -Drevision=${{ inputs.revision }} + + # - name: Test RPM package + # if: ${{ matrix.distribution == 'rpm' }} + # uses: addnab/docker-run-action@v3 + # with: + # image: redhat/ubi9:latest + # options: -v ${{ github.workspace }}/artifacts/dist:/artifacts/dist + # run: | + # yum localinstall "/artifacts/dist/${{ steps.package.outputs.name }}" -y + + # - name: Test DEB package + # if: ${{ matrix.distribution == 'deb' }} + # run: | + # sudo dpkg -i "artifacts/dist/${{ steps.package.outputs.name }}" + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ inputs.plugin }}-${{ steps.version.outputs.version }}.${{ inputs.revision }}.zip + path: plugins/${{ inputs.plugin }}/build/distributions/${{ inputs.plugin }}-${{ steps.version.outputs.version }}.${{ inputs.revision }}.zip + if-no-files-found: error diff --git a/.github/workflows/build_on_push.yml b/.github/workflows/build_on_push.yml new file mode 100644 index 0000000..bc27845 --- /dev/null +++ b/.github/workflows/build_on_push.yml @@ -0,0 +1,14 @@ +name: Build packages (on push) + +# This workflow runs when any of the following occur: +# - On push to branches named after ci/* +on: + push: + # Sequence of patterns matched against refs/heads + branches: + - "ci/*" + +jobs: + call-build-workflow: + uses: ./.github/workflows/build.yml + secrets: inherit \ No newline at end of file diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..28cbf7c --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +5.0.0 \ No newline at end of file diff --git a/plugins/wazuh-indexer-setup/build.gradle b/plugins/wazuh-indexer-setup/build.gradle index 4dd6547..12d5eaf 100644 --- a/plugins/wazuh-indexer-setup/build.gradle +++ b/plugins/wazuh-indexer-setup/build.gradle @@ -12,7 +12,6 @@ def pluginDescription = 'Wazuh Indexer setup plugin' def projectPath = 'org.wazuh' def pathToPlugin = 'setup' def pluginClassName = 'WazuhIndexerSetupPlugin' -group = "WazuhIndexerSetupGroup" tasks.register("preparePluginPathDirs") { mustRunAfter clean @@ -38,7 +37,7 @@ publishing { } developers { developer { - name = "OpenSearch" + name = "Wazuh" url = "https://github.com/opensearch-project/opensearch-plugin-template-java" } } @@ -63,7 +62,9 @@ validateNebulaPom.enabled = false buildscript { ext { - opensearch_version = System.getProperty("opensearch.version", "2.14.0") + opensearch_version = System.getProperty("opensearch.version", "2.15.0") + wazuh_version = System.getProperty("version", "5.0.0") + revision = System.getProperty("revision", "0") } repositories { @@ -78,6 +79,11 @@ buildscript { } } +allprojects { + group = 'org.wazuh' + version = "${wazuh_version}" + ".${revision}" +} + repositories { mavenLocal() maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" }