name: Create release

on:
  push:
    tags:
      - "v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+"

jobs:
  create_release:
    name: Create release
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - name: Extract version number
        id: tag_version
        shell: bash
        run: |
          echo ::set-output name=release_version::$(echo ${{github.ref_name}} | sed "s/^.*v\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\)-.*$/\1/")
      - name: Add release message
        uses: softprops/action-gh-release@v1
        with:
          name: v${{ steps.tag_version.outputs.release_version }}
          body: |
            Downloade the utiLITI editor from https://litiengine.com/download/.
            LITIENGINE is available through [Maven Central](https://search.maven.org/artifact/de.gurkenlabs/litiengine):
            <details>
              <summary>Gradle (Groovy)</summary>

              ````groovy
              implementation 'de.gurkenlabs:litiengine:${{ steps.tag_version.outputs.release_version }}'
              ````
            </details>

            <details>
              <summary>Gradle (Kotlin)</summary>

              ````kotlin
              implementation("de.gurkenlabs:litiengine:${{ steps.tag_version.outputs.release_version }}")
              ````
            </details>

            <details>
              <summary>Maven</summary>

              ````xml
              <dependency>
                <groupId>de.gurkenlabs</groupId>
                <artifactId>litiengine</artifactId>
                <version>${{ steps.tag_version.outputs.release_version }}</version>
              </dependency>
              ````
            </details>

Add action to automatically create release on GitHub
Add action to automatically create release on GitHub

If a tag is pushed/create that is of the form v[0-9]+\.[0-9]+\.[0-9]+-rc[0-9]+
(e.g. v5.8.6-rc1) it will change  the text of the release to include information
on how to obtain the library through Gradle/Maven and utiLITI on the website.
