Skip to content

Commit

Permalink
feat: allow alpha tags
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaccoSordo committed Aug 28, 2024
1 parent bb8bc99 commit e6e51f1
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 24 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ RUN export NODE_ENV=production
# install dependencies
RUN npm install

RUN chmod +x ./npm-ci-publish-beta-only.sh
RUN chmod +x ./npm-ci-publish-beta-and-alpha-only.sh
RUN chmod +x ./npm-ci-publish.sh

CMD ["npm", "run", "test"]
25 changes: 25 additions & 0 deletions npm-ci-publish-beta-and-alpha-only.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
echo "//registry.npmjs.org/:_authToken=$NPM_AUTH_TOKEN" > .npmrc

git update-index --assume-unchanged npm-ci-publish.sh
git update-index --assume-unchanged npm-ci-publish-beta-only.sh

VERSION=$(node -pe 'const version = JSON.parse(process.argv[1]).version; version.includes("beta") || version.includes("alpha") ? version : ""' "$(cat lerna.json)")

if [ -z "$VERSION" ]
then
echo "cannot publish non-beta/non-alpha version"
else
if [[ "$VERSION" == *"beta"* ]]
then
TAG="next"
echo "version is beta, using --tag $TAG"
elif [[ "$VERSION" == *"alpha"* ]]
then
TAG="alpha"
echo "version is alpha, using --tag $TAG"
fi
npx lerna publish from-package --contents ./ --dist-tag $TAG --yes
fi

rm .npmrc
17 changes: 0 additions & 17 deletions npm-ci-publish-beta-only.sh

This file was deleted.

21 changes: 15 additions & 6 deletions npm-ci-publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,24 @@ echo "//registry.npmjs.org/:_authToken=$NPM_AUTH_TOKEN" > .npmrc
git update-index --assume-unchanged npm-ci-publish.sh
git update-index --assume-unchanged npm-ci-publish-beta-only.sh

VERSION=$(node -pe 'JSON.parse(process.argv[1]).version.indexOf("beta")' "$(cat lerna.json)")
VERSION=$(node -pe 'const version = JSON.parse(process.argv[1]).version; version.includes("beta") || version.includes("alpha") ? version : ""' "$(cat lerna.json)")

if [ "$VERSION" = "-1" ]
if [ -z "$VERSION" ]
then
echo "version is not beta or alpha, proceeding with standard publish"
npx lerna publish from-package --contents ./ --yes
# lerna exec -- "npm publish || exit 0" # If some packages fail to be published, this command ignores already published ones and publishes the missing ones
# lerna exec -- "npm publish || exit 0" # Uncomment if you need to handle already published packages separately
else
echo "version is beta, using --tag next"
npx lerna publish from-package --contents ./ --dist-tag next --yes
if [[ "$VERSION" == *"beta"* ]]
then
TAG="next"
echo "version is beta, using --tag $TAG"
elif [[ "$VERSION" == *"alpha"* ]]
then
TAG="alpha"
echo "version is alpha, using --tag $TAG"
fi
npx lerna publish from-package --contents ./ --dist-tag $TAG --yes
fi

rm .npmrc
rm .npmrc

0 comments on commit e6e51f1

Please sign in to comment.