Skip to content

Release

Release #268

Workflow file for this run

# This is a basic workflow to help you get started with Actions
name: Release
# Controls when the action will run.
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
version:
# Friendly description to be shown in the UI instead of 'name'
description: "Version to release (if the version contains the beta keyword, we assume it is a pre-release)"
# Default value if no value is explicitly provided
default: ""
# Input has to be provided for the workflow to run
required: true
jobs:
# This workflow contains a single job called "build"
build-all:
# The type of runner that the job will run on
runs-on: ubuntu-20.04
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- name: Set prerelease variable
id: vars
run: |
echo ::set-output name=prerelease::${{ contains(github.event.inputs.version, 'beta') }}
echo ::set-output name=nonPatchRelease::${{ endsWith(github.event.inputs.version, '.0') }}
- name: Log parsed version
run: |
echo "version: ${{github.event.inputs.version}}"
echo "prerelease: ${{ steps.vars.outputs.prerelease }}"
- name: Set git config
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
- name: Reuse npm cache folder
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: |
~/.npm
./node_modules
key: ${{ runner.os }}-npm-rxdb-release-x2-${{ hashFiles('**/package.json') }}
restore-keys: |
${{ runner.os }}-npm-rxdb-release-x2-
# Build the docs, only do this if it is not a prerelease.
# TODO move from gitbook to honkit
# https://github.com/honkit/honkit
# so we do not need this
- name: downgrade nodejs for gitbook
if: steps.vars.outputs.prerelease == 'false'
uses: actions/setup-node@v3.7.0
with:
node-version: 13.8.0
- name: Install old node version so it works with the shitty gitbook
if: steps.vars.outputs.prerelease == 'false'
run: |
node -v
npm install
- name: build docs
if: steps.vars.outputs.prerelease == 'false'
run: |
npm run docs:build
- name: Setup Node.js environment
uses: actions/setup-node@v3.7.0
with:
node-version-file: ".nvmrc"
registry-url: "https://registry.npmjs.org"
- name: install npm dependencies
run: |
node -v
rm -rf node_modules/
npm install
- name: "update version and changelog"
working-directory: "scripts"
run: |
node set-version.js ${{github.event.inputs.version}}
- run: npm run docs:landingpage:build
- run: npm run build
- name: add git tag
run: |
git add .
git status .
git diff package.json
git commit -m ${{github.event.inputs.version}}
git tag ${{github.event.inputs.version}}
- run: npm publish --tag next
if: steps.vars.outputs.prerelease == 'true'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- run: npm publish
if: steps.vars.outputs.prerelease == 'false'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# pull again to make it unlikely that we have a merge conflict.
- run: git pull
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
# must run after the push
# because it otherwise does not know
# about the tag and add the old source code to the release.
# This might be a bug.
- uses: ncipollo/release-action@v1.12.0
with:
prerelease: ${{ steps.vars.outputs.prerelease }}
tag: ${{github.event.inputs.version}}
bodyFile: "./release-body.md"
token: ${{ secrets.GITHUB_TOKEN }}
# @link https://github.com/marketplace/actions/actions-for-discord
- name: Discord notification
# To not spam users too much, we only do this on major and minor releases
if: steps.vars.outputs.prerelease == 'false' && steps.vars.outputs.nonPatchRelease == 'true'
uses: Ilshidur/action-discord@master
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
with:
args: "@everyone A new RxDB version has been released: https://github.com/pubkey/rxdb/releases/tag/${{github.event.inputs.version}}"
# @link https://github.com/marketplace/actions/send-tweet-action
- name: Twitter notification
# To not spam users too much, we only do this on major and minor releases
if: steps.vars.outputs.prerelease == 'false' && steps.vars.outputs.nonPatchRelease == 'true'
uses: ethomson/send-tweet-action@v1
with:
status: "A new #RxDB version ${{github.event.inputs.version}} has been released: https://github.com/pubkey/rxdb/releases/tag/${{github.event.inputs.version}}"
consumer-key: ${{ secrets.TWITTER_CONSUMER_API_KEY }}
consumer-secret: ${{ secrets.TWITTER_CONSUMER_API_SECRET }}
access-token: ${{ secrets.TWITTER_ACCESS_TOKEN }}
access-token-secret: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}