name: tag
on:
  push:
    tags:
      # this is a glob, not a regexp
      - '[0-9]*'
jobs:
  release:
    runs-on: ubuntu-latest
    permissions:
      # create release
      contents: write
    env:
      GH_TOKEN: ${{ github.token }}
    steps:
      - name: Clone repository
        uses: actions/checkout@v5
        with:
          # need this to also fetch tags
          fetch-depth: 0

      - name: Workaround for https://github.com/actions/checkout/pull/697
        run: git fetch --force origin $(git describe --tags):refs/tags/$(git describe --tags)

      - name: Build release tarball
        # run as root; current Ubuntu podman breaks user networking ("could not find slirp4netns")
        run: sudo PUBLISH_TAR=1 tests/run-apt

      - name: Create GitHub release
        run: |
          VERSION="${{ github.ref_name }}"
          git tag -l --format='%(contents:body)' $VERSION > release-note.txt

          gh release create --title $VERSION --notes-file release-note.txt $VERSION \
            "umockdev-${VERSION}.tar.xz"
