Skip to content

Commit 20d0b68

Browse files
committed
Add workflow to assemble packages (#85)
* Add script to assemble arm64 and x64 archives (tar) * Cleanup * Update config file with latest upstream changes * Change packages maintainer information * Fix wrong substitution of config files * Update dockerignore to ignore git folder * Update wazuh-indexer.rpm.spec Remove unnecessary echo commands * Add wazuh-indexer-performance-analyzer.service Required to assembly RPM. The plugin does not install this file, so it needs to be added manually. * Update assemble.sh Successfully assemble RPM x64. Runner needed to arm64 * Update `build.yml` * Add WIP documentation for packages' generation * Test new approach using reusable workflows * Fix errors * Restructure reusable workflow * Fix upload and download paths * New try - Adds a reusable workflow to return the version of Wazuh set in source code. - Attempt to dynamically generate artifacts name to normalize them for usage between jobs. - Adds revision as input for the workflow. - Cleanup * Emulate assemble to test upload of the reusable assembly workflow * Add Caching Gradle dependencies * Remove extra '-' in the packages names on the assembly job * Final cleanup * Enable RPM package assemble Remove unused code * Fix regex to get package name * Fix download-artifact destination path * Exclude unimplemented deb assembly Extend example to run with Act
1 parent c0421a5 commit 20d0b68

14 files changed

+1910
-63
lines changed

.github/workflows/build.yml

+52-54
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,60 @@
1-
name: Build slim packages
1+
name: Build packages
22

33
# This workflow runs when any of the following occur:
4-
# - Run manually
4+
# - Run manually
55
on:
66
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-
7+
inputs:
8+
revision:
9+
# description:
10+
default: "1"
11+
required: false
12+
type: string
13+
14+
# ==========================
15+
# Bibliography
16+
# ==========================
17+
#
18+
# * Reusable workflows: limitations
19+
# | https://docs.github.com/en/actions/using-workflows/reusing-workflows#limitations
20+
# * Using matrix in reusable workflows:
21+
# | https://docs.github.com/en/actions/using-workflows/reusing-workflows#using-a-matrix-strategy-with-a-reusable-workflow
22+
# * Reading input from the called workflow
23+
# | https://docs.github.com/en/enterprise-cloud@latest/actions/using-workflows/workflow-syntax-for-github-actions#onworkflow_callinputs
1724

1825
jobs:
26+
version:
27+
uses: ./.github/workflows/r_version.yml
28+
1929
build:
20-
runs-on: ubuntu-latest
21-
# Permissions to upload the package
22-
permissions:
23-
packages: write
24-
contents: read
30+
needs: version
2531
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:
32+
matrix:
33+
distribution: [tar, rpm, deb]
34+
architecture: [x64, arm64]
35+
uses: ./.github/workflows/r_build.yml
36+
with:
37+
architecture: ${{ matrix.architecture }}
38+
distribution: ${{ matrix.distribution }}
39+
name: wazuh-indexer-min_${{ needs.version.outputs.version }}-${{ inputs.revision }}-${{ matrix.architecture }}_${{ github.sha }}.${{ matrix.distribution }}
40+
# wazuh-indexer-min_4.8.0-rc1_x64_ff98475f.deb
41+
# TODO arm64 != amd64 (deb), x64 != x86_64 (rpm)
42+
# TODO use short SHA https://stackoverflow.com/a/59819441/13918537
43+
44+
assemble:
45+
needs: [version, build]
46+
strategy:
47+
matrix:
48+
distribution: [tar, rpm, deb]
49+
architecture: [x64, arm64]
50+
exclude:
51+
# skip arm64 until we have arm runners
52+
- architecture: arm64
53+
- distribution: [tar, deb] # Exclude deb assembly until it's implemented
54+
55+
uses: ./.github/workflows/r_assemble.yml
56+
with:
57+
architecture: ${{ matrix.architecture }}
58+
distribution: ${{ matrix.distribution }}
59+
min: wazuh-indexer-min_${{ needs.version.outputs.version }}-${{ inputs.revision }}-${{ matrix.architecture }}_${{ github.sha }}.${{ matrix.distribution }}
60+
name: wazuh-indexer_${{ needs.version.outputs.version }}-${{ inputs.revision }}-${{ matrix.architecture }}_${{ github.sha }}.${{ matrix.distribution }}

.github/workflows/r_assemble.yml

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Assemble (reusable)
2+
3+
# This workflow runs when any of the following occur:
4+
# - Run from another workflow
5+
on:
6+
workflow_call:
7+
inputs:
8+
distribution:
9+
description: 'One of [ "tar", "rpm", "deb" ]'
10+
default: "rpm"
11+
required: false
12+
type: string
13+
architecture:
14+
description: 'One of [ "x64", "arm64" ]'
15+
default: "x64"
16+
required: false
17+
type: string
18+
min:
19+
description: The name of the package to download.
20+
required: true
21+
type: string
22+
name:
23+
description: The name of the package to upload.
24+
required: true
25+
type: string
26+
27+
jobs:
28+
r_assemble:
29+
runs-on: ubuntu-latest
30+
# Permissions to upload the package
31+
permissions:
32+
packages: write
33+
contents: read
34+
steps:
35+
- uses: actions/checkout@v4
36+
- name: Download artifact
37+
uses: actions/download-artifact@v4
38+
with:
39+
name: ${{ inputs.min }}
40+
path: artifacts/dist
41+
42+
- name: Run `assemble.sh`
43+
run: |
44+
bash scripts/assemble.sh -v ${{ vars.OPENSEARCH_VERSION }} -p linux -a ${{ inputs.architecture }} -d ${{ inputs.distribution }}
45+
46+
# The package's name is stored in artifacts/artifact_name.txt.
47+
- name: Set package name
48+
id: get_name
49+
run: |
50+
echo "name=$(cat artifacts/artifact_name.txt)" >> $GITHUB_OUTPUT
51+
52+
- name: Upload artifact
53+
uses: actions/upload-artifact@v4
54+
with:
55+
name: ${{ inputs.name }}
56+
path: artifacts/dist/${{ steps.get_name.outputs.name }}
57+
if-no-files-found: error
58+

.github/workflows/r_build.yml

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Build (reusable)
2+
3+
# This workflow runs when any of the following occur:
4+
# - Run from another workflow
5+
on:
6+
workflow_call:
7+
inputs:
8+
distribution:
9+
description: 'One of [ "tar", "rpm", "deb" ]'
10+
default: "rpm"
11+
required: false
12+
type: string
13+
architecture:
14+
description: 'One of [ "x64", "arm64" ]'
15+
default: "x64"
16+
required: false
17+
type: string
18+
name:
19+
type: string
20+
21+
jobs:
22+
r_build:
23+
runs-on: ubuntu-latest
24+
# Permissions to upload the package
25+
permissions:
26+
packages: write
27+
contents: read
28+
steps:
29+
- uses: actions/checkout@v4
30+
- uses: actions/setup-java@v4
31+
with:
32+
distribution: temurin
33+
java-version: 11
34+
35+
- name: Setup Gradle
36+
uses: gradle/[email protected]
37+
38+
- name: Run `build.sh`
39+
run: |
40+
bash scripts/build.sh -v ${{ vars.OPENSEARCH_VERSION }} -s false -p linux -a ${{ inputs.architecture }} -d ${{ inputs.distribution }}
41+
42+
# The package's name is stored in artifacts/artifact_name.txt.
43+
- name: Set package name
44+
id: get_name
45+
run: |
46+
echo "name=$(cat artifacts/artifact_name.txt)" >> $GITHUB_OUTPUT
47+
48+
- name: Upload artifact
49+
uses: actions/upload-artifact@v4
50+
with:
51+
name: ${{ inputs.name }}
52+
path: artifacts/dist/${{ steps.get_name.outputs.name }}
53+
if-no-files-found: error

.github/workflows/r_version.yml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Version (reusable)
2+
3+
# This workflow runs when any of the following occur:
4+
# - Run from another workflow
5+
on:
6+
workflow_call:
7+
outputs:
8+
version:
9+
description: "Returns the version of Wazuh"
10+
value: ${{ jobs.r_version.outputs.version }}
11+
12+
jobs:
13+
r_version:
14+
runs-on: ubuntu-latest
15+
outputs:
16+
version: ${{ steps.get_version.outputs.version }}
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: Read 'VERSION'
20+
id: get_version
21+
run: |
22+
echo "version=$(cat VERSION)" >> $GITHUB_OUTPUT

distribution/packages/build.gradle

+3-3
Original file line numberDiff line numberDiff line change
@@ -324,13 +324,13 @@ apply plugin: 'com.netflix.nebula.ospackage-base'
324324

325325
// this is package indepdendent configuration
326326
ospackage {
327-
maintainer ='OpenSearch Team <opensearch@amazon.com>'
327+
maintainer = 'Wazuh, Inc <info@wazuh.com>'
328328
summary = 'Distributed RESTful search engine built for the cloud'
329329
packageDescription = '''
330330
Reference documentation can be found at
331-
https://github.com/opensearch-project/OpenSearch
331+
https://documentation.wazuh.com/current/getting-started/components/wazuh-indexer.html
332332
'''.stripIndent().trim()
333-
url = 'https://github.com/opensearch-project/OpenSearch'
333+
url = 'https://documentation.wazuh.com/current/getting-started/components/wazuh-indexer.html'
334334

335335
// signing setup
336336
if (project.hasProperty('signing.password') && BuildParams.isSnapshotBuild() == false) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright OpenSearch Contributors
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
# The OpenSearch Contributors require contributions made to
5+
# this file be licensed under the Apache-2.0 license or a
6+
# compatible open source license.
7+
8+
[Unit]
9+
Description=wazuh-indexer Performance Analyzer
10+
11+
[Service]
12+
Type=simple
13+
ExecStart=/usr/share/wazuh-indexer/bin/wazuh-indexer-performance-analyzer/performance-analyzer-agent-cli
14+
Restart=on-failure
15+
User=wazuh-indexer
16+
Group=wazuh-indexer
17+
EnvironmentFile=-/etc/sysconfig/wazuh-indexer
18+
WorkingDirectory=/usr/share/wazuh-indexer
19+
20+
[Install]
21+
WantedBy=multi-user.target

0 commit comments

Comments
 (0)