Skip to content

Release

Release #20

Workflow file for this run

name: Release
on:
push:
branches:
- master
paths:
- './version.json'
workflow_dispatch:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Get version from version.json
id: get_info
run: |
echo "version=$(node -p "require('./version.json').version")" >> $GITHUB_ENV
- name: Get changelog
id: get_changelog
run: |
current_version="v${{ env.version }}"
if grep -q "^## $current_version$" CHANGELOG.md; then
changelog=$(awk -v ver="^## $current_version$" '/^##/{if(p && $0 !~ ver) exit; p=1} p' CHANGELOG.md)
else
start_line=$(grep -n "^## $current_version$" CHANGELOG.md | cut -d ':' -f 1)
next_version_line=$(grep -n "^## v" CHANGELOG.md | grep -A 1 "^$current_version$" | tail -n 1 | cut -d ':' -f 1)
if [ -z "$next_version_line" ]; then
changelog=$(tail -n +$start_line CHANGELOG.md)
else
changelog=$(sed -n "$(($start_line + 1)),$(($next_version_line - 1))p" CHANGELOG.md)
fi
fi
echo "changelog=$changelog" >> $GITHUB_ENV
- name: Print Changelog
id: print_changelog
run: |
echo "Changelog: ${{ env.changelog }}"
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.version }}
release_name: v${{ env.version }}
body: ${{ env.changelog }}
draft: false
prerelease: false