diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index fcd7571..f45ce3a 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -22,9 +22,26 @@ jobs: VERSION=$(grep -A1 'version' info.plist | grep '' | sed 's/.*//;s/<\/string>.*//') echo "version=${VERSION}" >> "$GITHUB_OUTPUT" - - name: Create release - uses: softprops/action-gh-release@v2 - with: - tag_name: v${{ steps.version.outputs.version }} - name: v${{ steps.version.outputs.version }} - files: dist/tmux-cheat-sheet.alfredworkflow + - name: Create release and upload artifact + env: + VERSION: v${{ steps.version.outputs.version }} + run: | + API="${GITHUB_SERVER_URL}/api/v1" + REPO="${GITHUB_REPOSITORY}" + AUTH="Authorization: token ${GITHUB_TOKEN}" + + # delete existing release for this tag (idempotent) + EXISTING=$(curl -sf -H "$AUTH" "$API/repos/$REPO/releases/tags/$VERSION" | jq -r '.id // empty') || true + if [ -n "$EXISTING" ]; then + curl -sf -X DELETE -H "$AUTH" "$API/repos/$REPO/releases/$EXISTING" + fi + + # create release + RELEASE_ID=$(curl -sf -X POST -H "$AUTH" -H "Content-Type: application/json" \ + -d "{\"tag_name\":\"$VERSION\",\"name\":\"$VERSION\",\"body\":\"Automated build from main\"}" \ + "$API/repos/$REPO/releases" | jq -r '.id') + + # upload artifact + curl -sf -X POST -H "$AUTH" \ + -F "attachment=@dist/tmux-cheat-sheet.alfredworkflow" \ + "$API/repos/$REPO/releases/$RELEASE_ID/assets?name=tmux-cheat-sheet.alfredworkflow"