# Credits: # https://gitea.com/gitea/runner-images/src/branch/main/.gitea/workflows/release.yaml
name: Release new version
run-name: Release ${{  github.ref_name }}

on:
  push:
    tags:
      - "*"

jobs:
  release:
    runs-on: ubuntu-latest
    container: docker.io/thegeeklab/git-sv:2.0.9
    steps:
      - name: Install tools
        run: |
          apk add -q --update --no-cache nodejs
      - name: Checkout repository
        uses: actions/checkout@v6
        with:
          fetch-tags: true
          fetch-depth: 0

      - name: Create changelog
        run: |
          git sv current-version
          git sv release-notes -t ${GITHUB_REF#refs/tags/} -o CHANGELOG.md
          sed -i '1,2d' CHANGELOG.md # remove version
          cat CHANGELOG.md

      - name: Release
        uses: https://github.com/akkuman/gitea-release-action@v1
        with:
          body_path: CHANGELOG.md
          token: "${{ secrets.REPO_RW_TOKEN }}"
