# Test changes locally with https://github.com/nektos/act
name: dotnet-release

# TODO
# - Allow workflows to be driven by the project(s)

on:
  push:
    branches: [ main, develop ]
    paths-ignore:
    - ".github/**/*.*"
    - "**/*.md"
    - "**/*.txt"

jobs:
  ci:
    name: CI # run test.yml. If it fails, this job fails.
    uses: ./.github/workflows/ci.yml # <- your CI workflow here. Example: 'file://./ci.yml'
  release:
    needs: [ci] # start 'release' if 'ci' completes successfully
    runs-on: ubuntu-latest
    permissions:
      contents: write
      issues: write
      pull-requests: write
    steps:
    ################
    # SETUP
    ################
    - uses: actions/checkout@v4
      with:
        fetch-depth: 0 # Required by GitVersion, Semantic Release
        submodules: "recursive" # submodule fetch depth unknown
    - uses: actions/setup-dotnet@v4
    - uses: actions/setup-node@v4
    - run: npm install -g npm@latest
    - run: npm ci # Required by Semantic Release

    ################
    # RELEASE
    # @semantic-release/exec should be configured to execute
    # `dotnet publish`, `dotnet pack`, and `dotnet nuget push`
    # You can use this package's semanticReleaseConfigDotnet exports to do so.
    ################
    # https://github.com/semantic-release/semantic-release
    - name: Semantic Release
      run: npx semantic-release
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        NUGET_TOKEN: ${{ secrets.NUGET_TOKEN }}