diff --git a/.github/workflows/npm.sh b/.github/workflows/npm.sh index 952f1f8..6038790 100644 --- a/.github/workflows/npm.sh +++ b/.github/workflows/npm.sh @@ -2,10 +2,17 @@ mkdir -p $RUNNER_TEMP/dist cp -a * $RUNNER_TEMP/dist cp -a .github $RUNNER_TEMP/dist cp -a .vscode $RUNNER_TEMP/dist -cp -a .yarn $RUNNER_TEMP/dist cp .* $RUNNER_TEMP/dist -mv $RUNNER_TEMP/dist dist +cd .yarn +mkdir $RUNNER_TEMP/dist/.yarn +cp -a patches $RUNNER_TEMP/dist/.yarn +cp -a plugins $RUNNER_TEMP/dist/.yarn +cp -a releases $RUNNER_TEMP/dist/.yarn +cp -a sdks $RUNNER_TEMP/dist/.yarn +cp -a versions $RUNNER_TEMP/dist/.yarn + +mv $RUNNER_TEMP/dist dist cd dist rm -rf node_modules @@ -14,9 +21,18 @@ rm -rf node_modules sed -i .gitignore \ -e '/yarn.lock/d' -cat package.json | jq ".version=\"0.0.0-$GITHUB_SHA\" | .private=false" > package.json.tmp -mv -f package.json.tmp package.json - -cd .. -tar -czf dist.tgz dist -npm publish dist.tgz --access public --tag nightly +# if $GITHUB_REF is in the form of refs/tags/v* then it's a release +if [[ $GITHUB_REF == refs/tags/v* ]]; then + cat package.json | jq ".private=false" > package.json.tmp + mv -f package.json.tmp package.json + cd .. + tar -czf dist.tgz dist + npm publish dist.tgz --access public +else + VERSION=$(cat package.json | grep '"version":' | cut -d '"' -f 4) + cat package.json | jq ".version=\"$VERSION-$GITHUB_SHA\" | .private=false" > package.json.tmp + mv -f package.json.tmp package.json + cd .. + tar -czf dist.tgz dist + npm publish dist.tgz --access public --tag nightly +fi diff --git a/.github/workflows/npm.yml b/.github/workflows/npm.yml index 711a451..a883835 100644 --- a/.github/workflows/npm.yml +++ b/.github/workflows/npm.yml @@ -4,6 +4,8 @@ on: push: branches: - main + tags: + - v* jobs: publish: @@ -26,4 +28,5 @@ jobs: run: bash .github/workflows/npm.sh env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + GITHUB_REF: ${{ github.ref }} GITHUB_SHA: ${{ github.sha }} diff --git a/package.json b/package.json index 90a073f..d4939cb 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "@cordisjs/boilerplate", + "name": "@cordiverse/boilerplate", "version": "0.0.1", "packageManager": "yarn@4.1.0", "private": true,