diff --git a/.github/workflows/release-cli.yml b/.github/workflows/release-cli.yml index 229c82c..7ee09a7 100644 --- a/.github/workflows/release-cli.yml +++ b/.github/workflows/release-cli.yml @@ -17,6 +17,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Install asdf & tools uses: asdf-vm/actions/install@v3 - name: Install deps diff --git a/cli/scripts/create-arch-npm-package.sh b/cli/scripts/create-arch-npm-package.sh index f089da0..fc22bfa 100755 --- a/cli/scripts/create-arch-npm-package.sh +++ b/cli/scripts/create-arch-npm-package.sh @@ -5,6 +5,20 @@ ARCH=$2 FULL_BINARY_PATH=$3 VERSION=$4 +# Function to check if an argument is missing +check_arg() { + if [[ -z "$1" ]]; then + echo "Error: Missing argument for $2." + exit 1 + fi +} + +# Check all arguments +check_arg "$OS" "operating system (OS)" +check_arg "$ARCH" "architecture (ARCH)" +check_arg "$FULL_BINARY_PATH" "full binary path (FULL_BINARY_PATH)" +check_arg "$VERSION" "version (VERSION)" + # Extract the binary name BINARY=$(basename "$FULL_BINARY_PATH") diff --git a/cli/scripts/create-main-npm-package.sh b/cli/scripts/create-main-npm-package.sh index 087ac72..a2d6451 100755 --- a/cli/scripts/create-main-npm-package.sh +++ b/cli/scripts/create-main-npm-package.sh @@ -7,11 +7,23 @@ TARGET_DIR="dist/npm/warpdive" # Get the current Git tag VERSION=$(git describe --tags --abbrev=0) +# Semver regex pattern to validate version format +SEMVER_REGEX="^[0-9]+\.[0-9]+\.[0-9]+$" + +# Check if the version is valid semver +if [[ $VERSION =~ $SEMVER_REGEX ]]; then + echo "Version $VERSION is valid semver." +else + echo "Error: Version $VERSION is not a valid semver." + exit 1 +fi + # Create necessary directories mkdir -p "${TARGET_DIR}/bin/" # Copy the JavaScript files cp "${SOURCE_DIR}/bin/cli" "${TARGET_DIR}/bin" +cp "${SOURCE_DIR}/index.js" "${TARGET_DIR}/" cp "${SOURCE_DIR}/install.js" "${TARGET_DIR}/" # Create package.json @@ -19,13 +31,14 @@ cat > "${TARGET_DIR}/package.json" <