forked from opensearch-project/OpenSearch
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test new approach using reusable worfklows
- Loading branch information
Showing
4 changed files
with
179 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,15 +4,35 @@ name: Build packages | |
# - Run manually | ||
on: | ||
workflow_dispatch: | ||
# TODO dynamic matrix or filtering complete matrix based on inputs | ||
# inputs: | ||
# distribution: | ||
# description: 'One of [ "tar", "rpm", "deb", "all" ]' | ||
# default: 'all' | ||
# required: false | ||
# type: string | ||
# architecture: | ||
# description: 'One of [ "x64", "arm64", "all" ]' | ||
# default: 'x64' | ||
# required: true | ||
# type: string | ||
|
||
# TODO para que esto funcione con reusable workflows hay que moverlos a variables | ||
# TODO para pasar el nombre del paquete del stage build al stage assemble hay que usar outputs | ||
|
||
# ========================== | ||
# 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 | ||
|
||
# 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 | ||
ASSEMBLE: bash scripts/assemble.sh | ||
ACT: # Used to run locally using https://github.com/nektos/act | ||
|
||
jobs: | ||
build: | ||
|
@@ -31,10 +51,10 @@ jobs: | |
DISTRIBUTION: [tar, rpm, deb] | ||
ARCHITECTURE: [x64, arm64] | ||
outputs: | ||
package_name: ${{ steps.get_package_name.outputs.package_name }} | ||
package: ${{ steps.r_build.outputs.package }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-java@v3 | ||
- uses: actions/setup-java@v4 | ||
with: | ||
distribution: temurin | ||
java-version: 11 | ||
|
@@ -43,23 +63,19 @@ jobs: | |
uses: gradle/[email protected] | ||
|
||
- name: Run `build.sh` | ||
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: get_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 | ||
id: r_build | ||
uses: ./.github/workflows/r_build.yml | ||
with: | ||
architecture: ${{ matrix.ARCHITECTURE }} | ||
distribution: ${{ matrix.DISTRIBUTION }} | ||
|
||
- name: Run `assemble.sh` | ||
uses: ./.github/workflows/r_assemble.yml | ||
with: | ||
name: ${{ steps.get_package_name.outputs.package_name }} | ||
path: artifacts/dist/${{ steps.get_package_name.outputs.package_name }} | ||
if-no-files-found: error | ||
architecture: ${{ matrix.ARCHITECTURE }} | ||
distribution: ${{ matrix.DISTRIBUTION }} | ||
package: ${{ needs.build.outputs.package }} | ||
# TODO comprobar si usa la misma máquina y hay acceso a ./artifacts/dist | ||
|
||
# assemble: | ||
# # needs: [build] | ||
|
@@ -79,7 +95,7 @@ jobs: | |
# # ARCHITECTURE: [ x64, arm64 ] | ||
# steps: | ||
# - name: Download artifact | ||
# uses: actions/download-artifact@v3 | ||
# uses: actions/download-artifact@v4 | ||
# with: | ||
# name: wazuh-indexer-*${{ matrix.ARCHITECTURE }}*${{ matrix.DISTRIBUTION }} | ||
# # name: ${{ needs.build.outputs.package_name }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
name: Assemble (reusable) | ||
|
||
# This workflow runs when any of the following occur: | ||
# - Run from another workflow | ||
on: | ||
workflow_call: | ||
inputs: | ||
distribution: | ||
description: 'One of [ "tar", "rpm", "deb" ]' | ||
default: 'rpm' | ||
required: false | ||
type: string | ||
architecture: | ||
description: 'One of [ "x64", "arm64" ]' | ||
default: 'x64' | ||
required: false | ||
type: string | ||
package: | ||
required: true | ||
type: string | ||
# outputs: | ||
# package: | ||
# description: "The package's name" | ||
# value: ${{ jobs.build.outputs.package }} | ||
|
||
|
||
jobs: | ||
build: | ||
# runs-on: ${{ inputs.architecture }} | ||
runs-on: ubuntu-latest | ||
# Permissions to upload the package | ||
permissions: | ||
packages: write | ||
contents: read | ||
# outputs: | ||
# package: ${{ steps.get_name.outputs.name }} | ||
steps: | ||
- name: Read artifacts | ||
run: | | ||
ls -l ./artifacts/dist | ||
- name: Download artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: ${{ inputs.package }} | ||
path: ${{ inputs.architecture }}/${{ inputs.distribution }} | ||
|
||
# - name: Run `assemble.sh` | ||
# run: | | ||
# bash scripts/assemble.sh -v ${{ vars.OPENSEARCH_VERSION }} -p linux -a ${{ inputs.architecture }} -d ${{ inputs.distribution }} | ||
|
||
# # The package name is stored in the artifacts/artifact_name.txt file. | ||
# # The variable name is generated dynamically: rpm_x64 | ||
# - name: Set package name | ||
# id: get_name | ||
# run: | | ||
# echo $(ls -la) | ||
# # ${{ inputs.distribution }}_${{ inputs.architecture }} | ||
# echo "name=$(cat artifacts/artifact_name.txt)" >> $GITHUB_OUTPUT | ||
# echo "$(cat artifacts/artifact_name.txt)" | ||
|
||
# - name: Upload artifact | ||
# uses: actions/upload-artifact@v4 | ||
# with: | ||
# name: ${{ steps.get_name.outputs.name }} | ||
# path: ${{ inputs.architecture }}/${{ inputs.distribution }} | ||
# if-no-files-found: error | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
name: Build (reusable) | ||
|
||
# This workflow runs when any of the following occur: | ||
# - Run from another workflow | ||
on: | ||
workflow_call: | ||
inputs: | ||
distribution: | ||
description: 'One of [ "tar", "rpm", "deb" ]' | ||
default: 'rpm' | ||
required: false | ||
type: string | ||
architecture: | ||
description: 'One of [ "x64", "arm64" ]' | ||
default: 'x64' | ||
required: false | ||
type: string | ||
outputs: | ||
package: | ||
description: "The package's name" | ||
value: ${{ jobs.build.outputs.package }} | ||
|
||
# TODO version must to be read from the VERSION file | ||
# TODO revision must be an input | ||
env: | ||
version: 4.9.0 | ||
revision: 1 | ||
|
||
jobs: | ||
build: | ||
# runs-on: ${{ inputs.architecture }} | ||
runs-on: ubuntu-latest | ||
# Permissions to upload the package | ||
permissions: | ||
packages: write | ||
contents: read | ||
outputs: | ||
package: ${{ steps.get_name.outputs.name }} | ||
steps: | ||
- name: Run `build.sh` | ||
run: | | ||
bash scripts/build.sh -v ${{ vars.OPENSEARCH_VERSION }} -s false -p linux -a ${{ inputs.architecture }} -d ${{ inputs.distribution }} | ||
# The package name is stored in the artifacts/artifact_name.txt file. | ||
# The variable name is generated dynamically: rpm_x64 | ||
- name: Set package name | ||
id: get_name | ||
run: | | ||
echo $(ls -la) | ||
# ${{ inputs.distribution }}_${{ inputs.architecture }} | ||
echo "name=$(cat artifacts/artifact_name.txt)" >> $GITHUB_OUTPUT | ||
echo "$(cat artifacts/artifact_name.txt)" | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
# name: wazuh-indexer-min_${{ env.version }}-${{ env.revision }}_${{ inputs.architecture }}_${{ github.sha }}.${{ inputs.distribution }} | ||
# example: x64/deb/wazuh-indexer_4.8.0-rc1_x64_ff98475f.deb | ||
# TODO x64 -> deb: amd64, rpm: x86_64 | ||
name: ${{ steps.get_name.outputs.name }} | ||
path: ${{ inputs.architecture }}/${{ inputs.distribution }} | ||
if-no-files-found: error | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters