🏡 index : quine-global-labs/mirror-get-aurora-dev-common.git

name: Monthly Release

on:
  schedule:
    # Run on the 1st of every month at 00:00 UTC
    - cron: '0 1 1 * *'
  workflow_dispatch:

permissions:
  contents: write

jobs:
  release:
    name: Create monthly snapshot release
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          fetch-depth: 0

      - name: Generate release tag
        id: tag
        run: |
          TAG="v$(date +'%Y.%m')"
          echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
          echo "Release tag: ${TAG}"

      - name: Generate release notes
        id: notes
        run: |
          TAG="${{ steps.tag.outputs.tag }}"
          PREVIOUS_TAG=$(git tag --sort=-version:refname | head -n1)

          if [ -z "$PREVIOUS_TAG" ]; then
            echo "First release - no previous tag found"
            cat >> "$GITHUB_OUTPUT" <<EOF
          notes<<NOTES_EOF
          Monthly snapshot release ${TAG}

          This is an automated monthly snapshot of aurora-common configuration files.
          NOTES_EOF
          EOF
          else
            echo "Generating notes since ${PREVIOUS_TAG}"
            cat >> "$GITHUB_OUTPUT" <<EOF
          notes<<NOTES_EOF
          Monthly snapshot release ${TAG}

          ## Changes since ${PREVIOUS_TAG}

          $(git log "${PREVIOUS_TAG}..HEAD" --pretty=format:'- %s (%h)' --no-merges)

          ---
          *This is an automated monthly snapshot of aurora-common configuration files.*
          NOTES_EOF
          EOF
          fi

      - name: Create Release
        uses: ncipollo/release-action@339a81892b84b4eeb0f6e744e4574d79d0d9b8dd # v1.21.0
        with:
          tag: ${{ steps.tag.outputs.tag }}
          name: ${{ steps.tag.outputs.tag }}
          body: ${{ steps.notes.outputs.notes }}
          draft: false
          prerelease: false
          makeLatest: true