-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbumpversion.lua
More file actions
executable file
·74 lines (52 loc) · 1.65 KB
/
bumpversion.lua
File metadata and controls
executable file
·74 lines (52 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/opt/local/bin/lua
require "pl"
local markdown = require 'markdown_extra'
local template = require 'pl.template'
local json = require 'dkjson'
local manifestRaw = file.read('manifest.json')
local manifest, pos, err = json.decode(manifestRaw, 1, nil)
if err then
print("Error: " .. err)
os.exit(1)
end
local currentVersion = manifest['version']
local today = Date()
local year = today:year()
local month = today:month()
print("Current version: " .. currentVersion)
local prefix = year .. "." .. month
local newVersion = ""
if not stringx.startswith(currentVersion, prefix) then
newVersion = prefix .. ".1"
else
local buildNumber = currentVersion:gsub(prefix .. ".", "")
newVersion = prefix .. "." .. (math.floor(buildNumber + 1))
end
print("New version: " .. newVersion)
--[[
===== Change manifest =====================================
Can't serialise `manifest` into json and save cause the keys
go all out of order.
--]]
local newManifest = manifestRaw:gsub(currentVersion, newVersion)
file.write("manifest.json", newManifest)
--[[
===== Save empty release notes =====================================
--]]
local releaseNotes = [[
# Release Notes VERSION
]]
file.write("docs/release-notes/" .. newVersion .. ".md",
releaseNotes:gsub("VERSION", newVersion))
--[[
===== Fix buildrss.lua =====================================
--]]
local buildRSSRaw = file.read("buildrss.lua")
local lineToFind = '"' .. currentVersion .. '",'
local lineToReplace =
[["NEW",
"CURRENT",]]
lineToReplace = lineToReplace:gsub("NEW", newVersion):gsub("CURRENT",
currentVersion)
buildRSSRaw = buildRSSRaw:gsub(lineToFind, lineToReplace)
file.write("buildrss.lua", buildRSSRaw)