Skip to content

Commit

Permalink
support tag release
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed May 13, 2024
1 parent c7a7966 commit 7f5236f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
32 changes: 24 additions & 8 deletions .github/workflows/npm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
3 changes: 3 additions & 0 deletions .github/workflows/npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
push:
branches:
- main
tags:
- v*

jobs:
publish:
Expand All @@ -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 }}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@cordisjs/boilerplate",
"name": "@cordiverse/boilerplate",
"version": "0.0.1",
"packageManager": "[email protected]",
"private": true,
Expand Down

0 comments on commit 7f5236f

Please sign in to comment.