mirror of
https://github.com/cheveguerra/whatsapp-web.js.git
synced 2026-04-17 19:26:20 +00:00
add release action
This commit is contained in:
28
.github/workflows/release.yml
vendored
Normal file
28
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
name: release
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
release_type:
|
||||
description: "`alpha`, `alpha-minor`, `alpha-major` release?"
|
||||
required: true
|
||||
default: "alpha"
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ github.repository == 'pedroslopez/whatsapp-web.js' }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Bump version and publish to NPM
|
||||
id: publish
|
||||
run: ./tools/publish ${{ github.event.inputs.release_type }}
|
||||
env:
|
||||
NPM_TOKEN: ${{ secrets.RELEASE_NPM_TOKEN }}
|
||||
- name: Create GitHub Release
|
||||
id: create_release
|
||||
uses: ncipollo/release-action@v1
|
||||
with:
|
||||
prerelease: ${{ steps.publish.outputs.PRERELEASE }}
|
||||
generateReleaseNotes: true
|
||||
tag: v${{ steps.publish.outputs.NEW_VERSION }}
|
||||
80
tools/publish
Executable file
80
tools/publish
Executable file
@@ -0,0 +1,80 @@
|
||||
#!/bin/bash
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
cd '..'
|
||||
|
||||
BRANCH=`git rev-parse --abbrev-ref HEAD`
|
||||
RELEASE_MODE=$1
|
||||
|
||||
echo ""
|
||||
echo "-----> CHECK INPUTS"
|
||||
echo ""
|
||||
|
||||
if [[ "$RELEASE_MODE" == "alpha" ]]
|
||||
then
|
||||
PRERELEASE='true'
|
||||
VERSION_ARGS='prerelease --preid alpha -m "chore: prerelease v%s"'
|
||||
DIST_TAG="next"
|
||||
elif [[ "$RELEASE_MODE" == "alpha-minor" ]]
|
||||
then
|
||||
PRERELEASE='true'
|
||||
VERSION_ARGS='preminor --preid alpha -m "chore: prerelease v%s"'
|
||||
DIST_TAG="next"
|
||||
elif [[ "$RELEASE_MODE" == "alpha-major" ]]
|
||||
then
|
||||
PRERELEASE='true'
|
||||
VERSION_ARGS='premajor --preid alpha -m "chore: prerelease v%s"'
|
||||
DIST_TAG="next"
|
||||
else
|
||||
echo 'Release Mode required'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -f ~/.npmrc ]; then
|
||||
echo "Found existing .npmrc"
|
||||
else
|
||||
if [[ -z "$NPM_TOKEN" ]];then
|
||||
echo "No NPM_TOKEN or ~/.npmrc, exiting.."
|
||||
exit 1;
|
||||
else
|
||||
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
|
||||
fi
|
||||
fi
|
||||
echo "Publishing as NPM user: `npm whoami`"
|
||||
|
||||
if [[ $BRANCH != 'main' ]]; then
|
||||
echo "Not on 'main' branch. Exiting"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -n $(git status -s) ]]; then
|
||||
echo "There are uncommitted changes on this branch. Exiting"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "-----> BUMP VERSION"
|
||||
echo ""
|
||||
|
||||
npm version $VERSION_ARGS || exit 1
|
||||
git push && git push --tags
|
||||
|
||||
NEW_VERSION=`cat package.json | jq -r .version`
|
||||
echo "New Version: $NEW_VERSION"
|
||||
|
||||
echo ""
|
||||
echo "-----> PUSH TO NPM"
|
||||
echo ""
|
||||
|
||||
npm publish --tag $DIST_TAG
|
||||
|
||||
|
||||
echo ""
|
||||
echo "-----> Done!"
|
||||
echo "Version $NEW_VERSION published to $DIST_TAG tag"
|
||||
echo ""
|
||||
|
||||
echo "::set-output name=NEW_VERSION::$NEW_VERSION"
|
||||
echo "::set-output name=PRERELEASE::$PRELEASE"
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user