Skip to content

Commit

Permalink
build: test stable zip.
Browse files Browse the repository at this point in the history
  • Loading branch information
richardo2016x committed Oct 17, 2024
1 parent 93f212e commit 9423663
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 25 deletions.
22 changes: 10 additions & 12 deletions scripts/autobuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ set -e
script_dir="$( cd "$( dirname "$0" )" && pwd )"
project_dir=$(dirname "$script_dir")

. $script_dir/fns.sh --source-only

export VERSION=$(node --eval="process.stdout.write(require('./package.json').version)");
export RABBY_GIT_HASH=$(git rev-parse --short HEAD);
export CURRENT_TIME=$(date +%Y%m%d%H%M%S);
Expand All @@ -19,18 +21,11 @@ if [ -z $NO_BUILD ]; then
fi
echo "[pack] built finished";

DIST_DIR=$project_dir/dist;

rm -rf $project_dir/tmp/ && mkdir -p $project_dir/tmp/;
if [ -d $DIST_DIR ]; then
cd $DIST_DIR;
zip -r $TARGET_FILE ./*
else
echo "[pack] dist dir not found: $DIST_DIR";
fi
cd $project_dir;
rm -f $TARGET_FILE;
pack_dist_to_zip $TARGET_FILE;

cd $project_dir;
# cp $TARGET_FILE $project_dir/tmp/RabbyDebug-latest.zip

# upload to storage
if [ -z $NO_UPLOAD ]; then
Expand All @@ -42,12 +37,15 @@ if [ -z $NO_UPLOAD ]; then
QUIET_PARASM=""
fi
echo "[pack] start upload...";
aws s3 cp $QUIET_PARASM $project_dir/tmp/ s3://$RABBY_BUILD_BUCKET/rabby/autobuild/RabbyDebug-$CURRENT_TIME --recursive --exclude="*" --include "*.zip" --acl public-read
# aws s3 cp $QUIET_PARASM $project_dir/tmp/ s3://$RABBY_BUILD_BUCKET/rabby/autobuild/RabbyDebug-$CURRENT_TIME --recursive --exclude="*" --include "*.zip" --acl public-read
echo "[pack] uploaded. DOWNLOAD_URL is $DOWNLOAD_URL";

if [ ! -z $notify_lark ]; then
echo "[pack] update latest link...";
node ./scripts/notify-lark.js "$DOWNLOAD_URL"
md5_value=$(md5 -q $TARGET_FILE);

echo "[pack] (md5: $TARGET_FILE) $md5_value";
node ./scripts/notify-lark.js "$DOWNLOAD_URL" "$md5_value"
else
echo "[pack] skip notify.";
fi
Expand Down
40 changes: 40 additions & 0 deletions scripts/fns.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
script_dir="$( cd "$( dirname "$0" )" && pwd )"
project_dir=$(dirname "$script_dir")
systype=$(uname -s)

pack_dist_to_zip() {
local entry_dir=$project_dir;
local files=$(find "$entry_dir/dist" -type f | sort)
local dest_zip=$1

if [ -z $dest_zip ]; then
echo "dest_zip is required"
exit 1
fi

if [ -z $build_type ]; then
build_type="debug"
fi

git_committish=$(git log --format="%h" -n 1)
# e.g. '2024-01-01 01:01:01 +0000'
git_tz_time_linux=$(git log --format="%cd" -n 1 --date=format:'%Y-%m-%d %H:%M:%S %z')
# SetFile format, e.g. '01/01/2024 01:01:01 +0000'
git_tz_time_setfile=$(git log --format="%cd" -n 1 --date=format:'%m/%d/%Y %H:%M:%S %z')

for file in $files; do
if [ "$systype" = "Darwin" ]; then
SetFile -d "$git_tz_time_setfile" "$file"
SetFile -m "$git_tz_time_setfile" "$file"
elif [ "$systype" = "Linux" ]; then
touch -a -d "$git_tz_time_linux" "$file"
touch -m -d "$git_tz_time_linux" "$file"
fi

local relname=${file#$entry_dir/}
zip -X "$dest_zip" "$relname"
done

echo "git_tz_time_setfile is $git_tz_time_setfile"
echo "git_tz_time_linux is $git_tz_time_linux"
}
9 changes: 7 additions & 2 deletions scripts/notify-lark.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ if (!secret) {
// sendMessage with axios
async function sendMessage({
downloadURL = '',
md5Value = '',
actionsJobUrl = '',
gitCommitURL = '',
gitRefURL = '',
Expand Down Expand Up @@ -65,6 +66,9 @@ async function sendMessage({
{ "tag": "text", "text": `Download URL: ` },
{ "tag": "a", "href": downloadURL, "text": downloadURL }
],
[
{ "tag": "text", "text": `MD5: ${md5Value}` },
],
[
{ "tag": "text", "text": `---------` },
],
Expand Down Expand Up @@ -99,8 +103,9 @@ const args = process.argv.slice(2);
if (args[0]) {
sendMessage({
downloadURL: args[0],
actionsJobUrl: args[1] || process.env.ACTIONS_JOB_URL,
gitCommitURL: args[2] || process.env.GIT_COMMIT_URL,
md5Value: args[1],
actionsJobUrl: args[2] || process.env.ACTIONS_JOB_URL,
gitCommitURL: args[3] || process.env.GIT_COMMIT_URL,
gitRefURL: process.env.GIT_REF_URL,
triggers: [
process.env.GITHUB_TRIGGERING_ACTOR,
Expand Down
55 changes: 44 additions & 11 deletions scripts/pack-debug.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,51 @@
script_dir="$( cd "$( dirname "$0" )" && pwd )"
project_dir=$(dirname "$script_dir")
systype=$(uname -s)
if [ -z $build_type ]; then
build_type="debug"
fi

cd $project_dir;
app_ver=$(node -p "require('./package.json').version")
git_committish=$(git log --format="%h" -n 1)
# e.g. '2024-01-01 01:01:01 +0000'
git_tz_time_linux=$(git log --format="%cd" -n 1 --date=format:'%Y-%m-%d %H:%M:%S %z')
# SetFile format, e.g. '01/01/2024 01:01:01 +0000'
git_tz_time_setfile=$(git log --format="%cd" -n 1 --date=format:'%m/%d/%Y %H:%M:%S %z')

pack_dist() {
rm -rf ./tmp/ && mkdir -p ./tmp/ && \
zip -r ./tmp/Rabby_v${app_ver}_debug.${git_committish}.zip ./dist
rm -rf $project_dir/tmp/*.zip && mkdir -p $project_dir/tmp/;

local entry_dir=$project_dir;

if [ ! -d "$entry_dir/dist" ]; then
echo "dist not exists"
exit 1
fi

local files=$(find "$entry_dir/dist" -type f | sort)
local dest_zip="$project_dir/tmp/Rabby_v${app_ver}_${build_type}.${git_committish}.zip"
for file in $files; do
if [ "$systype" = "Darwin" ]; then
SetFile -d "$git_tz_time_setfile" "$file"
SetFile -m "$git_tz_time_setfile" "$file"
elif [ "$systype" = "Linux" ]; then
touch -c -d "$git_tz_time_linux" "$file"
touch -c -m "$git_tz_time_linux" "$file"
fi

local relname=${file#$entry_dir/}
zip -X "$dest_zip" "$relname"
done

echo "git_tz_time_setfile is $git_tz_time_setfile"
echo "git_tz_time_linux is $git_tz_time_linux"
cd $project_dir;

}

build() {
yarn build:debug;
yarn build:${build_type};
}

if [ "$1" = "--pack-only" ]; then
Expand All @@ -23,11 +56,11 @@ else
build && pack_dist;
fi

case $systype in
"Darwin")
open ./tmp/
;;
MSYS_NT*|MINGW*)
start "" .\\tmp
;;
esac
# case $systype in
# "Darwin")
# open ./tmp/
# ;;
# MSYS_NT*|MINGW*)
# start "" .\\tmp
# ;;
# esac

0 comments on commit 9423663

Please sign in to comment.