Skip to content

Release Workflow

Release Workflow #4

Workflow file for this run

name: Release Workflow
on:
workflow_dispatch:
inputs:
releaseType:
description: 'Release Type (MAJOR, MINOR, PATCH)'
required: true
default: 'PATCH'
draft:
description: 'Create a draft release'
required: false
default: false
type: boolean
prerelease:
description: 'Mark release as a prerelease'
required: false
default: false
type: boolean
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '14'
- name: Fetch tags
run: git fetch --depth=1 --tags
- name: Get latest tag or set default
id: latest_tag
run: |
TAG=$(git tag -l "v*" --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -n 1)
if [ -z "$TAG" ]; then
TAG="0.0.0"
fi
echo "::set-output name=tag::$TAG"
- name: Create dummy package.json
run: |
echo "{\"version\": \"${{ steps.latest_tag.outputs.tag }}\"}" > package.json
cat package.json
- name: Calculate next version
id: next_version
run: |
npm --no-git-tag-version version ${{ github.event.inputs.releaseType }}
NEXT_VERSION=$(node -p "require('./package.json').version")
echo "Next version: $NEXT_VERSION"
echo "::set-output name=version::$NEXT_VERSION"
- name: Create Git tag
run: git tag v${{ steps.next_version.outputs.version }}
- name: Push Git tag
run: |
git config --global user.name 'Anton Potapov'
git config --global user.email '47938145+Flagro@users.noreply.github.com.'
git push origin v${{ steps.next_version.outputs.version }}
- name: Create Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.next_version.outputs.version }}
release_name: Release v${{ steps.next_version.outputs.version }}
draft: ${{ github.event.inputs.draft }}
prerelease: ${{ github.event.inputs.prerelease }}