-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c851596
commit d4477d1
Showing
1 changed file
with
42 additions
and
72 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 |
---|---|---|
|
@@ -29,91 +29,61 @@ jobs: | |
BC=Configuration.h | ||
AC=Configuration_adv.h | ||
shopt -s globstar | ||
git config user.email "[email protected]" | ||
git config user.name "Scott Lahteine" | ||
echo "- Initializing BASE branch..." | ||
# Copy to a temporary location | ||
# Copy 'config' to a temporary location | ||
TEMP=$( mktemp -d ) ; cp -R config $TEMP | ||
# Strip all #error lines | ||
IFS=$'\n'; set -f | ||
for fn in $( find $TEMP/config -type f -name "Configuration.h" ); do | ||
sed -i~ -e "20,30{/#error/d}" "$fn" | ||
rm "$fn~" | ||
done | ||
unset IFS; set +f | ||
IFS=$'\n' | ||
for fn in "$TEMP"/config/**/Configuration.h; do sed -e '20,30{/#error/d;}' "$fn" > "$fn~" && mv "$fn~" "$fn" ; done | ||
unset IFS | ||
# Create 'BASE' as a copy of 'init-repo' (README, LICENSE, etc.) | ||
# Create 'EXPORT' as a copy of 'init-repo' (README, LICENSE, etc.) | ||
echo "- Init $EXPORT branch..." | ||
git fetch origin init-repo >/dev/null | ||
git checkout origin/init-repo -b BASE >/dev/null || exit | ||
git checkout origin/init-repo -b $EXPORT >/dev/null || exit | ||
# Copy all config files into place | ||
echo "- Copying configs from fresh $IMPORT..." | ||
# Copy all config files and extras into place | ||
echo "- Clone fresh $IMPORT..." | ||
cp -R "$TEMP/config" . >/dev/null | ||
echo "- Deleting extras" | ||
# Delete anything that's not a Configuration file | ||
find config -type f \! -name "Conf*.h" -exec rm "{}" \; | ||
# Update the %VERSION% in the README.md file | ||
echo "- Set VERSION in README.md..." | ||
VERS=${EXPORT#release-} | ||
sed -E "s/%VERSION%/$VERS/g" README.md > README.md~ && mv README.md~ README.md | ||
# Reset configurations to default | ||
echo "- Reset configs to default..." | ||
IFS=$'\n' | ||
for fn in "$CEXA"/**/Configuration*.h ; do cp "$CDEF"/$(basename $fn) "$fn" ; done | ||
unset IFS | ||
# Commit the 'EXPORT', ready for customizations | ||
echo "- Amend root commit with only defaults..." | ||
{ git add config/**/Configuration*.h README.md && git commit --amend --no-edit ; } >/dev/null | ||
# Get configured Configuration.h & Configuration_adv.h | ||
echo "- Apply example config customizations..." | ||
find "$TEMP"/config -name 'Configuration*.h' | cpio -pdmv ./config >/dev/null 2>&1 | ||
echo "- Apply path labels..." | ||
for fn in "$CEXA"/**/Conf*.h; do | ||
fldr=$(dirname "$fn") ; fldr=${fldr#*config/} ; fldr=${fldr#examples/} | ||
blank_line=$(awk '/^\s*$/ {print NR; exit}' "$fn") | ||
sed -e "${blank_line}i\\ | ||
\\ | ||
#define CONFIG_EXAMPLES_DIR \"$fldr\"" "$fn" > "$fn~" && mv "$fn~" "$fn" | ||
done | ||
# Init Cartesian/SCARA/TPARA configurations to default | ||
echo "- Initializing configs to default state..." | ||
{ git add config/**/Configuration*.h && git commit -m "Examples Customizations" ; } >/dev/null | ||
find "$CEXA" -name $BC -print0 \ | ||
| while read -d $'\0' F ; do cp "$CDEF/$BC" "$F" >/dev/null ; done | ||
find "$CEXA" -name $AC -print0 \ | ||
| while read -d $'\0' F ; do cp "$CDEF/$AC" "$F" >/dev/null ; done | ||
{ git add . && git commit -m "Examples Extras" ; } >/dev/null | ||
# Update the %VERSION% in the README.md file | ||
VERS=$( echo $EXPORT | sed 's/release-//' ) | ||
eval "sed -E -i~ -e 's/%VERSION%/$VERS/g' README.md" | ||
rm -f README.md~ | ||
# Commit the 'BASE', ready for customizations | ||
git add . >/dev/null && git commit --amend --no-edit >/dev/null | ||
# Create a new branch from 'BASE' for the final result | ||
echo "- Creating 'built-temp' branch..." | ||
git checkout -b built-temp >/dev/null || exit | ||
# Delete temporary branch | ||
git branch -D BASE 2>/dev/null | ||
echo "- Applying customizations..." | ||
cp -R "$TEMP/config" . | ||
find config -type f \! -name "Configuration*" -exec rm "{}" \; | ||
addpathlabels() { | ||
cd $CEXA | ||
find . -name "Conf*.h" -print0 | while read -d $'\0' fn ; do | ||
fldr=$(dirname "$fn" | sed "s/^\.\///") | ||
blank_line=$(awk '/^\s*$/ {print NR; exit}' "$fn") | ||
sed -i~ "${blank_line}i\\\n#define CONFIG_EXAMPLES_DIR \"$fldr\"" "$fn" | ||
rm -f "$fn~" | ||
done | ||
cd - | ||
} | ||
echo "- Applying path labels..." | ||
addpathlabels >/dev/null 2>&1 | ||
git add . >/dev/null && git commit -m "Examples Customizations" >/dev/null | ||
echo "- Adding all the extras..." | ||
cp -R "$TEMP/config" . | ||
echo "- Applying path labels..." | ||
addpathlabels >/dev/null 2>&1 | ||
git add . >/dev/null && git commit -m "Examples Extras" >/dev/null | ||
echo "- Replace $EXPORT branch" | ||
git fetch origin $EXPORT >/dev/null | ||
git checkout >/dev/null $EXPORT | ||
git reset --hard built-temp | ||
git push -f | ||
git branch -D built-temp | ||
echo "- Push to origin/$EXPORT" | ||
git push -f origin HEAD:$EXPORT >/dev/null | ||
rm -rf $TEMP |