Skip to content

Commit

Permalink
update ci
Browse files Browse the repository at this point in the history
  • Loading branch information
Xziy committed Jun 2, 2024
1 parent b99efc7 commit 790f1f6
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions .github/workflows/dev-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,30 @@ jobs:

# resolve version
- run: |
set -x
set -ex
cd ./dist
BRANCH=${GITHUB_REF##*/}
PACKAGE=$(cat package.json | jq -r '.["name"]')
VERLOC=$(cat package.json | jq -r '.["version"]')
VERNPMRAW=$(curl -s https://registry.npmjs.org/$PACKAGE | jq -r '.["dist-tags"].'$BRANCH'')
BUILD_VERSION=0
if [[ "$VERNPMRAW" == "null" ]]; then
VEROUT=$VERLOC
else
VERNPM=$(echo $VERNPMRAW | cut -d'-' -f1)
BUILD_VERSION=$(echo $VERNPMRAW | awk -F '[.-]' '{print $5+1}')
VEROUT=$(printf "$VERNPM\n$VERLOC\n" | sort -V -r | awk 'NR==1 {print; exit}')
fi
jq -r '.version = "'${VEROUT}'-build.'$BUILD_VERSION'"' package.json > /tmp/package.json && mv /tmp/package.json ./package.json
- run: npm publish --tag ${GITHUB_REF##*/}
# Check if VEROUT already has a -build suffix
if [[ "$VEROUT" == *-build.* ]]; then
CLEAN_VERSION=$(echo $VEROUT | cut -d'-' -f1)
else
CLEAN_VERSION=$VEROUT
fi
jq -r '.version = "'${CLEAN_VERSION}'-build.'$BUILD_VERSION'"' package.json > /tmp/package.json && mv /tmp/package.json ./package.json
npm publish --tag $BRANCH
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 comments on commit 790f1f6

Please sign in to comment.