name: pk4

on: [ push, pull_request, workflow_dispatch ]

jobs:
  build:
    runs-on: docker

    steps:
    - uses: actions/checkout@v3
      with:
        fetch-depth: 1
        repository: vera/nuclide
        ref: Develop

    - uses: actions/checkout@v3
      with:
        fetch-depth: 1
        ref: Develop
        path: "./${{ github.event.repository.name }}"

    - name: apt install zip
      run: |
        apt update
        apt install -y \
        zip

    - name: assemble pk4
      run: make dist-pak NAME=bin GAME=${{ github.event.repository.name }}

    - uses: actions/upload-artifact@v3
      with:
        name: build-log
        path: ./build/bin-content.log

    - uses: actions/forgejo-release@v2
      with:
        url: https://code.idtech.space
        repo: "${{ github.repository }}"
        tag: "${{ github.ref_name }}"
        sha: "${{ github.sha }}"
        direction: upload
        release-dir: ./build/bin-content/${{ github.event.repository.name }}/
        token: ${{ secrets.TOKEN }}
        title: "Development Build"
        release-notes: "Auto-generated development build, override ${{ github.event.repository.name }}/package_${{ github.event.repository.name }}.pk4."
        prerelease: true
        override: true
        release-notes-assistant: true
