Skip to content

Commit af456e6

Browse files
committed
Add workflow for making releases
1 parent 5e4d45a commit af456e6

File tree

2 files changed

+169
-3
lines changed

2 files changed

+169
-3
lines changed

.github/workflows/release.yml

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
name: release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*"
7+
8+
jobs:
9+
linux-x86:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
- uses: jirutka/setup-alpine@v1
14+
with:
15+
arch: x86
16+
packages: "build-base make cmake"
17+
- name: build
18+
shell: alpine.sh {0}
19+
run: |
20+
mkdir build
21+
cd build
22+
cmake -DBUILD_STATIC_QJS_EXE=ON ..
23+
cd ..
24+
cmake --build build --target qjs_exe -j$(getconf _NPROCESSORS_ONLN)
25+
mv build/qjs build/qjs-linux-x86
26+
- name: check
27+
shell: alpine.sh {0}
28+
run: |
29+
file build/qjs-linux-x86
30+
- name: upload
31+
uses: actions/upload-artifact@v3
32+
with:
33+
name: qjs
34+
path: build/qjs-linux-x86
35+
36+
linux-x86_64:
37+
runs-on: ubuntu-latest
38+
steps:
39+
- uses: actions/checkout@v3
40+
- uses: jirutka/setup-alpine@v1
41+
with:
42+
arch: x86_64
43+
packages: "build-base make cmake"
44+
- name: build
45+
shell: alpine.sh {0}
46+
run: |
47+
mkdir build
48+
cd build
49+
cmake -DBUILD_STATIC_QJS_EXE=ON ..
50+
cd ..
51+
cmake --build build --target qjs_exe -j$(getconf _NPROCESSORS_ONLN)
52+
mv build/qjs build/qjs-linux-x86_64
53+
- name: check
54+
shell: alpine.sh {0}
55+
run: |
56+
file build/qjs-linux-x86_64
57+
- name: upload
58+
uses: actions/upload-artifact@v3
59+
with:
60+
name: qjs
61+
path: build/qjs-linux-x86_64
62+
63+
macos:
64+
runs-on: macos-latest
65+
steps:
66+
- uses: actions/checkout@v3
67+
- name: build
68+
run: |
69+
mkdir build
70+
cd build
71+
cmake -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" ..
72+
make -j$(getconf _NPROCESSORS_ONLN)
73+
mv qjs qjs-darwin
74+
- name: check
75+
run: |
76+
lipo -info build/qjs-darwin
77+
- name: upload
78+
uses: actions/upload-artifact@v3
79+
with:
80+
name: qjs
81+
path: build/qjs-darwin
82+
83+
windows-x86:
84+
runs-on: windows-latest
85+
defaults:
86+
run:
87+
shell: msys2 {0}
88+
steps:
89+
- uses: actions/checkout@v3
90+
- name: Setup MSYS2
91+
uses: msys2/setup-msys2@v2
92+
with:
93+
msystem: mingw32
94+
install: >-
95+
git
96+
make
97+
pacboy: >-
98+
cmake:p
99+
ninja:p
100+
toolchain:p
101+
- name: build
102+
run: |
103+
make
104+
mv build/qjs.exe build/qjs-windows-x86.exe
105+
- name: check
106+
run: |
107+
ldd build/qjs-windows-x86.exe
108+
- name: upload
109+
uses: actions/upload-artifact@v3
110+
with:
111+
name: qjs
112+
path: build/qjs-windows-x86.exe
113+
114+
windows-x86_64:
115+
runs-on: windows-latest
116+
defaults:
117+
run:
118+
shell: msys2 {0}
119+
steps:
120+
- uses: actions/checkout@v3
121+
- name: Setup MSYS2
122+
uses: msys2/setup-msys2@v2
123+
with:
124+
msystem: mingw64
125+
install: >-
126+
git
127+
make
128+
pacboy: >-
129+
cmake:p
130+
ninja:p
131+
toolchain:p
132+
- name: build
133+
run: |
134+
make
135+
mv build/qjs.exe build/qjs-windows-x86_64.exe
136+
- name: check
137+
run: |
138+
ldd build/qjs-windows-x86_64.exe
139+
- name: upload
140+
uses: actions/upload-artifact@v3
141+
with:
142+
name: qjs
143+
path: build/qjs-windows-x86_64.exe
144+
145+
upload-to-release:
146+
needs: [linux-x86, linux-x86_64, macos, windows-x86, windows-x86_64]
147+
runs-on: ubuntu-latest
148+
steps:
149+
- name: get assets
150+
uses: actions/download-artifact@v3
151+
with:
152+
path: build
153+
- name: release
154+
uses: softprops/action-gh-release@v1
155+
with:
156+
files: |
157+
build/qjs/qjs-linux-x86_64
158+
build/qjs/qjs-linux-x86
159+
build/qjs/qjs-windows-x86.exe
160+
build/qjs/qjs-windows-x86_64.exe
161+
build/qjs/qjs-darwin

CMakeLists.txt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ if(BUILD_SHARED_LIBS)
6969
endif()
7070

7171
xoption(BUILD_EXAMPLES "Build examples" OFF)
72+
xoption(BUILD_STATIC_QJS_EXE "Build a static qjs executable" OFF)
7273
xoption(CONFIG_ASAN "Enable AddressSanitizer (ASan)" OFF)
7374
xoption(CONFIG_MSAN "Enable MemorySanitizer (MSan)" OFF)
7475
xoption(CONFIG_UBSAN "Enable UndefinedBehaviorSanitizer (UBSan)" OFF)
@@ -180,9 +181,13 @@ set_target_properties(qjs_exe PROPERTIES
180181
)
181182
target_compile_definitions(qjs_exe PRIVATE ${qjs_defines})
182183
target_link_libraries(qjs_exe ${qjs_libs})
183-
if(MINGW)
184-
target_link_options(qjs_exe PRIVATE -static -static-libgcc)
185-
else()
184+
if(BUILD_STATIC_QJS_EXE OR MINGW)
185+
target_link_options(qjs_exe PRIVATE -static)
186+
if(MINGW)
187+
target_link_options(qjs_exe PRIVATE -static-libgcc)
188+
endif()
189+
endif()
190+
if(NOT MINGW)
186191
set_target_properties(qjs_exe PROPERTIES ENABLE_EXPORTS TRUE)
187192
endif()
188193

0 commit comments

Comments
 (0)