Skip to content

Commit a9a22b9

Browse files
committed
Add pipeline to generate release packages (#193)
* Add script to get the version of OpenSearch * Set revision to 0 by default. - Reduce inputs for scripts. - Add script to generate packages' naming convention. - Make scripts self-aware of the OpenSearch version. * Fix assemble * Smoke test new pipeline to build packages * Fix syntax errors * Update build.yml Signed-off-by: Álex Ruiz <[email protected]> * Add workflow to build packages on push * Run actionlint * Fix jq argjson * Fix set matrix output ? * Try new approach using a single workflow * Fix GITHUB_OUTPUT * Fix baptizer invocation * Add testing and upload to new approach * Fix hard coded revision number on RPM assembly * New attempt * Skip upload unless specified * Install plugins on RPM * Promote new approach Removes previous workflows to generate packages * Fix workflow name * Attempt to fix release package naming * Fix build.sh invocation from workflow * Use min package name in workflow * Use min package name for release naming convention in workflow * Attemtp to fix regex * Upgrade to aws-actions/configure-aws-credentials@v4 Clean up * Apply latest requirements Add workflow with single matrix for QA use. Rename inputs. Add checksum input. * Add checksum generation and upload * Use choice as input types for system and architecture * Invoke build single packages with upload option * Add documentation and clean up * Rename scripts folder to packaging_scripts --------- Signed-off-by: Álex Ruiz <[email protected]>
1 parent 2a72c41 commit a9a22b9

18 files changed

+876
-779
lines changed

.github/workflows/build.yml

+163-58
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,68 @@
1-
name: Build packages
1+
name: Build packages (on demand)
22

33
# This workflow runs when any of the following occur:
44
# - Run manually
5+
# - Invoked from another workflow
56
on:
6-
push:
7-
# Sequence of patterns matched against refs/heads
8-
branches:
9-
- "ci/*"
107
workflow_dispatch:
118
inputs:
129
revision:
1310
description: "Revision"
1411
type: string
15-
required: true
16-
default: "1"
12+
default: "0"
1713
upload:
1814
description: "Upload ?"
19-
type: bool
15+
type: boolean
16+
default: false
17+
is_stage:
18+
description: "Is stage ?"
19+
type: boolean
20+
default: false
21+
distribution:
22+
description: '[ "tar", "rpm", "deb" ]'
23+
type: string
24+
default: '[ "rpm", "deb" ]'
25+
architecture:
26+
description: '[ "x64", "arm64" ]'
27+
type: string
28+
default: '[ "x64" ]'
29+
checksum:
30+
description: "Checksum ?"
31+
type: boolean
2032
default: false
33+
workflow_call:
34+
inputs:
35+
revision:
36+
description: "Revision"
37+
type: string
38+
default: "0"
39+
upload:
40+
description: "Upload ?"
41+
type: boolean
42+
default: false
43+
is_stage:
44+
description: "Is stage ?"
45+
type: boolean
46+
default: false
47+
distribution:
48+
description: '[ "tar", "rpm", "deb" ]'
49+
type: string
50+
default: '[ "rpm", "deb" ]'
51+
architecture:
52+
description: '[ "x64", "arm64" ]'
53+
type: string
54+
default: '[ "x64" ]'
55+
checksum:
56+
description: "Checksum ?"
57+
type: boolean
58+
default: false
59+
secrets:
60+
CI_INTERNAL_DEVELOPMENT_BUCKET_USER_ACCESS_KEY:
61+
required: true
62+
description: "AWS user access key"
63+
CI_INTERNAL_DEVELOPMENT_BUCKET_USER_SECRET_KEY:
64+
required: true
65+
description: "AWS user secret key"
2166

2267
# ==========================
2368
# Bibliography
@@ -33,57 +78,117 @@ on:
3378
# | https://docs.github.com/en/actions/learn-github-actions/expressions#example
3479

3580
jobs:
36-
version:
37-
uses: ./.github/workflows/r_version.yml
38-
39-
commit_sha:
40-
uses: ./.github/workflows/r_commit_sha.yml
81+
matrix:
82+
name: Set up matrix
83+
runs-on: ubuntu-latest
84+
outputs:
85+
matrix: ${{ steps.setup.outputs.matrix }}
86+
steps:
87+
- id: setup
88+
run: |
89+
matrix=$(jq -cn \
90+
--argjson distribution '${{ inputs.distribution }}' \
91+
--argjson architecture '${{ inputs.architecture }}' \
92+
'{distribution: $distribution, architecture: $architecture}'
93+
)
94+
echo "matrix=$matrix" >> $GITHUB_OUTPUT
4195
4296
build:
43-
needs: [version, commit_sha]
44-
strategy:
45-
matrix:
46-
distribution: [tar, rpm, deb]
47-
architecture: [x64, arm64]
48-
uses: ./.github/workflows/r_build.yml
49-
with:
50-
architecture: ${{ matrix.architecture }}
51-
distribution: ${{ matrix.distribution }}
52-
revision: ${{ github.event_name == 'push' && '1' || inputs.revision }}
53-
name: wazuh-indexer-min_${{ needs.version.outputs.version }}-${{ github.event_name == 'push' && '1' || inputs.revision }}-${{ matrix.architecture }}_${{ needs.commit_sha.outputs.commit_sha }}.${{ matrix.distribution }}
54-
55-
assemble:
56-
needs: [version, commit_sha, build]
57-
strategy:
58-
matrix:
59-
distribution: [tar, rpm, deb]
60-
architecture: [x64, arm64]
61-
exclude:
62-
# skip arm64 until we have arm runners
63-
- architecture: arm64
64-
- distribution: tar
65-
66-
uses: ./.github/workflows/r_assemble.yml
67-
with:
68-
architecture: ${{ matrix.architecture }}
69-
distribution: ${{ matrix.distribution }}
70-
min: wazuh-indexer-min_${{ needs.version.outputs.version }}-${{ github.event_name == 'push' && '1' || inputs.revision }}-${{ matrix.architecture }}_${{ needs.commit_sha.outputs.commit_sha }}.${{ matrix.distribution }}
71-
72-
test:
73-
needs: [version, commit_sha, assemble]
97+
needs: [matrix]
98+
runs-on: ubuntu-latest
7499
strategy:
75100
fail-fast: false
76-
matrix:
77-
os: [{ suffix: "amd64", ext: "deb" }, { suffix: "x86_64", ext: "rpm" }]
78-
uses: ./.github/workflows/r_test.yml
79-
with:
80-
package: wazuh-indexer-${{ needs.version.outputs.version }}-${{ github.event_name == 'push' && '1' || inputs.revision }}_${{ matrix.os.suffix }}_${{ needs.commit_sha.outputs.commit_sha }}.${{ matrix.os.ext }}
81-
82-
upload:
83-
needs: [version, commit_sha, test]
84-
# Upload only on 'workflow_dispatch' event and if 'upload=true'
85-
if: ${{ github.event_name == 'push' && inputs.upload }}
86-
uses: ./.github/workflows/r_upload.yml
87-
with:
88-
package: wazuh-indexer-${{ needs.version.outputs.version }}-${{ github.event_name == 'push' && '1' || inputs.revision }}_${{ matrix.os.suffix }}_${{ needs.commit_sha.outputs.commit_sha }}.${{ matrix.os.ext }}
89-
secrets: inherit
101+
matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
102+
steps:
103+
- uses: actions/checkout@v4
104+
- uses: actions/setup-java@v4
105+
with:
106+
distribution: temurin
107+
java-version: 11
108+
109+
- name: Setup Gradle
110+
uses: gradle/actions/setup-gradle@v3
111+
112+
- name: Provision
113+
if: ${{ matrix.distribution == 'deb' }}
114+
run: |
115+
sudo bash packaging_scripts/provision.sh
116+
117+
- name: Run `baptizer.sh` (min)
118+
run: |
119+
name=$(bash packaging_scripts/baptizer.sh -m \
120+
-a ${{ matrix.architecture }} \
121+
-d ${{ matrix.distribution }} \
122+
-r ${{ inputs.revision }} \
123+
${{ inputs.is_stage && '-x' || '' }} \
124+
)
125+
echo "name=$name" >> $GITHUB_OUTPUT
126+
id: min_package
127+
128+
- name: Run `baptizer.sh`
129+
run: |
130+
name=$(bash packaging_scripts/baptizer.sh \
131+
-a ${{ matrix.architecture }} \
132+
-d ${{ matrix.distribution }} \
133+
-r ${{ inputs.revision }} \
134+
${{ inputs.is_stage && '-x' || '' }} \
135+
)
136+
echo "name=$name" >> $GITHUB_OUTPUT
137+
id: package
138+
139+
- name: Run `build.sh`
140+
run: |
141+
bash packaging_scripts/build.sh \
142+
-a ${{ matrix.architecture }} \
143+
-d ${{ matrix.distribution }} \
144+
-n ${{ steps.min_package.outputs.name }}
145+
146+
- name: Run `assemble.sh`
147+
run: |
148+
bash packaging_scripts/assemble.sh \
149+
-a ${{ matrix.architecture }} \
150+
-d ${{ matrix.distribution }} \
151+
-r ${{ inputs.revision }}
152+
153+
- name: Test RPM package
154+
if: ${{ matrix.distribution == 'rpm' }}
155+
uses: addnab/docker-run-action@v3
156+
with:
157+
image: redhat/ubi9:latest
158+
options: -v ${{ github.workspace }}/artifacts/dist:/artifacts/dist
159+
run: |
160+
yum localinstall "/artifacts/dist/${{ steps.package.outputs.name }}" -y
161+
162+
- name: Test DEB package
163+
if: ${{ matrix.distribution == 'deb' }}
164+
run: |
165+
sudo dpkg -i "artifacts/dist/${{ steps.package.outputs.name }}"
166+
167+
- name: Upload artifact
168+
uses: actions/upload-artifact@v4
169+
with:
170+
name: ${{ steps.package.outputs.name }}
171+
path: artifacts/dist/${{ steps.package.outputs.name }}
172+
if-no-files-found: error
173+
174+
- name: Set up AWS CLI
175+
if: ${{ inputs.upload }}
176+
uses: aws-actions/configure-aws-credentials@v4
177+
with:
178+
aws-access-key-id: ${{ secrets.CI_INTERNAL_DEVELOPMENT_BUCKET_USER_ACCESS_KEY }}
179+
aws-secret-access-key: ${{ secrets.CI_INTERNAL_DEVELOPMENT_BUCKET_USER_SECRET_KEY }}
180+
aws-region: us-east-1
181+
182+
- name: Upload package to S3
183+
if: ${{ inputs.upload }}
184+
run: |
185+
src="artifacts/dist/${{ steps.package.outputs.name }}"
186+
dest="s3://packages-dev.internal.wazuh.com/development/wazuh/4.x/main/packages/"
187+
aws s3 cp "$src" "$dest"
188+
189+
- name: Upload checksum to S3
190+
if: ${{ inputs.upload && inputs.checksum }}
191+
run: |
192+
src="artifacts/dist/${{ steps.package.outputs.name }}.sha512"
193+
dest="s3://packages-dev.internal.wazuh.com/development/wazuh/4.x/main/packages/"
194+
aws s3 cp "$src" "$dest"

.github/workflows/build_on_push.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Build packages (on push)
2+
3+
# This workflow runs when any of the following occur:
4+
# - On push to branches named after ci/*
5+
on:
6+
push:
7+
# Sequence of patterns matched against refs/heads
8+
branches:
9+
- "ci/*"
10+
11+
jobs:
12+
call-build-workflow:
13+
uses: ./.github/workflows/build.yml
14+
secrets: inherit

.github/workflows/build_single.yml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Build packages (single)
2+
3+
# This workflow runs when any of the following occur:
4+
# - Run manually
5+
on:
6+
workflow_dispatch:
7+
inputs:
8+
revision:
9+
description: "Revision"
10+
type: string
11+
default: "0"
12+
checksum:
13+
description: "Checksum ?"
14+
type: boolean
15+
default: false
16+
is_stage:
17+
description: "Is stage ?"
18+
type: boolean
19+
default: false
20+
system:
21+
description: "Package OS"
22+
type: choice
23+
options:
24+
- rpm
25+
- deb
26+
default: deb
27+
architecture:
28+
description: "Package architecture"
29+
type: choice
30+
options:
31+
- amd64
32+
- x86_64
33+
default: amd64
34+
35+
jobs:
36+
call-build-workflow:
37+
uses: ./.github/workflows/build.yml
38+
with:
39+
revision: ${{ inputs.revision }}
40+
checksum: ${{ inputs.checksum }}
41+
is_stage: ${{ inputs.is_stage }}
42+
distribution: '[ "${{ inputs.system }}" ]'
43+
upload: true
44+
# Architecture is always 'x64', which is the default value in ./build.yml
45+
# It is an input just for convenience and standardisation.
46+
secrets: inherit

.github/workflows/r_assemble.yml

-61
This file was deleted.

0 commit comments

Comments
 (0)