Skip to content

Commit

Permalink
Build scripts and GH workflows artifacts naming fix
Browse files Browse the repository at this point in the history
  • Loading branch information
f-galland committed Jan 9, 2024
1 parent 45a597b commit d7d65f4
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 17 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ jobs:
with:
architecture: ${{ matrix.architecture }}
distribution: ${{ matrix.distribution }}
name: wazuh-indexer-min_${{ needs.version.outputs.version }}-${{ inputs.revision }}-${{ matrix.architecture }}_${{ github.sha }}.${{ matrix.distribution }}
# wazuh-indexer-min_4.8.0-rc1_x64_ff98475f.deb
# TODO arm64 != amd64 (deb), x64 != x86_64 (rpm)
# TODO use short SHA https://stackoverflow.com/a/59819441/13918537
Expand All @@ -56,5 +55,3 @@ jobs:
with:
architecture: ${{ matrix.architecture }}
distribution: ${{ matrix.distribution }}
min: wazuh-indexer-min_${{ needs.version.outputs.version }}-${{ inputs.revision }}-${{ matrix.architecture }}_${{ github.sha }}.${{ matrix.distribution }}
name: wazuh-indexer_${{ needs.version.outputs.version }}-${{ inputs.revision }}-${{ matrix.architecture }}_${{ github.sha }}.${{ matrix.distribution }}
11 changes: 9 additions & 2 deletions .github/workflows/r_assemble.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,17 @@ jobs:
contents: read
steps:
- uses: actions/checkout@v4
# The -min package's name is stored in artifacts/artifact_min_name.txt.

- name: Set min package name
id: get_min_name
run: |
echo "name=$(cat artifacts/artifact_min_name.txt)" >> $GITHUB_OUTPUT
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: ${{ inputs.min }}
name: ${{ steps.get_min_name.outputs.name }}
path: artifacts/dist

- name: Provision
Expand All @@ -57,6 +64,6 @@ jobs:
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.name }}
name: ${{ steps.get_name.outputs.name }}
path: artifacts/dist/${{ steps.get_name.outputs.name }}
if-no-files-found: error
6 changes: 3 additions & 3 deletions .github/workflows/r_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ jobs:
run: |
bash scripts/build.sh -v ${{ vars.OPENSEARCH_VERSION }} -s false -p linux -a ${{ inputs.architecture }} -d ${{ inputs.distribution }}
# The package's name is stored in artifacts/artifact_name.txt.
# The package's name is stored in artifacts/artifact_min_name.txt.
- name: Set package name
id: get_name
run: |
echo "name=$(cat artifacts/artifact_name.txt)" >> $GITHUB_OUTPUT
echo "name=$(cat artifacts/artifact_min_name.txt)" >> $GITHUB_OUTPUT
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.name }}
name: ${{ steps.get_name.outputs.name }}
path: artifacts/dist/${{ steps.get_name.outputs.name }}
if-no-files-found: error
20 changes: 13 additions & 7 deletions scripts/assemble.sh
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ function clean() {
rm -r "${OUTPUT}/tmp"
echo "After execution, shell path is $(pwd)"
# Store package's name to file. Used by GH Action.
echo "${package_name}" >"${OUTPUT}/artifact_name.txt"
echo "${ARTIFACT_PACKAGE_NAME}" >"${OUTPUT}/artifact_name.txt"
}

# ====
Expand All @@ -228,7 +228,7 @@ function assemble_tar() {
cd ..
tar -cvf "${archive_name}-${SUFFIX}.${EXT}" "${archive_name}"
cd ../../..
cp "${TMP_DIR}/${archive_name}-${SUFFIX}.${EXT}" "${OUTPUT}/dist/"
cp "${TMP_DIR}/${archive_name}-${SUFFIX}.${EXT}" "${OUTPUT}/dist/$ARTIFACT_PACKAGE_NAME"

clean
}
Expand Down Expand Up @@ -272,8 +272,10 @@ function assemble_rpm() {

# Move to the root folder, copy the package and clean.
cd ../../..

package_name="wazuh-indexer-${version}-1.${SUFFIX}.${EXT}"
cp "${TMP_DIR}/RPMS/${SUFFIX}/${package_name}" "${OUTPUT}/dist/"

cp "${TMP_DIR}/RPMS/${SUFFIX}/${package_name}" "${OUTPUT}/dist/$ARTIFACT_PACKAGE_NAME"

clean
}
Expand Down Expand Up @@ -319,9 +321,9 @@ function assemble_deb() {

# Move to the root folder, copy the package and clean.
cd ../../..
package_name="wazuh-indexer_${version}_${SUFFIX}.${EXT}"
package_name="wazuh-indexer_${version}_${SUFFIX}.${EXT}"
# debmake creates the package one level above
cp "${TMP_DIR}/../${package_name}" "${OUTPUT}/dist/"
cp "${TMP_DIR}/../${package_name}" "${OUTPUT}/dist/$ARTIFACT_PACKAGE_NAME"

clean
}
Expand All @@ -333,8 +335,12 @@ function main() {
parse_args "${@}"

echo "Assembling wazuh-indexer for $PLATFORM-$DISTRIBUTION-$ARCHITECTURE"
# wazuh-indexer-min_4.9.0-1-x64_78fcc3db6a5b470294319e48b58c3d715bee39d1.rpm
ARTIFACT_BUILD_NAME=$(ls "${OUTPUT}/dist/" | grep "wazuh-indexer-min.*.$EXT")

ARTIFACT_BUILD_NAME=$(ls "${OUTPUT}/dist/" | grep "wazuh-indexer-min_.*\.$EXT")

ARTIFACT_PACKAGE_NAME=${ARTIFACT_BUILD_NAME/min_/}



# Create temporal directory and copy the min package there for extraction
TMP_DIR="${OUTPUT}/tmp/${TARGET}"
Expand Down
15 changes: 13 additions & 2 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,19 @@ echo "Building OpenSearch for $PLATFORM-$DISTRIBUTION-$ARCHITECTURE"
# Copy artifact to dist folder in bundle build output
echo "Copying artifact to ${OUTPUT}/dist"
# [[ "$SNAPSHOT" == "true" ]] && IDENTIFIER="-SNAPSHOT"


ARTIFACT_BUILD_NAME=$(ls "distribution/$TYPE/$TARGET/build/distributions/" | grep "wazuh-indexer-min.*$SUFFIX.$EXT")

GIT_COMMIT=$(git rev-parse --short HEAD)

WI_VERSION=$(<VERSION)

ARTIFACT_PACKAGE_NAME=wazuh-indexer-min_"$WI_VERSION"-"$QUALIFIER"_"$SUFFIX"_"$GIT_COMMIT"."$EXT"

# [WAZUH] Used by the GH workflow to upload the artifact
echo "$ARTIFACT_BUILD_NAME" > "$OUTPUT/artifact_name.txt"

echo "$ARTIFACT_PACKAGE_NAME" > "$OUTPUT/artifact_min_name.txt"

mkdir -p "${OUTPUT}/dist"
cp "distribution/$TYPE/$TARGET/build/distributions/$ARTIFACT_BUILD_NAME" "${OUTPUT}/dist/$ARTIFACT_BUILD_NAME"
cp "distribution/$TYPE/$TARGET/build/distributions/$ARTIFACT_BUILD_NAME" "${OUTPUT}/dist/$ARTIFACT_PACKAGE_NAME"

0 comments on commit d7d65f4

Please sign in to comment.