name: 🎉 Release Commit

on: 
  # workflow_dispatch: # see https://github.com/go-gitea/gitea/issues/23668
  # pull_request:
  #   types: [closed]
  push:
    branches:
      - main
    
# concurrency:
#   cancel-in-progress: true
#   group: "${{ github.workflow }}-${{ github.ref_name }}-${{ startsWith(github.event.head_commit.message, 'chore(release): ') && 'release' || 'commit' }}"

jobs:
  yarn-release:
    if: "${{ !startsWith(github.event.head_commit.message, 'chore(release): ') }}"
    runs-on: ubuntu-latest
    name: create release using commit-and-tag-version
    steps:
      - uses: actions/checkout@v4.1.7
        with:
          token: ${{ secrets.M8A_ORG_BOT_REPO_TOKEN }}
      
      - uses: actions/setup-node@v3
        with:
          node-version: 20

      - run: yarn

      - name: Run release
        env:
          GIT_AUTHOR_EMAIL: bot@devthefuture.org
          GIT_AUTHOR_NAME: forgejo-actions
          GIT_COMMITTER_EMAIL: bot@devthefuture.org
          GIT_COMMITTER_NAME: forgejo-actions
        run: yarn release
      
      - name: Push release
        shell: bash
        run: |
          git push --follow-tags origin main