# Trigger this workflow by pushing a release tag.
# Make sure that `HEAD` is pointing to the commit you want to release.
# Then run `git tag -a v<version_tag> -m "Release version <version_tag> (<yyyy>-<mm>-<dd>)" && git push && git push --tags`.
# For example `git tag -a v1.06 -m "Release version 1.06 (2020-12-20)" && git push && git push --tags`.
name: InChI Release

on:
  push:
    tags:
      - v1.*

jobs:
  release:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Checkout release
        # `ref_name` is triggering tag.
        run: git checkout ${{ github.ref_name }}

      - name: Build release artifacts
        run: |
          zip -r INCHI-1-BIN.zip INCHI-1-BIN
          zip -r INCHI-1-DOC.zip INCHI-1-DOC
          zip -r INCHI-1-SRC.zip INCHI-1-SRC
          zip -r INCHI-1-TEST.zip INCHI-1-TEST

      - name: Create release
        shell: bash
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        # See https://cli.github.com/manual/gh_release_create.
        run: |
          gh release create ${{ github.ref_name }} \
          --verify-tag \
          --title "${{ github.ref_name }}" \
          --notes "For details about this release have a look at the [CHANGELOG](INCHI-1-DOC/CHANGELOG.md)." \
          INCHI-1-BIN.zip INCHI-1-DOC.zip INCHI-1-SRC.zip INCHI-1-TEST.zip
