diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..66a8e52 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,31 @@ +on: + push: + tags: + - 'v*' + +name: Create Release + +jobs: + build: + name: Create Release + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + fetch-depth: 100 + - name: Get the version + id: version + run: echo ::set-output name=tag::${GITHUB_REF:10} + - name: Generate change log + run: scripts/changelog ${{ steps.version.outputs.tag }} > CHANGELOG.md + - name: Create Release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: "Release ${{ steps.version.outputs.tag }}" + body_path: CHANGELOG.md + draft: false + prerelease: false diff --git a/scripts/changelog b/scripts/changelog new file mode 100755 index 0000000..a65228a --- /dev/null +++ b/scripts/changelog @@ -0,0 +1,16 @@ +#!/bin/bash -e + +current_tag="$1" +if [ -z "${current_tag}" ]; then + echo "Displays changes since previous tag" + echo "Usage: changelog " + echo "Examples:" + echo " changelog HEAD" + echo " changelog 2.15.0" + exit 1 +fi + +previous_tag=$(git describe --tags --abbrev=0 "${current_tag}^") + +format="- %s ([%h](https://github.com/thumbsup/thumbsup/commit/%h))" +git log --pretty=format:"${format}" "${previous_tag}".."${current_tag}"