name: Release
on:
push:
tags:
- 'v*'
jobs:
create_new_release:
name: Create release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
version: ${{ steps.parse_changelog.outputs.version }}
version_num: ${{ steps.parse_changelog.outputs.version_num }}
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Parse changelog
id: parse_changelog
env:
VERSION: ${{ github.ref }}
run: |
# Extract the tag name from the github ref (e.g. revs/tags/v0.1.0)
VERSION=${VERSION:10}
# VERSION_NUM is the version but without the v on the front
VERSION_NUM=${VERSION:1}
# Grab the current release section from the changelog
BODY=$(sed -n "/$VERSION/,/^## /p" Changelog.md | head -n-1)
# URL-encode percent, LF, CR
BODY="${BODY//'%'/'%25'}"
BODY="${BODY//$'\n'/'%0A'}"
BODY="${BODY//$'\r'/'%0D'}"
# Store the release body for the next step
echo "::set-output name=BODY::${BODY}"
echo "::set-output name=version::${VERSION}"
echo "::set-output name=version_num::${VERSION_NUM}"
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
body: ${{ steps.parse_changelog.outputs.BODY }}
draft: false
prerelease: false