Skip to content

Commit

Permalink
change version builder
Browse files Browse the repository at this point in the history
  • Loading branch information
Xziy committed May 4, 2024
1 parent 378de31 commit 873a107
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .github/workflows/alpha.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ jobs:
- run: npm install 2>&1 || true && npm run test:init 2>&1 || true && npm run test

# resolve version
- run: set -x; BRANCH=${GITHUB_REF##*/} PACKAGE=$(cat package.json | jq -r '.["name"]') VERNPM=$(curl https://registry.npmjs.org/$PACKAGE | jq -r '.["dist-tags"].'${BRANCH} | awk -F. -v OFS=. '{$NF += 1 ; print}') VERLOC=$(cat package.json | jq -r '.["version"]') VEROUT=$(printf "$VERNPM\n$VERLOC\n" | sort -V -r | awk 'NR==1 {print; exit}') && jq -r '.version = "'${VEROUT}'-'${BRANCH}'"' package.json > /tmp/package.json && mv /tmp/package.json ./package.json
- run: set -x; BRANCH=${GITHUB_REF##*/}; PACKAGE=$(cat package.json | jq -r '.["name"]'); VERNPM=$(curl -sS https://registry.npmjs.org/"$PACKAGE" | jq -r '.["dist-tags"].'"$BRANCH"'); VERLOC=$(cat package.json | jq -r '.["version"]'); if [[ -z "$VERNPM" ]]; then VERNPM="0"; else RELEASE=$(echo "$VERNPM" | awk -F'-dev.' '{print $2}'); if [[ -z "$RELEASE" ]]; then RELEASE="0"; fi; RELEASE=$((RELEASE + 1)); VERNPM="0.$RELEASE"; fi; VEROUT="2.0.0-dev.$VERNPM"; jq -r --arg VEROUT "$VEROUT" '.version = $VEROUT' package.json > /tmp/package.json && mv /tmp/package.json ./package.json
# - run: set -x; BRANCH=${GITHUB_REF##*/} PACKAGE=$(cat package.json | jq -r '.["name"]') VERNPM=$(curl https://registry.npmjs.org/$PACKAGE | jq -r '.["dist-tags"].'${BRANCH} | awk -F. -v OFS=. '{$NF += 1 ; print}') VERLOC=$(cat package.json | jq -r '.["version"]') VEROUT=$(printf "$VERNPM\n$VERLOC\n" | sort -V -r | awk 'NR==1 {print; exit}') && jq -r '.version = "'${VEROUT}'-'${BRANCH}'"' package.json > /tmp/package.json && mv /tmp/package.json ./package.json
- run: npm publish --tag ${GITHUB_REF##*/}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 comments on commit 873a107

Please sign in to comment.