bump packages, fix ts test #4
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
pull_request: | |
types: [ labeled ] | |
branches: | |
- master | |
jobs: | |
prepare-release: | |
name: Prepare release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set major release | |
if: ${{ github.event.label.name == 'release-major' }} | |
run: echo "RELEASE=major" >> $GITHUB_ENV | |
- name: Set minor release | |
if: ${{ github.event.label.name == 'release-minor' }} | |
run: echo "RELEASE=minor" >> $GITHUB_ENV | |
- name: Set patch release | |
if: ${{ github.event.label.name == 'release-patch' }} | |
run: echo "RELEASE=patch" >> $GITHUB_ENV | |
- name: Check release env | |
run: | | |
if [[ -z "${{ env.RELEASE }}" ]]; | |
then | |
echo "You need to set a release label on PRs to the main branch" | |
exit 1 | |
else | |
exit 0 | |
fi | |
- name: Install semver-tool | |
run: | | |
export DIR=$(mktemp -d) | |
cd $DIR | |
curl https://github.com/fsaintjacques/semver-tool/archive/3.2.0.tar.gz -L -o semver.tar.gz | |
tar -xvf semver.tar.gz | |
sudo cp semver-tool-3.2.0/src/semver /usr/local/bin | |
- name: Bump version | |
run: | | |
export CURRENT=$(npm show @pusher/push-notifications-server | grep latest | cut -d':' -f 2 | xargs) | |
export NEW_VERSION=$(semver bump ${{ env.RELEASE }} $CURRENT) | |
echo "VERSION=$NEW_VERSION" >> $GITHUB_ENV | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Setup git | |
run: | | |
git config user.email "pusher-ci@pusher.com" | |
git config user.name "Pusher CI" | |
git fetch | |
git checkout ${{ github.event.pull_request.head.ref }} | |
- name: Prepare CHANGELOG | |
run: | | |
echo "${{ github.event.pull_request.body }}" | csplit -s - "/##/" | |
echo "# Changelog | |
## ${{ env.VERSION }} | |
" >> CHANGELOG.tmp | |
grep "^*" xx01 >> CHANGELOG.tmp | |
grep -v "^# " CHANGELOG.md >> CHANGELOG.tmp | |
cp CHANGELOG.tmp CHANGELOG.md | |
- name: Prepare README | |
run: | | |
export MAJOR=$(echo "${{ env.VERSION }}" | cut -d'.' -f1) | |
export MINOR=$(echo "${{ env.VERSION }}" | cut -d'.' -f2) | |
- name: Prepare update | |
run: | | |
sed -i "s|\"version\": \"[^\"]*\"|\"version\": \"${{ env.VERSION }}\"|" package.json | |
sed -i "s|const SDK_VERSION = '[^']*'|const SDK_VERSION = '${{ env.VERSION }}'|" push-notifications.js | |
sed -i "s|'pusher-push-notifications-node [^']*'|'pusher-push-notifications-node ${{ env.VERSION }}'|g" __tests__/*.js | |
- name: Commit changes | |
run: | | |
git add CHANGELOG.md README.md package.json push-notifications.js __tests__/*.js | |
git commit -m "Bump to version ${{ env.VERSION }}" | |
- name: Push | |
run: git push | |