Skip to content

test with dev counter build version #83

test with dev counter build version

test with dev counter build version #83

Workflow file for this run

name: Publish Package to npmjs
on:
push:
branches:
- alpha
- next
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v3
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
# waiting https://github.com/ds300/patch-package/issues/339
- 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"]')
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 }}