Skip to content

Commit ea56e34

Browse files
authored
Merge pull request #21 from jujudusud/cross-compile
test cross compile
2 parents 51fc396 + bdbed58 commit ea56e34

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

.github/workflows/release.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Build and Release
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
workflow_dispatch:
8+
9+
jobs:
10+
build:
11+
name: Build ${{ matrix.target }}
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
include:
16+
- target: win32
17+
docker_image: jpcima/arch-mingw
18+
cmake: i686-w64-mingw32-cmake
19+
zip_name: FreeMajor-dev-win32.zip
20+
- target: win64
21+
docker_image: jpcima/arch-mingw
22+
cmake: x86_64-w64-mingw32-cmake
23+
zip_name: FreeMajor-dev-win64.zip
24+
- target: macos
25+
docker_image: jpcima/osxcross-10.6
26+
cmake: x86_64-apple-darwin15-cmake
27+
zip_name: FreeMajor-dev-mac.zip
28+
29+
steps:
30+
- uses: actions/checkout@v4
31+
32+
- name: Start cross container
33+
run: |
34+
docker pull ${{ matrix.docker_image }}
35+
container=$(docker run -d -i -t -v $GITHUB_WORKSPACE:$GITHUB_WORKSPACE ${{ matrix.docker_image }} /bin/bash)
36+
echo "CONTAINER_ID=$container" >> $GITHUB_ENV
37+
38+
- name: Define cross function
39+
run: |
40+
{
41+
echo 'cross() {'
42+
if [ "${{ matrix.target }}" = "macos" ]; then
43+
echo ' docker exec -w "$GITHUB_WORKSPACE" -e PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/osxcross/target/bin -e MACOSX_DEPLOYMENT_TARGET=10.7 -i -t "$CONTAINER_ID" "$@";'
44+
else
45+
echo ' docker exec -w "$GITHUB_WORKSPACE" -i -t "$CONTAINER_ID" "$@";'
46+
fi
47+
echo '}'
48+
} >> $GITHUB_ENV
49+
50+
- name: Build and package
51+
run: |
52+
mkdir -p release build
53+
cd build
54+
source <(echo "$(
55+
grep '^cross()' -n $GITHUB_ENV >/dev/null 2>&1 || cat $GITHUB_ENV
56+
)") || true
57+
cross ${{ matrix.cmake }} -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DENABLE_GETTEXT=ON ..
58+
cross make -j
59+
cross cpack -G ZIP
60+
cp FreeMajor-*.zip ../release/${{ matrix.zip_name }}
61+
62+
- name: Upload build artifact
63+
uses: actions/upload-artifact@v4
64+
with:
65+
name: ${{ matrix.zip_name }}
66+
path: release/${{ matrix.zip_name }}

0 commit comments

Comments
 (0)