name: Release Daily State # Workflow name displayed on GitHub
on:
  workflow_dispatch: # Trigger manually
  schedule:
    - cron: '30 20 * * *' # UTC is 2-3 hours behind Europe/Helsinki, my timezone
permissions:
  contents: write
jobs:
  new-daily-release:
    runs-on: self-hosted
    outputs:
      created: ${{ steps.daily-version.outputs.created }}
      version: ${{ steps.daily-version.outputs.version }}
    steps:
      - uses: actions/checkout@v4 # Checkout our working repository
      - name: Create tag if necessary
        uses: fregante/daily-version-action@v2
        id: daily-version
      - name: Create changelog text
        if: steps.daily-version.outputs.created
        id: changelog
        uses: loopwerk/tag-changelog@v1
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          config_file: .github/tag-changelog-config.js
      - name: Create release
        if: steps.daily-version.outputs.created
        uses: actions/create-release@latest
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          tag_name: ${{ steps.daily-version.outputs.version }}
          release_name: Release ${{ steps.daily-version.outputs.version }}
          body: ${{ steps.changelog.outputs.changes }}
