Skip to content

Crawlee—A web scraping and browser automation library for Node.js to build reliable crawlers. In JavaScript and TypeScript. Extract data for AI, LLMs, RAG, or GPTs. Download HTML, PDF, JPG, PNG, and other files from websites. Works with Puppeteer, Playwright, Cheerio, JSDOM, and raw HTTP. Both headful and headless mode. With proxy rotation.

Updating ./publish.sh

Marek Trunkatcfe4d0d4a9a5
diff --git a/package.json b/package.json
index 472e01a35..a2923daa3 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "apify",
- "version": "0.4.6",
+ "version": "0.4.7",
"description": "Apify runtime for JavaScript",
"main": "build/index.js",
"keywords": [
diff --git a/publish.sh b/publish.sh
index 3b0d6589a..5a604a0da 100755
--- a/publish.sh
+++ b/publish.sh
@@ -5,31 +5,44 @@ set -e
RED='\033[0;31m'
NC='\033[0m' # No Color
+PACKAGE_NAME=`node -pe "require('./package.json').name"`
PACKAGE_VERSION=`node -pe "require('./package.json').version"`
BRANCH=`git status | grep 'On branch' | cut -d ' ' -f 3`
BRANCH_UP_TO_DATE=`git status | grep 'nothing to commit' | tr -s \n ' '`;
+GIT_TAG="v${PACKAGE_VERSION}"
if [ -z "$BRANCH_UP_TO_DATE" ]; then
printf "${RED}You have uncommited changes!${NC}\n"
exit 1
fi
-if [ $BRANCH = "master" ]; then
- NPM_TAG='latest'
- GIT_TAG="v${PACKAGE_VERSION}"
-else
- NPM_TAG='beta'
- GIT_TAG="v${PACKAGE_VERSION}-beta"
-fi
-
echo "Pushing to git ..."
git push
-echo "Publishing version ${PACKAGE_VERSION} with tag \"${NPM_TAG}\" ..."
-RUNNING_FROM_SCRIPT=1 npm publish --tag $NPM_TAG
+# Master gets published as LATEST if that version doesn't exists yet and retagged as LATEST otherwise.
+if [ $BRANCH = "master" ]; then
+ if [ -z `npm view ${PACKAGE_NAME} versions | grep $PACKAGE_VERSION` ]; then
+ echo "Publishing version ${PACKAGE_VERSION} with tag \"latest\" ..."
+ RUNNING_FROM_SCRIPT=1 npm publish --tag latest
+ else
+ echo "Tagging version ${PACKAGE_VERSION} with tag \"latest\" ..."
+ RUNNING_FROM_SCRIPT=1 npm dist-tag add ${PACKAGE_NAME}@${PACKAGE_VERSION} latest
+ fi
+
+# Develop branch gets published as BETA and we don't allow to override tag of existing version.
+elif [ $BRANCH = "develop" ]; then
+ echo "Publishing version ${PACKAGE_VERSION} with tag \"beta\" ..."
+ RUNNING_FROM_SCRIPT=1 npm publish --tag beta
+
+# For other branch throw an error.
+else
+ printf "${RED}You can publish from develop and master branches only!${NC}\n"
+ exit 1
+fi
echo "Tagging git with ${GIT_TAG} ..."
git tag ${GIT_TAG}
git push origin ${GIT_TAG}
+echo "Git tag: ${GIT_TAG} created."
echo "Done."