-
Notifications
You must be signed in to change notification settings - Fork 8
130 lines (117 loc) · 4.85 KB
/
go.yml
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: Go
on: [push]
jobs:
Build:
strategy:
matrix:
lua-version: [lua51, lua52, lua53, lua54, luajit]
os: [ubuntu, macos, windows]
include:
- os: ubuntu
image: ubuntu-latest
- os: macos
image: macos-latest
- os: windows
image: windows-latest
runs-on: ${{ matrix.image }}
steps:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.22
id: go
- uses: msys2/setup-msys2@v2
if: matrix.os == 'windows'
with:
update: true
msystem: MINGW64
install: mingw-w64-x86_64-gcc mingw-w64-x86_64-make make curl unzip
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Build Lua on Unix
if: matrix.os != 'windows'
run: |
cd golua/lua
./buildlua.sh
cd -
- name: Build GetNovel on Linux
if: matrix.os == 'ubuntu'
run: |
go build -ldflags="-linkmode 'external' -extldflags '-static' -s -w -X main.sha1ver=$(git rev-parse --short HEAD) -X 'main.buildTime=$(date)'" -tags ${{ matrix.lua-version }} -o getnovel .
mkdir ${{ matrix.os }}-amd64
cp getnovel ${{ matrix.os }}-amd64/
cp -r pdfpresets ${{ matrix.os }}-amd64/
cp -r handlers ${{ matrix.os }}-amd64/
cp -r lua ${{ matrix.os }}-amd64/
- name: Build GetNovel on macOS
if: matrix.os == 'macos'
run: |
env CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w -X main.sha1ver=$(git rev-parse --short HEAD) -X 'main.buildTime=$(date)'" -tags ${{ matrix.lua-version }} -o getnovel-amd64 .
if [ "${{ matrix.lua-version }}" == "luajit" ]; then
mv getnovel-amd64 getnovel
else
env CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w -X main.sha1ver=$(git rev-parse --short HEAD) -X 'main.buildTime=$(date)'" -tags ${{ matrix.lua-version }} -o getnovel-arm64 .
lipo -create -output getnovel getnovel-amd64 getnovel-arm64
fi
curl -sSL -o kindlegen.zip https://github.com/ystyle/kaf-cli/releases/download/kindlegen/KindleGen_Mac_64bit_v2_9.zip
unzip kindlegen.zip
mkdir ${{ matrix.os }}-amd64
cp getnovel ${{ matrix.os }}-amd64/
cp kindlegen ${{ matrix.os }}-amd64/
cp -r pdfpresets ${{ matrix.os }}-amd64/
cp -r handlers ${{ matrix.os }}-amd64/
cp -r lua ${{ matrix.os }}-amd64/
- name: Download LuaJIT on Windows
if: matrix.os == 'windows' && matrix.lua-version == 'luajit'
run: |
cd golua/lua
git clone --depth 1 https://github.com/LuaJIT/LuaJIT.git luajit
cd -
- name: Build Lua on Windows
if: matrix.os == 'windows'
shell: msys2 {0}
run: |
cd golua/lua/${{ matrix.lua-version }}
if [ "${{ matrix.lua-version }}" == "luajit" ]; then env MSYSTEM=MINGW64 PATH=$PATH:/mingw64/bin make BUILDMODE=static; mv src/libluajit.a ./ ; else env MSYSTEM=MINGW64 PATH=$PATH:/mingw64/bin make mingw; fi
cd -
- name: Build GetNovel on Windows
if: matrix.os == 'windows'
shell: cmd
run: |
set PATH=D:\a\_temp\msys64\mingw64\bin;%PATH%
for /F "tokens=*" %%R in ('git rev-parse --short HEAD') do set REV=%%R
for /F "tokens=*" %%A in ('date /T') do set TODAY=%%A
go build -ldflags="-s -w -X main.sha1ver=%REV% -X 'main.buildTime=%TODAY%'" -tags ${{ matrix.lua-version }} -o getnovel.exe .
- name: copy files on Windows
if: matrix.os == 'windows'
shell: msys2 {0}
run: |
curl -sSL -o kindlegen.zip https://github.com/ystyle/kaf-cli/releases/download/kindlegen/kindlegen_win32_v2_9.zip
unzip kindlegen.zip
mkdir ${{ matrix.os }}-amd64
cp getnovel.exe ${{ matrix.os }}-amd64/
cp kindlegen.exe ${{ matrix.os }}-amd64/
cp -r pdfpresets ${{ matrix.os }}-amd64/
cp -r handlers ${{ matrix.os }}-amd64/
cp -r lua ${{ matrix.os }}-amd64/
- name: Upload artifact getnovel-${{ matrix.os }}-amd64
uses: actions/[email protected]
with:
name: getnovel-${{ matrix.os }}-${{ matrix.lua-version }}
path: ${{ matrix.os }}-amd64
- name: Pack release
if: startsWith(github.event.ref, 'refs/tags/')
uses: vimtor/[email protected]
with:
files: ${{ matrix.os }}-amd64/
recursive: true
dest: getnovel-${{ matrix.os }}-${{ matrix.lua-version }}.zip
- name: upload Release
if: startsWith(github.event.ref, 'refs/tags/')
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GH_TOKEN }}
file: getnovel-${{ matrix.os }}-${{ matrix.lua-version }}.zip
asset_name: getnovel-${{ matrix.os }}-${{ matrix.lua-version }}.zip
tag: ${{ github.ref }}
overwrite: true