Skip to content

Commit

Permalink
test with dev counter build version
Browse files Browse the repository at this point in the history
  • Loading branch information
Xziy committed May 4, 2024
1 parent 4534bff commit 20acb91
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
21 changes: 19 additions & 2 deletions .github/workflows/alpha.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,25 @@ 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 -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: |
set -x
BRANCH=${GITHUB_REF##*/}
PACKAGE=$(cat package.json | jq -r '.["name"]')
VERNPMRAW=$(curl -s https://registry.npmjs.org/$PACKAGE | jq -r '.["dist-tags"].'$BRANCH'')
VERNPM=$(echo $VERNPMRAW | cut -d'-' -f1)
BUILD_VERSION=$(echo $VERNPMRAW | cut -d'.' -f3)
VERLOC=$(cat package.json | jq -r '.["version"]')
VEROUT=$(printf "$VERNPM\n$VERLOC\n" | sort -V -r | awk 'NR==1 {print; exit}')
if [[ ! -z "$VERNPM" ]]; then
if [[ ! -z "$BUILD_VERSION" ]]; then
BUILD_VERSION=$((BUILD_VERSION+1))
else
BUILD_VERSION=1
fi
else
BUILD_VERSION=1
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##*/}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
1 change: 1 addition & 0 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
branches-ignore:
- master
- alpha
- next
- test-with-postgres
jobs:
build:
Expand Down

0 comments on commit 20acb91

Please sign in to comment.