name: AUR Publish

on:
  push:
    tags:
      - 'v*'

jobs:
  aur-publish-fips:
    name: Publish fips to AUR
    runs-on: ubuntu-latest
    continue-on-error: true
    if: "!contains(github.ref_name, '-')"

    steps:
      - uses: actions/checkout@v4

      - name: Update pkgver in PKGBUILD
        run: |
          VERSION="${GITHUB_REF_NAME#v}"
          sed -i "s/^pkgver=.*/pkgver=${VERSION}/" packaging/aur/PKGBUILD

      - name: Publish to AUR
        uses: KSXGitHub/github-actions-deploy-aur@v4.1.1
        with:
          pkgname: fips
          pkgbuild: packaging/aur/PKGBUILD
          updpkgsums: true
          assets: |
            packaging/aur/fips.sysusers
            packaging/aur/fips.tmpfiles
            packaging/aur/fips.install
          commit_username: ${{ github.repository_owner }}
          commit_email: ${{ secrets.AUR_EMAIL }}
          ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
          commit_message: "Update to ${{ github.ref_name }}"
