From da69d8bd4fa627458752ac7b0ed252129b0f119d Mon Sep 17 00:00:00 2001 From: Michael Freno Date: Sat, 6 Dec 2025 14:19:00 -0500 Subject: [PATCH] setup for luarocks releases --- RELEASE.md | 51 ++++++++++++++++++-- flexlove-0.5.4-1.rockspec | 76 ++++++++++++++++++++++++++++++ modules/Renderer.lua | 4 +- modules/TextEditor.lua | 3 +- modules/UTF8.lua | 44 +++++++++++++++++ scripts/create-profile-packages.sh | 8 ++-- scripts/make-tag.sh | 63 +++++++++++++++++++++---- 7 files changed, 230 insertions(+), 19 deletions(-) create mode 100644 flexlove-0.5.4-1.rockspec create mode 100644 modules/UTF8.lua diff --git a/RELEASE.md b/RELEASE.md index b4f2fab..88bd156 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -15,10 +15,11 @@ This interactive script will: 2. Ask you to select: Major / Minor / Patch / Custom version bump 3. Calculate the new version (resetting lower components to 0) 4. Update `FlexLove.lua` with the new version -5. Update `README.md` first line with the new version -6. Create a git commit: `v{version} release` -7. Create a git tag: `v{version}` -8. Prompt you to push the changes +5. Update `docs/index.html` footer version +6. Create/update rockspec file: `flexlove-{version}-1.rockspec` +7. Create a git commit: `v{version} release` +8. Create a git tag: `v{version}` +9. Push changes and tag to GitHub After pushing the tag, GitHub Actions automatically: - Archives previous documentation @@ -26,6 +27,8 @@ After pushing the tag, GitHub Actions automatically: - Creates 4 build profile packages (minimal, slim, default, full) with SHA256 checksums - Publishes GitHub release with all profile packages +The script will display next steps for publishing to LuaRocks (see [LUAROCKS_PUBLISHING.md](LUAROCKS_PUBLISHING.md)). + ### Example Usage ```bash @@ -124,6 +127,7 @@ shasum -a 256 -c flexlove-*-v0.3.0.zip.sha256 ## Release Checklist - [ ] Version updated in `FlexLove.lua` +- [ ] Rockspec created/updated (automated by `make-tag.sh`) - [ ] Documentation regenerated (`./scripts/generate_docs.sh`) - [ ] Changes committed and pushed - [ ] Profile packages created (`./scripts/create-profile-packages.sh`) @@ -131,6 +135,7 @@ shasum -a 256 -c flexlove-*-v0.3.0.zip.sha256 - [ ] All profile packages tested - [ ] Git tag created and pushed - [ ] GitHub release published with all 4 profile packages and checksums +- [ ] Published to LuaRocks (`luarocks upload flexlove-{version}-1.rockspec`) ## Versioning @@ -211,6 +216,43 @@ unzip flexlove-default-v0.3.0.zip **macOS/Linux:** Use `shasum -a 256 -c` **Windows:** Use `certutil -hashfile flexlove--v0.3.0.zip SHA256` and compare manually +## Publishing to LuaRocks + +After creating a GitHub release, publish to LuaRocks for easy installation: + +### First-Time Setup + +1. Create a LuaRocks account at [https://luarocks.org/register](https://luarocks.org/register) +2. Get your API key from [https://luarocks.org/settings/api-keys](https://luarocks.org/settings/api-keys) +3. Configure it locally: + ```bash + luarocks config api-key YOUR_API_KEY_HERE + ``` + +### Publishing a Release + +The `make-tag.sh` script automatically creates the rockspec file. After the tag is pushed: + +```bash +# Upload to LuaRocks +luarocks upload flexlove-{version}-1.rockspec + +# Example for version 0.5.5: +luarocks upload flexlove-0.5.5-1.rockspec +``` + +### Verifying Publication + +```bash +# Search for your package +luarocks search flexlove + +# Test installation +luarocks install flexlove +``` + +For detailed instructions, see [LUAROCKS_PUBLISHING.md](LUAROCKS_PUBLISHING.md). + ## Automated Releases (Future) Consider adding GitHub Actions workflow to automate: @@ -218,5 +260,6 @@ Consider adding GitHub Actions workflow to automate: - Release package creation - Documentation deployment - GitHub release creation +- LuaRocks publishing See `.github/workflows/release.yml` (to be created) diff --git a/flexlove-0.5.4-1.rockspec b/flexlove-0.5.4-1.rockspec new file mode 100644 index 0000000..8839414 --- /dev/null +++ b/flexlove-0.5.4-1.rockspec @@ -0,0 +1,76 @@ +package = "flexlove" +version = "0.5.4-1" + +source = { + url = "git+https://github.com/mikefreno/FlexLove.git", + tag = "v0.5.4", +} + +description = { + summary = "A comprehensive UI library providing flexbox/grid layouts, theming, animations, and event handling for LÖVE2D games", + detailed = [[ + FlexLöve is a lightweight, flexible GUI library for LÖVE2D that implements a + flexbox-based layout system. The goals of this project are two-fold: first, + anyone with basic CSS knowledge should be able to use this library with minimal + learning curve. Second, this library should take you from early prototyping to + production. + + Features: + - Flexbox and Grid Layout systems + - Modern theming with 9-patch support + - Animations and transitions + - Image rendering with CSS-like object-fit + - Touch events and gesture recognition + - Text input with rich editing features + - Responsive design with viewport units + - Both immediate and retained rendering modes + ]], + homepage = "https://mikefreno.github.io/FlexLove/", + license = "MIT", + maintainer = "Mike Freno", +} + +dependencies = { + "lua >= 5.1", + "luautf8 >= 0.1.3" +} + +build = { + type = "builtin", + modules = { + ["FlexLove"] = "FlexLove.lua", + ["FlexLove.modules.Animation"] = "modules/Animation.lua", + ["FlexLove.modules.Blur"] = "modules/Blur.lua", + ["FlexLove.modules.Color"] = "modules/Color.lua", + ["FlexLove.modules.Context"] = "modules/Context.lua", + ["FlexLove.modules.Element"] = "modules/Element.lua", + ["FlexLove.modules.ErrorHandler"] = "modules/ErrorHandler.lua", + ["FlexLove.modules.EventHandler"] = "modules/EventHandler.lua", + ["FlexLove.modules.FFI"] = "modules/FFI.lua", + ["FlexLove.modules.GestureRecognizer"] = "modules/GestureRecognizer.lua", + ["FlexLove.modules.Grid"] = "modules/Grid.lua", + ["FlexLove.modules.ImageCache"] = "modules/ImageCache.lua", + ["FlexLove.modules.ImageRenderer"] = "modules/ImageRenderer.lua", + ["FlexLove.modules.ImageScaler"] = "modules/ImageScaler.lua", + ["FlexLove.modules.InputEvent"] = "modules/InputEvent.lua", + ["FlexLove.modules.LayoutEngine"] = "modules/LayoutEngine.lua", + ["FlexLove.modules.MemoryScanner"] = "modules/MemoryScanner.lua", + ["FlexLove.modules.ModuleLoader"] = "modules/ModuleLoader.lua", + ["FlexLove.modules.NinePatch"] = "modules/NinePatch.lua", + ["FlexLove.modules.Performance"] = "modules/Performance.lua", + ["FlexLove.modules.Renderer"] = "modules/Renderer.lua", + ["FlexLove.modules.RoundedRect"] = "modules/RoundedRect.lua", + ["FlexLove.modules.ScrollManager"] = "modules/ScrollManager.lua", + ["FlexLove.modules.StateManager"] = "modules/StateManager.lua", + ["FlexLove.modules.TextEditor"] = "modules/TextEditor.lua", + ["FlexLove.modules.Theme"] = "modules/Theme.lua", + ["FlexLove.modules.types"] = "modules/types.lua", + ["FlexLove.modules.Units"] = "modules/Units.lua", + ["FlexLove.modules.UTF8"] = "modules/UTF8.lua", + ["FlexLove.modules.utils"] = "modules/utils.lua" + }, + copy_directories = { + "docs", + "examples", + }, +} diff --git a/modules/Renderer.lua b/modules/Renderer.lua index ff48fc1..bf7022d 100644 --- a/modules/Renderer.lua +++ b/modules/Renderer.lua @@ -1,3 +1,5 @@ +local UTF8 = require((...):match("(.-)[^%.]+$") .. "UTF8") + ---@class Renderer ---@field backgroundColor Color ---@field borderColor Color @@ -463,7 +465,7 @@ end ---@return table Array of {text, startIdx, endIdx} function Renderer:wrapLine(element, line, maxWidth) -- UTF-8 support - local utf8 = utf8 or require("utf8") + local utf8 = UTF8 if not element.editable then return { { text = line, startIdx = 0, endIdx = utf8.len(line) } } diff --git a/modules/TextEditor.lua b/modules/TextEditor.lua index e62683b..58daee4 100644 --- a/modules/TextEditor.lua +++ b/modules/TextEditor.lua @@ -1,4 +1,5 @@ -local utf8 = utf8 or require("utf8") +local UTF8 = require((...):match("(.-)[^%.]+$") .. "UTF8") +local utf8 = UTF8 ---@class TextEditor ---@field editable boolean diff --git a/modules/UTF8.lua b/modules/UTF8.lua new file mode 100644 index 0000000..618f1c7 --- /dev/null +++ b/modules/UTF8.lua @@ -0,0 +1,44 @@ +---@class UTF8 +---Compatibility layer for UTF-8 support across Lua versions +---Handles utf8 (Lua 5.3+), lua-utf8 (LuaRocks), and basic fallbacks + +local UTF8 = {} + +-- Try to load UTF-8 library in order of preference: +-- 1. Built-in utf8 (Lua 5.3+, LÖVE2D) +-- 2. lua-utf8 from LuaRocks (Lua 5.1, 5.2) +-- 3. Error if neither available +local function loadUTF8() + -- Try built-in utf8 first (Lua 5.3+ and LÖVE2D) + if utf8 and type(utf8) == "table" and utf8.len then + return utf8 + end + + -- Try lua-utf8 from LuaRocks + local ok, luautf8 = pcall(require, "lua-utf8") + if ok then + return luautf8 + end + + -- Try standard utf8 module name as fallback + ok, luautf8 = pcall(require, "utf8") + if ok then + return luautf8 + end + + -- No UTF-8 library available + error("No UTF-8 library available. Please install 'luautf8' via LuaRocks: luarocks install luautf8") +end + +-- Load the UTF-8 implementation +local utf8lib = loadUTF8() + +-- Export all utf8 functions +UTF8.char = utf8lib.char +UTF8.charpattern = utf8lib.charpattern +UTF8.codes = utf8lib.codes +UTF8.codepoint = utf8lib.codepoint +UTF8.len = utf8lib.len +UTF8.offset = utf8lib.offset + +return UTF8 diff --git a/scripts/create-profile-packages.sh b/scripts/create-profile-packages.sh index 524f9bf..b5d2371 100755 --- a/scripts/create-profile-packages.sh +++ b/scripts/create-profile-packages.sh @@ -55,16 +55,16 @@ get_description() { get_modules() { case "$1" in minimal) - echo "utils.lua Units.lua Context.lua StateManager.lua ErrorHandler.lua Color.lua InputEvent.lua TextEditor.lua LayoutEngine.lua Renderer.lua EventHandler.lua ScrollManager.lua Element.lua RoundedRect.lua Grid.lua ModuleLoader.lua types.lua FFI.lua" + echo "utils.lua Units.lua Context.lua StateManager.lua ErrorHandler.lua Color.lua InputEvent.lua TextEditor.lua LayoutEngine.lua Renderer.lua EventHandler.lua ScrollManager.lua Element.lua RoundedRect.lua Grid.lua ModuleLoader.lua types.lua FFI.lua UTF8.lua" ;; slim) - echo "utils.lua Units.lua Context.lua StateManager.lua ErrorHandler.lua Color.lua InputEvent.lua TextEditor.lua LayoutEngine.lua Renderer.lua EventHandler.lua ScrollManager.lua Element.lua RoundedRect.lua Grid.lua ModuleLoader.lua types.lua FFI.lua Animation.lua NinePatch.lua ImageRenderer.lua ImageScaler.lua ImageCache.lua" + echo "utils.lua Units.lua Context.lua StateManager.lua ErrorHandler.lua Color.lua InputEvent.lua TextEditor.lua LayoutEngine.lua Renderer.lua EventHandler.lua ScrollManager.lua Element.lua RoundedRect.lua Grid.lua ModuleLoader.lua types.lua FFI.lua UTF8.lua Animation.lua NinePatch.lua ImageRenderer.lua ImageScaler.lua ImageCache.lua" ;; default) - echo "utils.lua Units.lua Context.lua StateManager.lua ErrorHandler.lua Color.lua InputEvent.lua TextEditor.lua LayoutEngine.lua Renderer.lua EventHandler.lua ScrollManager.lua Element.lua RoundedRect.lua Grid.lua ModuleLoader.lua types.lua FFI.lua Animation.lua NinePatch.lua ImageRenderer.lua ImageScaler.lua ImageCache.lua Theme.lua Blur.lua GestureRecognizer.lua" + echo "utils.lua Units.lua Context.lua StateManager.lua ErrorHandler.lua Color.lua InputEvent.lua TextEditor.lua LayoutEngine.lua Renderer.lua EventHandler.lua ScrollManager.lua Element.lua RoundedRect.lua Grid.lua ModuleLoader.lua types.lua FFI.lua UTF8.lua Animation.lua NinePatch.lua ImageRenderer.lua ImageScaler.lua ImageCache.lua Theme.lua Blur.lua GestureRecognizer.lua" ;; full) - echo "utils.lua Units.lua Context.lua StateManager.lua ErrorHandler.lua Color.lua InputEvent.lua TextEditor.lua LayoutEngine.lua Renderer.lua EventHandler.lua ScrollManager.lua Element.lua RoundedRect.lua Grid.lua ModuleLoader.lua types.lua FFI.lua Animation.lua NinePatch.lua ImageRenderer.lua ImageScaler.lua ImageCache.lua Theme.lua Blur.lua GestureRecognizer.lua Performance.lua MemoryScanner.lua" + echo "utils.lua Units.lua Context.lua StateManager.lua ErrorHandler.lua Color.lua InputEvent.lua TextEditor.lua LayoutEngine.lua Renderer.lua EventHandler.lua ScrollManager.lua Element.lua RoundedRect.lua Grid.lua ModuleLoader.lua types.lua FFI.lua UTF8.lua Animation.lua NinePatch.lua ImageRenderer.lua ImageScaler.lua ImageCache.lua Theme.lua Blur.lua GestureRecognizer.lua Performance.lua MemoryScanner.lua" ;; esac } diff --git a/scripts/make-tag.sh b/scripts/make-tag.sh index e39c4ae..3028e6d 100755 --- a/scripts/make-tag.sh +++ b/scripts/make-tag.sh @@ -113,8 +113,9 @@ echo "" echo -e "${YELLOW}This will:${NC}" echo " 1. Update FlexLove.lua → flexlove._VERSION = \"${NEW_VERSION}\"" echo " 2. Update docs/index.html → footer version" -echo " 3. Stage changes for commit" -echo " 4. Create git tag v${NEW_VERSION}" +echo " 3. Create/update rockspec → flexlove-${NEW_VERSION}-1.rockspec" +echo " 4. Stage changes for commit" +echo " 5. Create git tag v${NEW_VERSION}" echo "" read -p "Proceed? (y/n) " -n 1 -r echo "" @@ -124,12 +125,12 @@ if [[ ! $REPLY =~ ^[Yy]$ ]]; then fi echo "" -echo -e "${CYAN}[1/3]${NC} Updating FlexLove.lua..." +echo -e "${CYAN}[1/4]${NC} Updating FlexLove.lua..." sed -i.bak "s/flexlove\._VERSION = \".*\"/flexlove._VERSION = \"${NEW_VERSION}\"/" FlexLove.lua rm -f FlexLove.lua.bak echo -e "${GREEN}✓ FlexLove.lua updated${NC}" -echo -e "${CYAN}[2/3]${NC} Updating docs/index.html..." +echo -e "${CYAN}[2/4]${NC} Updating docs/index.html..." if [ -f docs/index.html ]; then sed -i.bak -E "s/FlexLöve v[0-9]+\.[0-9]+\.[0-9]+/FlexLöve v${NEW_VERSION}/" docs/index.html rm -f docs/index.html.bak @@ -138,8 +139,31 @@ else echo -e "${YELLOW}⚠ docs/index.html not found, skipping${NC}" fi -echo -e "${CYAN}[3/3]${NC} Staging changes..." -git add FlexLove.lua docs/index.html +echo -e "${CYAN}[3/4]${NC} Creating/updating rockspec..." +# Find the most recent rockspec to use as template +LATEST_ROCKSPEC=$(ls -1 flexlove-*.rockspec 2>/dev/null | sort -V | tail -n 1) +NEW_ROCKSPEC="flexlove-${NEW_VERSION}-1.rockspec" + +if [ -n "$LATEST_ROCKSPEC" ] && [ -f "$LATEST_ROCKSPEC" ]; then + # Copy existing rockspec and update version/tag + cp "$LATEST_ROCKSPEC" "$NEW_ROCKSPEC" + # Update version line + sed -i.bak "s/^version = \".*\"/version = \"${NEW_VERSION}-1\"/" "$NEW_ROCKSPEC" + # Update tag line + sed -i.bak "s/tag = \"v.*\"/tag = \"v${NEW_VERSION}\"/" "$NEW_ROCKSPEC" + rm -f "${NEW_ROCKSPEC}.bak" + echo -e "${GREEN}✓ Created ${NEW_ROCKSPEC} from ${LATEST_ROCKSPEC}${NC}" +else + echo -e "${YELLOW}⚠ No existing rockspec found, skipping rockspec creation${NC}" + echo -e "${YELLOW} You can manually create one later or run this script again${NC}" +fi + +echo -e "${CYAN}[4/4]${NC} Staging changes..." +if [ -f "$NEW_ROCKSPEC" ]; then + git add FlexLove.lua docs/index.html "$NEW_ROCKSPEC" +else + git add FlexLove.lua docs/index.html +fi echo -e "${GREEN}✓ Changes staged${NC}" echo "" @@ -158,7 +182,11 @@ if [[ ! $REPLY =~ ^[Yy]$ ]]; then echo "You can:" echo " - Review changes: git diff --cached" echo " - Commit manually: git commit -m 'v${NEW_VERSION} release'" - echo " - Unstage: git restore --staged FlexLove.lua docs/index.html" + if [ -f "$NEW_ROCKSPEC" ]; then + echo " - Unstage: git restore --staged FlexLove.lua docs/index.html ${NEW_ROCKSPEC}" + else + echo " - Unstage: git restore --staged FlexLove.lua docs/index.html" + fi exit 0 fi @@ -186,13 +214,17 @@ if [[ ! $REPLY =~ ^[Yy]$ ]]; then echo "You can:" echo " - Review changes: git diff --cached" echo " - Commit manually: git commit -m 'v${NEW_VERSION} release'" - echo " - Unstage: git restore --staged FlexLove.lua docs/index.html" + if [ -f "$NEW_ROCKSPEC" ]; then + echo " - Unstage: git restore --staged FlexLove.lua docs/index.html ${NEW_ROCKSPEC}" + else + echo " - Unstage: git restore --staged FlexLove.lua docs/index.html" + fi exit 0 fi # Commit changes echo "" -echo -e "${CYAN}[4/4]${NC} Committing and tagging..." +echo -e "${CYAN}[5/5]${NC} Committing and tagging..." git commit -m "$COMMIT_MSG" git tag -a "v${NEW_VERSION}" -m "Release version ${NEW_VERSION}" @@ -254,7 +286,20 @@ echo -e "${GREEN}═════════════════════ echo "" echo -e "${CYAN}Version:${NC} ${CURRENT_VERSION} → ${GREEN}${NEW_VERSION}${NC}" echo -e "${CYAN}Tag created:${NC} ${GREEN}v${NEW_VERSION}${NC}" +if [ -f "$NEW_ROCKSPEC" ]; then + echo -e "${CYAN}Rockspec:${NC} ${GREEN}${NEW_ROCKSPEC}${NC}" +fi echo "" echo -e "${BLUE}Release will be available at:${NC}" echo " https://github.com/$(git remote get-url origin | sed 's/.*github.com[:/]\(.*\)\.git/\1/')/releases/tag/v${NEW_VERSION}" echo "" +if [ -f "$NEW_ROCKSPEC" ]; then + echo -e "${BLUE}Next steps for LuaRocks publishing:${NC}" + echo " 1. Wait for GitHub Actions to complete" + echo " 2. Upload to LuaRocks:" + echo " ${CYAN}luarocks upload ${NEW_ROCKSPEC}${NC}" + echo "" + echo -e "${YELLOW}Note: Ensure you have your LuaRocks API key configured${NC}" + echo " ${CYAN}luarocks config api-key YOUR_API_KEY${NC}" + echo "" +fi