diff --git a/.github/workflows/create_test_patches.yml b/.github/workflows/create_test_patches.yml index 5519aa44fe..415cd6f246 100644 --- a/.github/workflows/create_test_patches.yml +++ b/.github/workflows/create_test_patches.yml @@ -59,24 +59,15 @@ jobs: # yarn3+ by default disables lockfile alteration in CI. We want it. YARN_ENABLE_IMMUTABLE_INSTALLS: false run: | - PACKAGE_LIST=`find packages -maxdepth 1 -mindepth 1 -type d -exec basename {} \; | egrep -v 'template|invites'` - mkdir $HOME/packages - for PACKAGE in $PACKAGE_LIST; do - echo "Packing PR version of package $PACKAGE" - pushd packages/$PACKAGE; - yarn pack; - mv package.tgz $HOME/packages/react-native-firebase-${PACKAGE}.tgz; - ls -la $HOME/packages/*${PACKAGE}* - popd; - done - ls -la $HOME/packages/ + ./.github/workflows/scripts/create_npm_packages.sh ./packages $HOME/packages cd $HOME npx @react-native-community/cli init template --skip-install --skip-git-init cd template yarn yarn add patch-package --dev mkdir patches || true - for PACKAGE in $PACKAGE_LIST; do + PACKED_PACKAGE_LIST=`find $HOME/packages/ -maxdepth 1 -mindepth 1 -type f -exec basename -s .tgz {} \; | cut -d'-' -f4-10 | sort` + for PACKAGE in $PACKED_PACKAGE_LIST; do echo "Installing package $PACKAGE into fresh template app, then clobbering with PR version" yarn add @react-native-firebase/$PACKAGE || true if [ -d node_modules/@react-native-firebase/$PACKAGE ]; then diff --git a/.github/workflows/scripts/create_npm_packages.sh b/.github/workflows/scripts/create_npm_packages.sh new file mode 100755 index 0000000000..a210c0b0ad --- /dev/null +++ b/.github/workflows/scripts/create_npm_packages.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +SOURCE_PACKAGE_DIR="$1" +TARGET_PACKAGE_DIR="$2" + +echo "Creating local npm packages from source '${SOURCE_PACKAGE_DIR}' in '${TARGET_PACKAGE_DIR}'..." + +# Make sure our target directory exists and is clean from previous runs +if ! [ -d "${TARGET_PACKAGE_DIR}" ]; then + mkdir "${TARGET_PACKAGE_DIR}" +else + rm -f "${TARGET_PACKAGE_DIR}"/*.tgz +fi + +if ! [ -d "${SOURCE_PACKAGE_DIR}" ]; then + echo "Source package dir '${SOURCE_PACKAGE_DIR} not found." + exit 1; +fi + +# Get our full list of packages, except any we specifically ignore +IGNORED_PACKAGE_NAMES='template|invites' +PACKAGE_LIST=`find ${SOURCE_PACKAGE_DIR} -maxdepth 1 -mindepth 1 -type d -exec basename {} \; | egrep -v "${IGNORED_PACKAGE_NAMES}"` + +# Pack up each package +for PACKAGE in $PACKAGE_LIST; do + echo "Creating package for $PACKAGE from local source" + pushd "${SOURCE_PACKAGE_DIR}/${PACKAGE}"; + yarn pack; + mv package.tgz "${TARGET_PACKAGE_DIR}/react-native-firebase-${PACKAGE}.tgz"; + ls -la "${TARGET_PACKAGE_DIR}/react-native-firebase-${PACKAGE}.tgz" + popd; +done +ls -la "${TARGET_PACKAGE_DIR}" \ No newline at end of file