Skip to content

Commit

Permalink
Add build workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
f-galland committed Sep 23, 2024
1 parent 3f8b53f commit e974593
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 0 deletions.
90 changes: 90 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
irun-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: "reporting"
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: "reporting"
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=$(<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/wazuh-indexer-${{ inputs.plugin }}-${{ steps.version.outputs.version }}.${{ inputs.revision }}.zip
if-no-files-found: error
14 changes: 14 additions & 0 deletions .github/workflows/build_on_push.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit e974593

Please sign in to comment.