Skip to content

Release package

Release package #53

name: Release package
on:
workflow_dispatch:
inputs:
release-level:
description: 'Release level (one of): patch, minor, major, prepatch, preminor, premajor, prerelease'
required: true
jobs:
release:
runs-on: ubuntu-20.04
strategy:
matrix:
node-version: [ 16.x ]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
registry-url: 'https://registry.npmjs.org'
- name: Install Yarn dependencies
run: yarn install
- name: Run tests
run: yarn test
- name: Run build
run: yarn build
# Git configuration
- name: Git configuration
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions release workflow"
- name: Bump release version
if: startsWith(github.event.inputs.release-level, 'pre') != true
run: |
echo "NEW_VERSION=$(npm --no-git-tag-version version $RELEASE_LEVEL)" >> $GITHUB_ENV
echo "RELEASE_TAG=latest" >> $GITHUB_ENV
# Bump api
cd ./packages/api/build
cp ../package.json .
echo "NEW_VERSION=$(npm --no-git-tag-version --preid=beta version $RELEASE_LEVEL)" >> $GITHUB_ENV
echo "RELEASE_TAG=latest" >> $GITHUB_ENV
cp package.json ../package.json
# Bump definitions
cd ../../definitions/build/
cp ../package.json .
echo "NEW_VERSION=$(npm --no-git-tag-version --preid=beta version $RELEASE_LEVEL)" >> $GITHUB_ENV
echo "RELEASE_TAG=latest" >> $GITHUB_ENV
cp package.json ../package.json
# Bump utils
cd ../../utils/build/
cp ../package.json .
echo "NEW_VERSION=$(npm --no-git-tag-version --preid=beta version $RELEASE_LEVEL)" >> $GITHUB_ENV
echo "RELEASE_TAG=latest" >> $GITHUB_ENV
cp package.json ../package.json
# Bump elastic
cd ../../elasticsearch/build/
cp ../package.json .
echo "NEW_VERSION=$(npm --no-git-tag-version --preid=beta version $RELEASE_LEVEL)" >> $GITHUB_ENV
echo "RELEASE_TAG=latest" >> $GITHUB_ENV
cp package.json ../package.json
env:
RELEASE_LEVEL: ${{ github.event.inputs.release-level }}
- name: Bump pre-release version
if: startsWith(github.event.inputs.release-level, 'pre')
run: |
echo "NEW_VERSION=$(npm --no-git-tag-version --preid=beta version $RELEASE_LEVEL)" >> $GITHUB_ENV
echo "RELEASE_TAG=beta" >> $GITHUB_ENV
# Bump api
cd ./packages/api/build
cp ../package.json .
echo "NEW_VERSION=$(npm --no-git-tag-version --preid=beta version $RELEASE_LEVEL)" >> $GITHUB_ENV
echo "RELEASE_TAG=beta" >> $GITHUB_ENV
cp package.json ../package.json
# Bump definitions
cd ../../definitions/build/
cp ../package.json .
echo "NEW_VERSION=$(npm --no-git-tag-version --preid=beta version $RELEASE_LEVEL)" >> $GITHUB_ENV
echo "RELEASE_TAG=beta" >> $GITHUB_ENV
cp package.json ../package.json
# Bump utils
cd ../../utils/build/
cp ../package.json .
echo "NEW_VERSION=$(npm --no-git-tag-version --preid=beta version $RELEASE_LEVEL)" >> $GITHUB_ENV
echo "RELEASE_TAG=beta" >> $GITHUB_ENV
cp package.json ../package.json
# Bump elastic
cd ../../elasticsearch/build/
cp ../package.json .
echo "NEW_VERSION=$(npm --no-git-tag-version --preid=beta version $RELEASE_LEVEL)" >> $GITHUB_ENV
echo "RELEASE_TAG=beta" >> $GITHUB_ENV
cp package.json ../package.json
env:
RELEASE_LEVEL: ${{ github.event.inputs.release-level }}
# Update changelog unreleased section with new version
- name: Update changelog
uses: superfaceai/release-changelog-action@v1
if: startsWith(github.event.inputs.release-level, 'pre') != true
with:
path-to-changelog: CHANGELOG.md
version: ${{ env.NEW_VERSION }}
operation: release
# Commit changelog changes
- name: Commit CHANGELOG.md and package.json changes and create tag
run: |
git add "package.json"
git add "CHANGELOG.md"
git add "packages/api/package.json"
git add "packages/definitions/package.json"
git add "packages/utils/package.json"
git add "packages/elasticsearch/package.json"
git commit -m "chore: release ${{ env.NEW_VERSION }}"
git tag ${{ env.NEW_VERSION }}
# Publish version to public repository
- name: publish all
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
# publish api
cd ./packages/api/build
yarn publish --verbose --access public --tag ${{ env.RELEASE_TAG }}
# publish definitions
cd ../../definitions/build
yarn publish --verbose --access public --tag ${{ env.RELEASE_TAG }}
# publish utils
cd ../../utils/build
yarn publish --verbose --access public --tag ${{ env.RELEASE_TAG }}
# publish elasic
cd ../../elasticsearch/build
yarn publish --verbose --access public --tag ${{ env.RELEASE_TAG }}
# Push changes to origin
- name: Push changes to repository
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git push origin && git push --tags
# Read version changelog
- id: get-changelog
name: Get release version changelog
if: startsWith(github.event.inputs.release-level, 'pre') != true
uses: superfaceai/release-changelog-action@v1
with:
path-to-changelog: CHANGELOG.md
version: ${{ env.NEW_VERSION }}
operation: read
# Update release documentation
- name: Update GitHub release documentation
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.NEW_VERSION }}
body: ${{ steps.get-changelog.outputs.changelog }}
prerelease: ${{ startsWith(github.event.inputs.release-level, 'pre') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}