name: Automatically publish to Modrinth and CurseForge
on:
  release:
    types: [published]
jobs:
  publish-to-curseforge:
    if: github.repository_owner == 'Fabulously-Optimized'
    runs-on: ubuntu-22.04
    environment: github-actions
    steps:
       - name: Download the pack files
         uses: robinraju/release-downloader@v1.8
         id: download-files
         with:
           fileName: "*.zip"
           latest: true
           tarBall: false
           zipBall: false

       - name: Publish to CurseForge
         uses: Kir-Antipov/mc-publish@v3.3
         with:
           name: ${{ steps.download-files.outputs.tag_name }} for ${{ vars.MC_VERSION }}
           curseforge-id: 396246
           curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}
           curseforge-files: '*.zip'
           loaders: fabric
           game-versions: ${{ vars.MC_VERSION }}
           
  publish-to-modrinth:
    if: github.repository_owner == 'Fabulously-Optimized'
    runs-on: ubuntu-22.04
    environment: github-actions
    steps:
       - name: Download the pack files
         uses: robinraju/release-downloader@v1.8
         id: download-files
         with:
           fileName: "*.mrpack"
           latest: true
           tarBall: false
           zipBall: false
           
       - name: Publish to Modrinth
         uses: Kir-Antipov/mc-publish@v3.3
         with:
           name: ${{ steps.download-files.outputs.tag_name }} for ${{ vars.MC_VERSION }}
           modrinth-id: 1KVo5zza
           modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
           modrinth-unfeature-mode: subset
           files: '*.mrpack'
           loaders: fabric
           game-versions: ${{ vars.MC_VERSION }}
