Skip to content

Release

Release #21

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$" 'BEGIN {RS="^## v"; FS="\n"} $0 ~ ver {print substr($0, index($0,"\n")+1)}' 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 + 1)) CHANGELOG.md)
else
changelog=$(sed -n "$(($start_line + 1)),$(($next_version_line - 1))p" CHANGELOG.md)
fi
fi
printf "changelog='%s'" "$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