diff --git a/.github/scripts/changelog.sh b/.github/scripts/changelog.sh new file mode 100755 index 0000000..f8e80d6 --- /dev/null +++ b/.github/scripts/changelog.sh @@ -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 diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 89e2795..d6914d8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -4,7 +4,13 @@ name: ci # Controls when the action will run. Triggers the workflow on push or pull request # 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 jobs: diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..4c773ca --- /dev/null +++ b/.github/workflows/release.yaml @@ -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