Skip to content

Commit

Permalink
chore: add script and workflow for releases
Browse files Browse the repository at this point in the history
  • Loading branch information
stfsy committed Jan 2, 2022
1 parent 7014171 commit 37ac2ba
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .get_latest_changes_for_release_notes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash

CHANGELOG="CHANGELOG.md"
NEWLINE="\n"

first_release_processed='false'
has_linebreak='false'

text=''

while IFS= read -r line; do
if echo $line | grep -q -E '^<a *'; then
continue
fi

if echo $line | grep -q -E '^#[#]{1,2} [[]{1}.*|^<a *'; then
if [[ $first_release_processed == "false" ]]; then
first_release_processed="true"
else
break
fi
fi

if [[ -z $line ]]; then
if [[ $has_linebreak == 'false' ]]; then
has_linebreak='true'
else
continue
fi
else
has_linebreak='false'
fi

text="$text ${line} ${NEWLINE}"

done < "$CHANGELOG"

echo -e "$text"
35 changes: 35 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
on:
push:
tags:
- 'v*'

name: release

jobs:
build:
name: Create Release
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set env
run: |
echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
echo "RELEASE_NAME=${GITHUB_EVENT_REPOSITORY_NAME}-${RELEASE_VERSION}" >> $GITHUB_ENV
- name: Create changelog
run: |
./.get_latest_changes_for_release_notes.sh > ./${RELEASE_NAME}.md
- name: Create Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ env.RELEASE_VERSION }}
body_path: ./${{ env.RELEASE_NAME }}.md
draft: false
prerelease: false

0 comments on commit 37ac2ba

Please sign in to comment.