Skip to content

Commit

Permalink
fix: Fix scripts for CI building
Browse files Browse the repository at this point in the history
  • Loading branch information
hangxingliu committed Feb 28, 2024
1 parent 20d8a9f commit f80a9e1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 18 deletions.
23 changes: 13 additions & 10 deletions scripts/build-npm-package.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
#!/usr/bin/env bash
# shellcheck disable=SC2015

#
# Update: 2024-02-29
#

throw() { echo -e "fatal: $1" >&2; exit 1; }
execute() { echo "$ $*"; "$@" || throw "Failed to execute '$1'"; }
command -v jq >/dev/null || throw "jq is not installed! (https://jqlang.github.io/jq/)";

# change the current directory to the project directory
pushd "$( dirname -- "${BASH_SOURCE[0]}" )/.." >/dev/null || exit 1;

execute mkdir -p "./artifacts/npm";

PKG_NAME="$(awk '/"name"/{ print substr($2,2, length($2)-3); }' ./package.json)"
PKG_VERSION="$(awk '/"version"/{ print substr($2,2, length($2)-3); }' ./package.json)"
PKG="${PKG_NAME}-${PKG_VERSION}";
PKG="$(jq -r '.name+"-"+.version' ./package.json)";
TARGET_DIR="./artifacts/npm";
LIST_FILE="./artifacts/npm/${PKG}.list";
echo "PKG=${PKG}";

npm pack --dryrun 2>&1 |
sed 's/npm notice//' |
tee "./artifacts/npm/${PKG}.list";
execute mkdir -p "$TARGET_DIR";

echo "created './artifacts/vscode/${PKG}.list'";
echo "$ npm pack --dryrun | tee $LIST_FILE";
npm pack --dryrun 2>&1 | sed 's/npm notice//' | tee "$LIST_FILE";

execute npm pack;
execute mv -f "${PKG}.tgz" "./artifacts/npm";
execute mv -f "${PKG}.tgz" "$TARGET_DIR";
23 changes: 15 additions & 8 deletions scripts/build-vscode-artifact.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
#!/usr/bin/env bash

#
# Update: 2024-02-29
#
throw() { echo -e "fatal: $1" >&2; exit 1; }
execute() { echo "$ $*"; "$@" || throw "Failed to execute '$1'"; }
command -v jq >/dev/null || throw "jq is not installed! (https://jqlang.github.io/jq/)";

# change the current directory to the project directory
pushd "$( dirname -- "${BASH_SOURCE[0]}" )/.." >/dev/null || exit 1;

mkdir -p "./artifacts/vscode";
PKG="$(jq -r '.name+"-"+.version' ./package.json)";
TARGET_DIR="./artifacts/vscode";
LIST_FILE="./artifacts/vscode/${PKG}.list";
echo "PKG=${PKG}";

PKG_NAME="$(awk '/"name"/{ print substr($2,2, length($2)-3); }' ./package.json)"
PKG_VERSION="$(awk '/"version"/{ print substr($2,2, length($2)-3); }' ./package.json)"
PKG="${PKG_NAME}-${PKG_VERSION}";
execute mkdir -p "$TARGET_DIR";

echo "$ ./scripts/vsce.sh ls | tee $LIST_FILE";
bash ./scripts/vsce.sh ls |
awk '!/Detected presence of yarn.lock/' |
tee "./artifacts/vscode/${PKG}.list";

echo "created './artifacts/vscode/${PKG}.list'";
tee "$LIST_FILE";

bash ./scripts/vsce.sh package --out "./artifacts/vscode/${PKG}.vsix"
execute bash ./scripts/vsce.sh package --out "${TARGET_DIR}/${PKG}.vsix";

0 comments on commit f80a9e1

Please sign in to comment.