-
Notifications
You must be signed in to change notification settings - Fork 8
109 lines (98 loc) · 3.73 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
name: Go
on: [push]
jobs:
Build:
strategy:
matrix:
lua-version: [lua51, lua52, lua53, lua54]
os: [macos, ubuntu, windows]
runs-on: ${{ matrix.os }}-latest
steps:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.21
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 on Unix
if: matrix.os != 'macos' && matrix.os != 'windows'
run: |
go build -ldflags="-s -w" -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 on macOS
if: matrix.os == 'macos'
run: |
env CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" -tags ${{ matrix.lua-version }} -o getnovel-amd64 .
env CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w" -tags ${{ matrix.lua-version }} -o getnovel-arm64 .
lipo -create -output getnovel getnovel-amd64 getnovel-arm64
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: Build Lua on Windows
if: matrix.os == 'windows'
shell: msys2 {0}
run: |
cd golua/lua/${{ matrix.lua-version }}
env MSYSTEM=MINGW64 PATH=$PATH:/mingw64/bin make mingw
cd -
- name: Build GetNovel on Windows
if: matrix.os == 'windows'
shell: cmd
run: |
set PATH=D:\a\_temp\msys64\mingw64\bin;%PATH%
go build -ldflags="-s -w" -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