From 55166cdc3740feb2469372637dd21a43b8c73552 Mon Sep 17 00:00:00 2001 From: Liang Hai Date: Wed, 4 Dec 2024 23:42:10 +0100 Subject: [PATCH] Beta mode; organize code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use modern syntax $(…) in place of `…`. Quote $MODE in comparison to avoid the confusing “unary operator expected” error when value is empty in testing. Copy directories directly (rather copy content of a directory to a ready-made directory) whenever possible, for simpler code. --- .github/workflows/publish-ucd.sh | 48 +++++++++------- .github/workflows/publish-ucd.yml | 2 + pub/copy-beta-to-draft.sh | 93 ------------------------------- 3 files changed, 31 insertions(+), 112 deletions(-) delete mode 100755 pub/copy-beta-to-draft.sh diff --git a/.github/workflows/publish-ucd.sh b/.github/workflows/publish-ucd.sh index 62053061c..48b48cd0f 100755 --- a/.github/workflows/publish-ucd.sh +++ b/.github/workflows/publish-ucd.sh @@ -1,46 +1,56 @@ # See publish-ucd.yml -TODAY=`date --iso-8601` - mkdir dist +PUB_DATE=$(date --iso-8601) + cat > dist/sed-readmes.txt << eof s/COPY_YEAR/$COPY_YEAR/ -s/PUB_DATE/$TODAY/ +s/PUB_DATE/$PUB_DATE/ s/PUB_STATUS/draft/ s/UNI_VER/$UNI_VER/ s/EMOJI_VER/$EMOJI_VER/ +s/TR10_REV/$TR10_REV/ s%PUBLIC_EMOJI%Public/draft/emoji% s%PUBLIC_UCD%Public/draft/UCD% eof -mkdir -p dist/UCD/ucd -mkdir dist/zipped -cp -r unicodetools/data/ucd/dev/* dist/UCD/ucd -rm -r dist/UCD/ucd/Unihan +mkdir dist/UCD +cp -R unicodetools/data/ucd/dev dist/UCD/ucd mv dist/UCD/ucd/version-ReadMe.txt dist/UCD/ReadMe.txt -mv dist/UCD/ucd/zipped-ReadMe.txt dist/zipped/ReadMe.txt +rm -r dist/UCD/ucd/Unihan +if [ "$MODE" = "Snapshot" ]; then + rm -r dist/UCD/ucd/emoji +fi -if [ $MODE = "Alpha" ]; then - mkdir dist/emoji - cp unicodetools/data/emoji/dev/* dist/emoji +if [ "$MODE" = "Alpha" ] || [ "$MODE" = "Beta" ]; then + cp -R unicodetools/data/emoji/dev dist/emoji - mkdir dist/idna - cp unicodetools/data/idna/dev/* dist/idna + cp -R unicodetools/data/idna/dev dist/idna mkdir dist/idna2008derived - cp unicodetools/data/idna/idna2008derived/Idna2008-$UNI_VER.txt dist/idna2008derived cp unicodetools/data/idna/idna2008derived/ReadMe.txt dist/idna2008derived -else - rm -r dist/UCD/ucd/emoji + cp unicodetools/data/idna/idna2008derived/Idna2008-$UNI_VER.txt dist/idna2008derived + + if [ "$MODE" = "Beta" ]; then + cp -R unicodetools/data/uca/dev dist/UCA + sed -i -f dist/sed-readmes.txt dist/UCA/CollationTest.html + + cp -R unicodetools/data/security/dev dist/security + fi fi # Update the readmes in-place (-i) as set up above. find dist -name '*ReadMe.txt' | xargs sed -i -f dist/sed-readmes.txt +rm dist/sed-readmes.txt -# Zip files for some types of data, after fixing permissions +mkdir dist/zipped +mv dist/UCD/ucd/zipped-ReadMe.txt dist/zipped/ReadMe.txt (cd dist/UCD/ucd; zip -r UCD.zip *) mv dist/UCD/ucd/UCD.zip dist/zipped -# Cleanup -rm dist/sed-readmes.txt +if [ "$MODE" = "Beta" ]; then + (cd dist/UCA; zip -r CollationTest.zip CollationTest; rm -r CollationTest) + + (cd dist/security; zip -r uts39-data-$UNI_VER.zip *) +fi diff --git a/.github/workflows/publish-ucd.yml b/.github/workflows/publish-ucd.yml index 1588a1f6c..e576f6df9 100644 --- a/.github/workflows/publish-ucd.yml +++ b/.github/workflows/publish-ucd.yml @@ -16,12 +16,14 @@ on: options: - Snapshot - Alpha + - Beta default: Snapshot env: COPY_YEAR: "2024" UNI_VER: "17.0.0" EMOJI_VER: "17.0" + TR10_REV: "tr10-52" # UTS #10 release revision number to be used in CollationTest.html: One more than the last release revision number. MODE: ${{ inputs.mode }} jobs: diff --git a/pub/copy-beta-to-draft.sh b/pub/copy-beta-to-draft.sh deleted file mode 100755 index 84c30ae08..000000000 --- a/pub/copy-beta-to-draft.sh +++ /dev/null @@ -1,93 +0,0 @@ -# Script for -# https://github.com/unicode-org/unicodetools/blob/main/docs/data-workflow.md#publish-a-beta-snapshot -# -# Invoke like this: -# -# pub/copy-beta-to-draft.sh ~/unitools/mine/src /tmp/unicode/Public/draft - -UNICODETOOLS=$1 -DRAFT=$2 - -UNITOOLS_DATA=$UNICODETOOLS/unicodetools/data - -# Adjust the following for each year and version as needed. -COPY_YEAR=2024 -UNI_VER=17.0.0 -EMOJI_VER=17.0 -# UTS #10 release revision number to be used in CollationTest.html: -# One more than the last release revision number. -TR10_REV=tr10-52 - -TODAY=`date --iso-8601` - -mkdir -p $DRAFT - -cat > $DRAFT/sed-readmes.txt << eof -s/COPY_YEAR/$COPY_YEAR/ -s/PUB_DATE/$TODAY/ -s/PUB_STATUS/draft/ -s/UNI_VER/$UNI_VER/ -s/EMOJI_VER/$EMOJI_VER/ -s/TR10_REV/$TR10_REV/ -s%PUBLIC_EMOJI%Public/draft/emoji% -s%PUBLIC_UCD%Public/draft/UCD% -eof - -mkdir -p $DRAFT/UCD/ucd -mkdir -p $DRAFT/zipped -cp -r $UNITOOLS_DATA/ucd/dev/* $DRAFT/UCD/ucd -rm -r $DRAFT/UCD/ucd/Unihan -mv $DRAFT/UCD/ucd/version-ReadMe.txt $DRAFT/UCD/ReadMe.txt -mv $DRAFT/UCD/ucd/zipped-ReadMe.txt $DRAFT/zipped/ReadMe.txt - -mkdir -p $DRAFT/UCA -cp -r $UNITOOLS_DATA/uca/dev/* $DRAFT/UCA -sed -i -f $DRAFT/sed-readmes.txt $DRAFT/UCA/CollationTest.html - -mkdir -p $DRAFT/emoji -cp $UNITOOLS_DATA/emoji/dev/* $DRAFT/emoji - -mkdir -p $DRAFT/idna -cp $UNITOOLS_DATA/idna/dev/* $DRAFT/idna - -mkdir -p $DRAFT/idna2008derived -rm $DRAFT/idna2008derived/* -cp $UNITOOLS_DATA/idna/idna2008derived/Idna2008-$UNI_VER.txt $DRAFT/idna2008derived -cp $UNITOOLS_DATA/idna/idna2008derived/ReadMe.txt $DRAFT/idna2008derived - -mkdir -p $DRAFT/security -cp $UNITOOLS_DATA/security/dev/* $DRAFT/security - -# Fix permissions. Everyone can read, and search directories. -chmod a+rX -R $DRAFT - -# Update the readmes in-place (-i) as set up above. -find $DRAFT -name '*ReadMe.txt' | xargs sed -i -f $DRAFT/sed-readmes.txt - -# Zip files for some types of data, after fixing permissions -rm $DRAFT/UCD/ucd/UCD.zip -(cd $DRAFT/UCD/ucd; zip -r UCD.zip * && mv UCD.zip $DRAFT/zipped) - -rm $DRAFT/UCA/CollationTest.zip -(cd $DRAFT/UCA; zip -r CollationTest.zip CollationTest && rm -r CollationTest) - -rm $DRAFT/security/*.zip -(cd $DRAFT/security; zip -r uts39-data-$UNI_VER.zip *) - -# Fix permissions again to catch the zip files -chmod a+rX -R $DRAFT - -# Cleanup -rm $DRAFT/sed-readmes.txt - -# Zip file to deliver the whole set of data files -rm $DRAFT/beta.zip -(cd $DRAFT; zip -r beta.zip *) - -echo "--------------------" -echo "Copy files from elsewhere:" -echo "- Unihan.zip to $DRAFT/UCD/ucd" -echo "- Unihan.zip to $DRAFT/zipped" -echo "- UCDXML files to $DRAFT/UCD/ucdxml" -echo "- beta charts to $DRAFT/UCD/charts" -