#!/usr/bin/env bash # Creates a (draft) Gitea Release for the tag that triggered # .gitea/workflows/release.yml, and uploads every archive in $DIST_DIR as a # release asset. Draft because nobody has run this plugin in the OBS GUI on # any platform yet -- a human still opens it and clicks Publish once that's # no longer true (or once they're satisfied regardless). # # Required env: GITEA_TOKEN, SERVER, OWNER, REPO, TAG, SHA, DIST_DIR # Optional env: MACOS_BUNDLE_FOUND ("true"/"false", default "false") set -euo pipefail : "${GITEA_TOKEN:?}" : "${SERVER:?}" : "${OWNER:?}" : "${REPO:?}" : "${TAG:?}" : "${SHA:?}" : "${DIST_DIR:?}" MACOS_BUNDLE_FOUND="${MACOS_BUNDLE_FOUND:-false}" if [ "${MACOS_BUNDLE_FOUND}" = "true" ]; then MACOS_NOTE="This archive contains a \`.plugin\` bundle." else MACOS_NOTE="This archive is packaged as a bare \`streamer-tools-camera.so\` (the layout \`build/package/\` currently produces on macOS), **not** an OBS.app-loadable \`.plugin\` bundle. It will not load in the OBS GUI as-is -- see the \"macOS packaging gap\" section of \`README.md\`." fi NOTES_FILE="$(mktemp)" cat > "${NOTES_FILE}" < \`+\` -> "streamer-tools Camera" -> fill in the server URL, room slug and read key from the room's settings page -> "Refresh camera list" -> pick a camera. ## What this is Native OBS Studio source plugin that pulls streamer-tools camera feeds directly from LiveKit over WebRTC. See \`README.md\` in the repository for the full design, what is and is not verified, and current CI status. EOF echo "----- release notes -----" cat "${NOTES_FILE}" echo "--------------------------" BODY_JSON="$(python3 - "$TAG" "$NOTES_FILE" <<'PYEOF' import json, sys tag, notes_file = sys.argv[1], sys.argv[2] with open(notes_file) as f: notes = f.read() print(json.dumps({ "tag_name": tag, "name": tag, "body": notes, "draft": True, "prerelease": False, })) PYEOF )" echo "Creating release for tag ${TAG} ..." RESP="$(curl -sS -f -X POST \ -H "Authorization: token ${GITEA_TOKEN}" \ -H "Content-Type: application/json" \ -d "${BODY_JSON}" \ "${SERVER}/api/v1/repos/${OWNER}/${REPO}/releases")" RELEASE_ID="$(python3 -c 'import json,sys; print(json.load(sys.stdin)["id"])' <<<"${RESP}")" echo "Created release id ${RELEASE_ID} (draft)." shopt -s nullglob ASSETS=("${DIST_DIR}"/*) if [ "${#ASSETS[@]}" -eq 0 ]; then echo "::error::no archives found in ${DIST_DIR} -- nothing to upload." exit 1 fi for f in "${ASSETS[@]}"; do name="$(basename "${f}")" echo "Uploading ${name} ..." curl -sS -f -X POST \ -H "Authorization: token ${GITEA_TOKEN}" \ -F "attachment=@${f}" \ "${SERVER}/api/v1/repos/${OWNER}/${REPO}/releases/${RELEASE_ID}/assets?name=${name}" \ > /dev/null done echo "Done. Draft release: ${SERVER}/${OWNER}/${REPO}/releases/${RELEASE_ID}"