name: Publish latest Infix

on:
  workflow_dispatch:
  workflow_call:

jobs:
  publish:
    name: Upload Latest Build
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - uses: actions/download-artifact@v4
        with:
          pattern: "artifact-*"
          merge-multiple: true

      - name: Create checksums ...
        run: |
          for file in *.tar.gz; do
              sha256sum $file > $file.sha256
          done

      - uses: ncipollo/release-action@v1
        with:
          allowUpdates: true
          omitName: true
          omitBody: true
          omitBodyDuringUpdate: true
          prerelease: true
          tag: "latest"
          token: ${{ secrets.GITHUB_TOKEN }}
          artifacts: "*.tar.gz*"

      - name: Summary
        run: |
          cat <<EOF >> $GITHUB_STEP_SUMMARY
          # Latest Build Complete! :rocket:

          For the public download links of these build artifacts, please see:
           <https://github.com/kernelkit/infix/releases/tag/latest>
          EOF
