Skip to content

Commit 420d62f

Browse files
committed
Add distribution workflow
1 parent 89a4c25 commit 420d62f

8 files changed

Lines changed: 73 additions & 17 deletions

File tree

.github/create-release.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
IFS=$'\t\n'
5+
6+
RELEASE_NAME="$(echo "$GITHUB_REF_NAME" | cut -d "/" -f 3-)"
7+
gh release create --verify-tag --title $RELEASE_NAME $GITHUB_REF_NAME

.github/dist.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
IFS=$'\t\n'
5+
6+
if [[ -d dist ]]; then
7+
rm -r dist
8+
fi
9+
mkdir dist
10+
cp -r tptasm modulepack.conf dist/
11+
cd dist
12+
git submodule update --init
13+
luajit ../TPT-Script-Manager/modulepack.lua modulepack.conf > tptasm.dist.lua

.github/upload-release-asset.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
IFS=$'\t\n'
5+
6+
temp=.temp
7+
mkdir $temp
8+
cp $ASSET_PATH $temp/$ASSET_NAME
9+
(
10+
cd $temp
11+
gh release upload $GITHUB_REF_NAME $ASSET_NAME
12+
)
13+
rm -r $temp
14+
echo browser_download_url=https://github.com/$GITHUB_REPOSITORY/releases/download/$GITHUB_REF_NAME/$ASSET_NAME >> $GITHUB_OUTPUT

.github/workflows/build.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: build
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v1.*'
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- env:
14+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15+
run: bash -c './.github/create-release.sh'
16+
- run: sudo apt update && sudo apt install luajit
17+
- run: ./.github/dist.sh ${{ github.ref }}
18+
- env:
19+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20+
ASSET_PATH: dist/tptasm.dist.lua
21+
ASSET_NAME: tptasm.lua
22+
run: bash -c './.github/upload-release-asset.sh'

TPT-Script-Manager

tptasm/detect.lua

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,11 @@ end
132132
local function all_cpus()
133133
local co = coroutine.create(function()
134134
local rethrow = false
135-
xpcall(function()
135+
xpcall_wrap(function()
136136
enumerate_cpus()
137137
end, function(err)
138-
printf.err("error inside xpcall: %s", tostring(err))
139-
printf.info("%s", debug.traceback())
140138
rethrow = true
141-
end)
139+
end)()
142140
if rethrow then
143141
error("rethrowing error from inside xpcall")
144142
end

tptasm/init.lua

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
11
local printf = require("tptasm.printf")
22
local utility = require("tptasm.utility")
33

4-
local function run(...)
4+
local function main(...)
55
local exit_with = 0
66

7-
local args = { ... }
8-
if _G.tpt and select("#", ...) == 0 then
9-
_G.tptasm = run
10-
return exit_with
11-
end
12-
137
printf.update_colour()
148
local old_print = print
159
function print(...)
1610
printf.debug(utility.get_line(2), ...)
1711
end
1812

19-
xpcall(function()
13+
local args = { ... }
14+
xpcall_wrap(function()
2015

2116
local detect = require("tptasm.detect")
2217
local archs = require("tptasm.archs")
@@ -159,14 +154,12 @@ local function run(...)
159154
exit_with = 1
160155
else
161156
-- * Dang.
162-
printf.err("error: %s", tostring(err))
163-
printf.info("%s", debug.traceback())
164157
printf.info("this is an assembler bug, tell LBPHacker!")
165158
printf.info("https://github.com/LBPHacker/tptasm")
166159
exit_with = 2
167160
end
168161

169-
end)
162+
end)()
170163

171164
printf.unredirect()
172165
printf.info("done")
@@ -177,6 +170,14 @@ local function run(...)
177170
return exit_with
178171
end
179172

173+
local function run(...)
174+
if _G.tpt and select("#", ...) == 0 then
175+
_G.tptasm = xpcall_wrap(main)
176+
return
177+
end
178+
return main(...)
179+
end
180+
180181
return {
181182
run = run,
182183
}

tptasm/printf.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
local printf = setmetatable({
1+
local printf
2+
printf = setmetatable({
23
print = print,
34
print_old = print,
45
log_handle = false,

0 commit comments

Comments
 (0)