diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml index 41645d3..79fa3c1 100644 --- a/.gitea/workflows/ci.yaml +++ b/.gitea/workflows/ci.yaml @@ -113,12 +113,46 @@ jobs: tar -czvf ps.ipam-${{ github.ref_name }}.tar.gz ps.ipam/ - name: Create Gitea Release - uses: actions/gitea-release-action@v1 - with: - token: ${{ secrets.TOKEN }} - files: | - ps.ipam-${{ github.ref_name }}.zip - ps.ipam-${{ github.ref_name }}.tar.gz - title: Release ${{ github.ref_name }} - draft: false - prerelease: ${{ contains(github.ref_name, '-') }} + env: + GITEA_TOKEN: ${{ secrets.TOKEN }} + run: | + # Determine if this is a prerelease (contains hyphen like v1.0.0-beta) + PRERELEASE=false + if [[ "${{ github.ref_name }}" == *-* ]]; then + PRERELEASE=true + fi + + # Create the release + RELEASE_RESPONSE=$(curl -s -X POST \ + -H "Authorization: token ${GITEA_TOKEN}" \ + -H "Content-Type: application/json" \ + -d "{\"tag_name\": \"${{ github.ref_name }}\", \"name\": \"Release ${{ github.ref_name }}\", \"body\": \"Release ${{ github.ref_name }}\", \"draft\": false, \"prerelease\": ${PRERELEASE}}" \ + "${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases") + + echo "Release response: ${RELEASE_RESPONSE}" + + # Extract release ID + RELEASE_ID=$(echo "${RELEASE_RESPONSE}" | jq -r '.id') + + if [ "${RELEASE_ID}" == "null" ] || [ -z "${RELEASE_ID}" ]; then + echo "Failed to create release" + exit 1 + fi + + echo "Created release with ID: ${RELEASE_ID}" + + # Upload ZIP attachment + curl -s -X POST \ + -H "Authorization: token ${GITEA_TOKEN}" \ + -H "Content-Type: multipart/form-data" \ + -F "attachment=@ps.ipam-${{ github.ref_name }}.zip" \ + "${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases/${RELEASE_ID}/assets" + + # Upload tar.gz attachment + curl -s -X POST \ + -H "Authorization: token ${GITEA_TOKEN}" \ + -H "Content-Type: multipart/form-data" \ + -F "attachment=@ps.ipam-${{ github.ref_name }}.tar.gz" \ + "${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases/${RELEASE_ID}/assets" + + echo "Release created successfully with attachments"