mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-20 03:20:49 +00:00
classicapi: two-tier version check + drop hardcoded github URLs
Splits the ClassicAPI version check into a hard floor (MIN, manual) and a soft target (LATEST, pinned by the release workflow). Below MIN pfUI disables itself entirely as before; between MIN and LATEST it runs normally but fires a delayed chat nudge after PLAYER_LOGIN with the available update. PLAYER_LOGIN handlers swap to EventUtil.ContinueOnPlayerLogin so we don't have to spin a frame for each branch. URLs centralize on toc X-Website fields. pfUI.lua factors out ClassicAPIReleaseUrl(version) sourcing from !!!ClassicAPI's metadata; modules/gui.lua and libs/libdebuff.lua replace hardcoded me0wg4ming/pfUI links with GetAddOnMetadata(pfUI.name, "X-Website") lookups. release.yml gains a pre-package step that queries ClassicAPI's latest release tag, packs it (X*10000 + Y*100 + Z), and seds only the LATEST line in pfUI.lua so the published zip ships with the correct soft target.
This commit is contained in:
@@ -17,6 +17,17 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Pin ClassicAPI latest version to current release
|
||||||
|
run: |
|
||||||
|
LATEST=$(gh api repos/brues-code/ClassicAPI/releases/latest --jq .tag_name | tr -d v)
|
||||||
|
IFS=. read -r MAJOR MINOR PATCH <<<"$LATEST"
|
||||||
|
PACKED=$((MAJOR * 10000 + MINOR * 100 + PATCH))
|
||||||
|
echo "Pinning PFUI_CLASSIC_API_LATEST to $LATEST ($PACKED)"
|
||||||
|
sed -i "s/^local PFUI_CLASSIC_API_LATEST = [0-9]*/local PFUI_CLASSIC_API_LATEST = $PACKED/" pfUI.lua
|
||||||
|
grep '^local PFUI_CLASSIC_API_' pfUI.lua
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Package and release to GitHub
|
- name: Package and release to GitHub
|
||||||
uses: BigWigsMods/packager@v2
|
uses: BigWigsMods/packager@v2
|
||||||
env:
|
env:
|
||||||
|
|||||||
+2
-2
@@ -226,7 +226,7 @@ StaticPopupDialogs["LIBDEBUFF_NAMPOWER_UPDATE"] = {
|
|||||||
hideOnEscape = 0,
|
hideOnEscape = 0,
|
||||||
preferredIndex = 3,
|
preferredIndex = 3,
|
||||||
OnAccept = function()
|
OnAccept = function()
|
||||||
pfUI.chat.urlcopy.CopyText("https://github.com/me0wg4ming/pfUI/wiki/How-to-install-nampower")
|
pfUI.chat.urlcopy.CopyText(GetAddOnMetadata(pfUI.name, "X-Website") .. "/wiki/How-to-install-nampower")
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,7 +239,7 @@ StaticPopupDialogs["LIBDEBUFF_NAMPOWER_MISSING"] = {
|
|||||||
hideOnEscape = 0,
|
hideOnEscape = 0,
|
||||||
preferredIndex = 3,
|
preferredIndex = 3,
|
||||||
OnAccept = function()
|
OnAccept = function()
|
||||||
pfUI.chat.urlcopy.CopyText("https://github.com/me0wg4ming/pfUI/wiki/How-to-install-nampower")
|
pfUI.chat.urlcopy.CopyText(GetAddOnMetadata(pfUI.name, "X-Website") .. "/wiki/How-to-install-nampower")
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -1401,7 +1401,7 @@ pfUI:RegisterModule("gui", function ()
|
|||||||
donate:SetHeight(20)
|
donate:SetHeight(20)
|
||||||
donate:SetText(T["Donate"])
|
donate:SetText(T["Donate"])
|
||||||
donate:SetScript("OnClick", function()
|
donate:SetScript("OnClick", function()
|
||||||
pfUI.chat.urlcopy.CopyText("https://buymeacoffee.com/w1ot8abps4")
|
pfUI.chat.urlcopy.CopyText("https://buymeacoffee.com/brues")
|
||||||
end)
|
end)
|
||||||
SkinButton(donate)
|
SkinButton(donate)
|
||||||
|
|
||||||
@@ -1411,7 +1411,7 @@ pfUI:RegisterModule("gui", function ()
|
|||||||
github:SetHeight(20)
|
github:SetHeight(20)
|
||||||
github:SetText(T["GitHub"])
|
github:SetText(T["GitHub"])
|
||||||
github:SetScript("OnClick", function()
|
github:SetScript("OnClick", function()
|
||||||
pfUI.chat.urlcopy.CopyText("https://github.com/me0wg4ming/pfUI")
|
pfUI.chat.urlcopy.CopyText(GetAddOnMetadata(pfUI.name, "X-Website"))
|
||||||
end)
|
end)
|
||||||
SkinButton(github)
|
SkinButton(github)
|
||||||
|
|
||||||
@@ -1421,7 +1421,7 @@ pfUI:RegisterModule("gui", function ()
|
|||||||
website:SetHeight(20)
|
website:SetHeight(20)
|
||||||
website:SetText(T["Website"])
|
website:SetText(T["Website"])
|
||||||
website:SetScript("OnClick", function()
|
website:SetScript("OnClick", function()
|
||||||
pfUI.chat.urlcopy.CopyText("https://github.com/me0wg4ming/pfUI")
|
pfUI.chat.urlcopy.CopyText(GetAddOnMetadata(pfUI.name, "X-Website"))
|
||||||
end)
|
end)
|
||||||
SkinButton(website)
|
SkinButton(website)
|
||||||
end)
|
end)
|
||||||
|
|||||||
@@ -26,20 +26,29 @@ pfUI.bootup = true
|
|||||||
-- ClassicAPI dependency check.
|
-- ClassicAPI dependency check.
|
||||||
-- pfUI relies pervasively on the modern C_* / SuperWoW / nameplate / focus
|
-- pfUI relies pervasively on the modern C_* / SuperWoW / nameplate / focus
|
||||||
-- API surface that ClassicAPI polyfills, so presence is required.
|
-- API surface that ClassicAPI polyfills, so presence is required.
|
||||||
local PFUI_CLASSIC_API_MIN = 10403 -- (X*10000 + Y*100 + Z)
|
--
|
||||||
|
-- MIN is the hard floor — bumped manually when pfUI starts using a new
|
||||||
|
-- ClassicAPI feature. Below this, pfUI disables itself entirely.
|
||||||
|
-- LATEST is the soft target — replaced by the release workflow with whatever
|
||||||
|
-- ClassicAPI release was current at build time. Between MIN and LATEST,
|
||||||
|
-- pfUI runs normally but nudges the user to update.
|
||||||
|
local PFUI_CLASSIC_API_MIN = 10403 -- (X*10000 + Y*100 + Z)
|
||||||
|
local PFUI_CLASSIC_API_LATEST = 99999999
|
||||||
|
|
||||||
local function FormatVersion(packed)
|
local function FormatVersion(packed)
|
||||||
local x = math.floor(packed / 10000)
|
local x = math.floor(packed / 10000)
|
||||||
local y = math.floor(math.mod(packed, 10000) / 100)
|
local y = math.floor(math.mod(packed, 10000) / 100)
|
||||||
local z = math.mod(packed, 100)
|
local z = math.mod(packed, 100)
|
||||||
return string.format("v%d.%d.%d", x, y, z)
|
return string.format("v%d.%d.%d", x, y, z)
|
||||||
end
|
end
|
||||||
|
local function ClassicAPIReleaseUrl(version)
|
||||||
|
return GetAddOnMetadata("!!!ClassicAPI", "X-Website") .. "/releases/tag/" .. version
|
||||||
|
end
|
||||||
if not CLASSIC_API_VERSION or CLASSIC_API_VERSION < PFUI_CLASSIC_API_MIN then
|
if not CLASSIC_API_VERSION or CLASSIC_API_VERSION < PFUI_CLASSIC_API_MIN then
|
||||||
pfUI.disabled = true
|
pfUI.disabled = true
|
||||||
|
|
||||||
local minVersion = FormatVersion(PFUI_CLASSIC_API_MIN)
|
local minVersion = FormatVersion(PFUI_CLASSIC_API_MIN)
|
||||||
local alertFrame = CreateFrame("Frame")
|
EventUtil.ContinueOnPlayerLogin(function()
|
||||||
alertFrame:RegisterEvent("PLAYER_LOGIN")
|
|
||||||
alertFrame:SetScript("OnEvent", function()
|
|
||||||
StaticPopupDialogs["PFUI_CLASSICAPI_REQUIRED"] = {
|
StaticPopupDialogs["PFUI_CLASSICAPI_REQUIRED"] = {
|
||||||
text = "This fork of |cff33ffccpf|cffffffffUI|r requires ClassicAPI\n " .. minVersion .. " or newer.\n\nAll |cff33ffccpf|cffffffffUI|r modules have been disabled.\nInstall ClassicAPI from:",
|
text = "This fork of |cff33ffccpf|cffffffffUI|r requires ClassicAPI\n " .. minVersion .. " or newer.\n\nAll |cff33ffccpf|cffffffffUI|r modules have been disabled.\nInstall ClassicAPI from:",
|
||||||
button1 = OKAY,
|
button1 = OKAY,
|
||||||
@@ -52,7 +61,7 @@ if not CLASSIC_API_VERSION or CLASSIC_API_VERSION < PFUI_CLASSIC_API_MIN then
|
|||||||
OnShow = function()
|
OnShow = function()
|
||||||
local editBox = _G[this:GetName().."EditBox"]
|
local editBox = _G[this:GetName().."EditBox"]
|
||||||
if editBox then
|
if editBox then
|
||||||
editBox:SetText("https://github.com/brues-code/ClassicAPI/releases/tag/" .. minVersion)
|
editBox:SetText(ClassicAPIReleaseUrl(minVersion))
|
||||||
editBox:HighlightText()
|
editBox:HighlightText()
|
||||||
editBox:SetFocus()
|
editBox:SetFocus()
|
||||||
end
|
end
|
||||||
@@ -61,11 +70,26 @@ if not CLASSIC_API_VERSION or CLASSIC_API_VERSION < PFUI_CLASSIC_API_MIN then
|
|||||||
StaticPopup_Show("PFUI_CLASSICAPI_REQUIRED")
|
StaticPopup_Show("PFUI_CLASSICAPI_REQUIRED")
|
||||||
if DEFAULT_CHAT_FRAME then
|
if DEFAULT_CHAT_FRAME then
|
||||||
DEFAULT_CHAT_FRAME:AddMessage(
|
DEFAULT_CHAT_FRAME:AddMessage(
|
||||||
"This fork of pfUI requires ClassicAPI " .. minVersion .. "+. Get it at https://github.com/brues-code/ClassicAPI/releases/tag/" .. minVersion,
|
"This fork of pfUI requires ClassicAPI " .. minVersion .. "+. Get it at " .. ClassicAPIReleaseUrl(minVersion),
|
||||||
1, 0.3, 0.3
|
1, 0.3, 0.3
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
elseif CLASSIC_API_VERSION < PFUI_CLASSIC_API_LATEST then
|
||||||
|
-- Above MIN but below the release-pinned LATEST — soft nudge in chat,
|
||||||
|
-- delayed so it lands after the login welcome spam instead of getting
|
||||||
|
-- buried.
|
||||||
|
local latestVersion = FormatVersion(PFUI_CLASSIC_API_LATEST)
|
||||||
|
EventUtil.ContinueOnPlayerLogin(function()
|
||||||
|
C_Timer.After(8, function()
|
||||||
|
if DEFAULT_CHAT_FRAME then
|
||||||
|
DEFAULT_CHAT_FRAME:AddMessage(
|
||||||
|
"|cff33ffccpf|rUI: ClassicAPI " .. latestVersion .. " is available — " .. ClassicAPIReleaseUrl(latestVersion),
|
||||||
|
1, 0.85, 0.3
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- initialize saved variables
|
-- initialize saved variables
|
||||||
|
|||||||
Reference in New Issue
Block a user