Meta: Add GitHub release action

The action is executed on every tag and creates a GitHub release. The
release contains a .tar.gz asset and a changelog consisting of all
commit messages since the previous tag. Commits with a commit message
starting with "Meta" are excluded from the changelog.
This commit is contained in:
carlfriedrich 2022-11-16 19:09:23 +01:00
parent fe4ac0f9f2
commit eedf3ae890
3 changed files with 63 additions and 1 deletions

27
.github/scripts/changelog.sh vendored Executable file
View file

@ -0,0 +1,27 @@
#!/bin/bash
url=$(git remote get-url origin | sed -r 's/(.*)\.git/\1/')
previous_tag=$(git describe --tags --abbrev=0 HEAD~)
echo "Changes since $previous_tag:"
echo
# Loop through all commits since previous tag
for rev in $(git log $previous_tag..HEAD --format="%H" --reverse --no-merges)
do
summary=$(git log $rev~..$rev --format="%s")
# Exclude commits starting with "Meta"
if [[ $summary != Meta* ]]
then
# Print markdown list of commit headlines
echo "* [$summary]($url/commit/$rev)"
# Append commit body indented (blank lines and signoff trailer removed)
git log $rev~..$rev --format="%b" | sed '/^\s*$/d' | sed '/^Signed-off-by:/d' | \
while read -r line
do
# Escape markdown formatting symbols _ * `
echo " $line" | sed 's/_/\\_/g' | sed 's/`/\\`/g' | sed 's/\*/\\\*/g'
done
fi
done

View file

@ -4,7 +4,13 @@ name: ci
# Controls when the action will run. Triggers the workflow on push or pull request # Controls when the action will run. Triggers the workflow on push or pull request
# events, but only for the master branch # events, but only for the master branch
on: [push, pull_request] on:
push:
branches:
- '**'
pull_request:
branches:
- '**'
# A workflow run is made up of one or more jobs that can run sequentially or in parallel # A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs: jobs:

29
.github/workflows/release.yaml vendored Normal file
View file

@ -0,0 +1,29 @@
name: Release
on:
push:
tags:
- '**'
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Create Package
run: tar -czf forgit-${{github.ref_name}}.tar.gz --exclude LICENSE --exclude README.md *
- name: Generate Changelog
run: .github/scripts/changelog.sh > CHANGELOG.md
- name: Release
uses: softprops/action-gh-release@v1
with:
body_path: CHANGELOG.md
files: forgit-${{github.ref_name}}.tar.gz