Skip to content

Release package

Release package #26

Workflow file for this run

# @see https://superface.ai/blog/npm-publish-gh-actions-changelog
name: Release package
on:
workflow_dispatch:
inputs:
release-type:
type: 'choice'
description: 'The release type. It can be one of: major, minor, patch, premajor, preminor, prepatch, or prerelease. Defaults to "patch"'
required: true
default: 'patch'
options:
- major
- minor
- patch
- premajor
- preminor
- prepatch
- prerelease
git_bot_token:
description: Git Bot token used to push to protected branches because github token can't
required: false
jobs:
release:
runs-on: ubuntu-latest
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
contents: write
actions: write
id-token: write # to verify the deployment originates from an appropriate source
steps:
# Checkout project repository
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
# persist-credentials: false
token: ${{secrets.PA_TOKEN}}
# Configure Git
- name: Git configuration
run: |
git config user.name $GITHUB_ACTOR
git config user.email gh-actions-${GITHUB_ACTOR}@github.com
#
# git config --global user.name "Vadym Parakonnyi"
# git config --global user.email ${{ secrets.PA_EMAIL }}
# git remote set-url origin https://x-access-token/:${{ secrets.PA_TOKEN }}@github.com/${{ github.repository }}
# Setup Node.js environment
- name: Setup Node.js
uses: actions/setup-node@v3
with:
registry-url: https://registry.npmjs.org/
node-version: 18
# Install dependencies (required by Run tests step)
- name: Install dependencies
run: npm ci
# Bump package version
# Use tag latest
# Generates the changelog commit and tags and pushes them to Github.
# Use two post actions to Create a release in Github and for Publishing the package to NPM
- name: Bump release version
if: startsWith(github.event.inputs.release-type, 'pre') != true
run: |
# echo "NEW_VERSION=$(npm --no-git-tag-version version $RELEASE_TYPE)" >> $GITHUB_ENV
# echo "RELEASE_TAG=latest" >> $GITHUB_ENV
npx nx run rxdb:version --releaseAs=$RELEASE_TYPE
env:
GITHUB_TOKEN: ${{ secrets.PA_TOKEN }}
RELEASE_TYPE: ${{ github.event.inputs.release-type }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# Bump package pre-release version
# Use tag dev for pre-release versions
# Generates the changelog commit and tags and pushes them to Github.
# Use two post actions to Create a release in Github and for Publishing the package to NPM
- name: Bump pre-release version
if: startsWith(github.event.inputs.release-type, 'pre')
run: |
# echo "NEW_VERSION=$(npm --no-git-tag-version --preid=dev version $RELEASE_TYPE
# echo "RELEASE_TAG=dev" >> $GITHUB_ENV
npx nx run rxdb:version --releaseAs=$RELEASE_TYPE --preid=dev
env:
GITHUB_TOKEN: ${{ secrets.PA_TOKEN }}
RELEASE_TYPE: ${{ github.event.inputs.release-type }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# Build
- name: Build
run: npx nx run rxdb:build
# Publish version to public repository
- name: Publish release version
if: startsWith(github.event.inputs.release-type, 'pre') != true
working-directory: dist/packages/rxdb
run: |
npm pack
npm publish --access public --non-interactive --no-git-tag-version --tag latest
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# Publish version to public repository
- name: Publish pre-release version
if: startsWith(github.event.inputs.release-type, 'pre')
working-directory: dist/packages/rxdb
run: |
npm pack
npm publish --access public --non-interactive --no-git-tag-version --tag dev
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}