Skip to content

Commit

Permalink
refactor: add function to retrieve distributable artefacts from works…
Browse files Browse the repository at this point in the history
…pace packages
  • Loading branch information
lgersman committed Nov 26, 2024
1 parent 2640470 commit 0cdbbd9
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
name: gather builded directories
with:
runCmd: |
find ./packages -mindepth 3 -maxdepth 3 -type d -name "dist" -exec ls -la {} \;
pnpm exec /bin/bash -c '. ./scripts/includes/bootstrap.sh; ionos.wordpress.get_distributable_artefacts'
- name: print build directories
run: |
Expand Down
43 changes: 43 additions & 0 deletions scripts/includes/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,49 @@ function ionos.wordpress.author_email() {
}
export -f ionos.wordpress.author_email

#
# outputs the distributable artefacts of all workspace packages
# the workspace needs to be built to get correct results
#
# distributable artefacts are workspace package flavor specific
# and can be a .zip or .tgz files usually located in the dist folder of the package
#
function ionos.wordpress.get_distributable_artefacts() {
local PACKAGE_PATH PACKAGE_NAME FLAVOUR ARTEFACTS=()

for PACKAGE_PATH in $(find ./packages -mindepth 2 -maxdepth 2 -type d | sort); do
PACKAGE_NAME=$(jq -r '.name // false' $PACKAGE_PATH/package.json)

if [[ "$(jq -r '.private // false' $PACKAGE_PATH/package.json)" == "true" ]]; then
ionos.wordpress.log_warn "skipping package $PACKAGE_NAME - it is marked as private"
continue
fi

FLAVOUR=$(basename $(dirname $PACKAGE_PATH))
case "$FLAVOUR" in
docker)
ionos.wordpress.log_warn "skipping $FLAVOUR package $PACKAGE_NAME - docker packages are not distributable"
;;
npm)
ARTEFACTS+=("$(find $PACKAGE_PATH/dist -type f -name '*.tgz')")
;;
wp-plugin)
ARTEFACTS+=("$(find $PACKAGE_PATH/dist -type f -name '*.zip')")
;;
wp-theme)
ARTEFACTS+=("$(find $PACKAGE_PATH/dist -type f -name '*.zip')")
;;
*)
ionos.wordpress.log_error "don't know how to handle workspace package flavor '$FLAVOUR' (extracted from path=$PACKAGE_PATH)"
exit 1
;;
esac
done

echo "${ARTEFACTS[@]}"
}
export -f ionos.wordpress.get_distributable_artefacts

export GIT_ROOT_PATH=$(git rev-parse --show-toplevel)

# docker flags to use if docker containers will be invoked
Expand Down

0 comments on commit 0cdbbd9

Please sign in to comment.