name: release

on:
  push:
    tags:
      - '*.*.*'

jobs:
  make-release:

    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      - name: extract version
        id: version
        run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/}
      - name: create changelog
        id: changelog
        uses: jaywcjlove/changelog-generator@main
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          filter: 'Release \d+\.\d+\.\d+'
      - name: create archive
        run: make archive
        env:
          VERSION: ${{ steps.version.outputs.VERSION }}
      - name: Release
        uses: softprops/action-gh-release@v1
        with:
          body: |
            ${{ steps.changelog.outputs.compareurl }}
            ${{ steps.changelog.outputs.changelog }}
          files: ahriman-*-src.tar.xz
          fail_on_unmatched_files: true
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
