name: changelog-assembly

on:
  workflow_dispatch:
    inputs:
      release:
        description: Release type
        required: true
        default: patch
        type: choice
        options:
          - major
          - minor
          - patch

permissions:
  contents: write
  pull-requests: write

jobs:
  ronlog:
    if: contains(fromJson('["major", "minor", "patch"]'), inputs.release)
    name: ronlog
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3.5.2
      - uses: fregante/setup-git-user@v2.0.1
      - run: rustup update

      - uses: baptiste0928/cargo-install@v2.1.0
        with:
          crate: aeruginous

      - run: |
          aeruginous increment-version \
            -v "$(cat .version)" \
            -r ${{ inputs.release }} \
            -p tui-journal \
            -e .version \
            -e CITATION.cff \
            -e Cargo.lock \
            -e Cargo.toml
          aeruginous cff-release-today CITATION.cff
          aeruginous ronlog release -i changelog.d/ -v "$(cat .version)"

      - uses: peter-evans/create-pull-request@v5.0.2
        with:
          assignees: |
            AmmarAbouZor
          branch: documentation/aeruginous-ronlog
          branch-suffix: timestamp
          commit-message: '[Aeruginous] Assemble CHANGELOG'
          labels: |
            documentation
          title: '[Aeruginous] Assemble CHANGELOG'
