diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index f964e4a..d0113a5 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -10,12 +10,20 @@ jobs: runs-on: ubuntu-latest steps: - name: Create Gitea Release + # Idempotent: a re-fired tag finds its release already present and + # says so instead of failing on the 409. run: | + api="${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases" + auth='Authorization: token ${{ secrets.GITHUB_TOKEN }}' + if curl -sf -H "$auth" "$api/tags/${{ github.ref_name }}" > /dev/null; then + echo "release for ${{ github.ref_name }} already exists — nothing to do" + exit 0 + fi curl -sf -X POST \ - -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + -H "$auth" \ -H "Content-Type: application/json" \ -d '{"tag_name": "${{ github.ref_name }}", "name": "Release ${{ github.ref_name }}", "body": "Automated release for ${{ github.ref_name }}"}' \ - "${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases" + "$api" build: runs-on: ubuntu-latest