Release #375
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
# 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-22.04 | |
# @link https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs | |
permissions: | |
contents: write | |
# @link https://docs.npmjs.com/generating-provenance-statements#about-npm-provenance | |
id-token: write | |
# 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@v4 | |
- 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: Setup Node.js environment | |
uses: actions/[email protected] | |
with: | |
node-version-file: ".nvmrc" | |
registry-url: "https://registry.npmjs.org" | |
- name: Reuse npm cache folder | |
uses: actions/cache@v4 | |
env: | |
cache-name: cache-node-modules | |
with: | |
path: | | |
~/.npm | |
./node_modules | |
./docs-src/node_modules | |
key: ${{ runner.os }}-npm-rxdb-release-x3-${{ hashFiles('**/package.json') }} | |
restore-keys: | | |
${{ runner.os }}-npm-rxdb-release-x3- | |
- 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.mjs ${{github.event.inputs.version}} | |
- run: npm run build | |
- name: build docs | |
if: steps.vars.outputs.prerelease == 'false' | |
run: | | |
(cd docs-src && npm install) | |
npm run docs: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 --provenance --access public | |
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/[email protected] | |
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 }} |