Skip to content

Commit 2b984c4

Browse files
authored
Update release-crosscompile.yml
1 parent ba6fb93 commit 2b984c4

File tree

1 file changed

+66
-40
lines changed

1 file changed

+66
-40
lines changed

.github/workflows/release-crosscompile.yml

Lines changed: 66 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
name: Cross-Platform Build and Release
22

33
on:
4+
# Trigger every 15 minutes and on manual dispatch.
45
schedule:
56
- cron: '*/15 * * * *'
67
workflow_dispatch:
78

89
jobs:
10+
# -----------------------------------------------------------
11+
# 1. Sync the upstream source into the mirror repository.
12+
# -----------------------------------------------------------
913
git-sync:
1014
runs-on: ubuntu-latest
15+
outputs:
16+
# (optional: you could output the path if needed by downstream jobs)
17+
synced: true
1118
steps:
1219
- name: Sync repositories
1320
uses: wei/git-sync@v3
@@ -18,7 +25,10 @@ jobs:
1825
destination_branch: "mob"
1926
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}
2027

21-
build-binaries:
28+
# -----------------------------------------------------------
29+
# 2. Build the Linux binary on Ubuntu.
30+
# -----------------------------------------------------------
31+
build-linux:
2232
needs: git-sync
2333
runs-on: ubuntu-latest
2434
steps:
@@ -30,80 +40,96 @@ jobs:
3040
ssh-key: ${{ secrets.SSH_PRIVATE_KEY }}
3141
fetch-depth: 0
3242

33-
- name: Install build dependencies
43+
- name: Install Linux build dependencies
3444
run: |
35-
sudo dpkg --add-architecture i386
3645
sudo apt-get update
37-
sudo apt-get install -y \
38-
gcc \
39-
make \
40-
gcc-mingw-w64-x86-64 \
41-
binutils-mingw-w64-x86-64 \
42-
mingw-w64-x86-64-dev \
43-
build-essential \
44-
wine64 \
45-
wine32:i386
46-
47-
- name: Build Linux host compiler
48-
run: |
49-
./configure
50-
make
51-
mv tcc tcc-host
46+
sudo apt-get install -y gcc make build-essential
5247
5348
- name: Build Linux binary
5449
run: |
5550
./configure
51+
make clean
5652
make
53+
# Rename the built executable for clarity
5754
mv tcc tcc-linux
5855
56+
- name: Upload Linux binary artifact
57+
uses: actions/upload-artifact@v4
58+
with:
59+
name: tcc-linux
60+
path: tcc-linux
61+
62+
# -----------------------------------------------------------
63+
# 3. Cross-compile the Windows binary using mingw on Ubuntu.
64+
# -----------------------------------------------------------
65+
build-windows:
66+
needs: git-sync
67+
runs-on: ubuntu-latest
68+
steps:
69+
- name: Checkout mirror repository
70+
uses: actions/checkout@v4
71+
with:
72+
repository: Tiny-C-Compiler/mirror-repository
73+
ref: mob
74+
ssh-key: ${{ secrets.SSH_PRIVATE_KEY }}
75+
fetch-depth: 0
76+
77+
- name: Install Windows cross-compilation dependencies
78+
run: |
79+
sudo apt-get update
80+
sudo apt-get install -y \
81+
gcc-mingw-w64-x86-64 \
82+
binutils-mingw-w64-x86-64 \
83+
mingw-w64-x86-64-dev \
84+
make build-essential
85+
5986
- name: Prepare Windows build environment
6087
run: |
61-
# Clean previous artifacts (keep host compiler)
88+
# Clean previous build artifacts (except the Linux host binary)
6289
make clean
6390
rm -f config.mak config.h
64-
65-
# Configure for Windows cross-compilation
91+
# Configure for Windows cross-compilation using mingw
6692
./configure \
6793
--cross-prefix=x86_64-w64-mingw32- \
6894
--cpu=x86_64 \
6995
--extra-cflags="-static" \
7096
--extra-ldflags="-static"
71-
72-
# Patch the Makefile:
73-
# • Use host compiler (tcc-host) for helper tools.
74-
# • Use the cross-compiler for building Windows binary.
75-
# • Define WIN32 and use wine for any Windows executable that runs.
76-
sed -i 's/^\(HOST_CC\s*=\s*\).*/\1.\/tcc-host/' Makefile
97+
# Adjust the Makefile:
98+
# Use the already built Linux executable as a helper if needed.
99+
sed -i 's/^\(HOST_CC\s*=\s*\).*/\1.\/tcc-linux/' Makefile
77100
sed -i 's/^\(CC\s*=\s*\).*/\1x86_64-w64-mingw32-gcc/' Makefile
78101
sed -i 's/\(CFLAGS\s*+=\)/\1 -DWIN32/' Makefile
79-
sed -i 's|./c2str.exe|wine ./c2str.exe|' Makefile
80-
# Remove -ldl from linking since it’s not available on Windows.
81-
sed -i 's/-ldl//g' Makefile
82102
83103
- name: Build Windows binary
84104
run: |
85-
# Build any helper tools using the host compiler first.
105+
# First build helper libraries with the host compiler
86106
make libtcc1.a
87-
# Build the Windows executable with the cross-compiler.
107+
# Then build the Windows executable
88108
make tcc
89109
mv tcc tcc-windows.exe
90110
91-
- name: Upload artifacts
111+
- name: Upload Windows binary artifact
92112
uses: actions/upload-artifact@v4
93113
with:
94-
name: binaries
95-
path: |
96-
tcc-linux
97-
tcc-windows.exe
114+
name: tcc-windows
115+
path: tcc-windows.exe
98116

117+
# -----------------------------------------------------------
118+
# 4. Create or update the “latest” GitHub Release on the mirror repo.
119+
# -----------------------------------------------------------
99120
create-release:
100-
needs: build-binaries
121+
needs: [build-linux, build-windows]
101122
runs-on: ubuntu-latest
102123
steps:
103-
- name: Download artifacts
124+
- name: Download Linux artifact
125+
uses: actions/download-artifact@v4
126+
with:
127+
name: tcc-linux
128+
129+
- name: Download Windows artifact
104130
uses: actions/download-artifact@v4
105131
with:
106-
name: binaries
132+
name: tcc-windows
107133

108134
- name: Create GitHub Release
109135
uses: softprops/action-gh-release@v1

0 commit comments

Comments
 (0)