|
1 | | -name: Cross-Compile & Release |
| 1 | +name: Cross-Compile TinyCC |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | 5 | branches: |
6 | | - - main |
7 | | - workflow_dispatch: |
| 6 | + - main # Change to the branch you want to trigger on |
8 | 7 |
|
9 | 8 | jobs: |
10 | 9 | build: |
| 10 | + runs-on: ubuntu-latest |
11 | 11 | strategy: |
12 | 12 | matrix: |
13 | | - os: [ubuntu-latest, windows-latest] |
14 | | - runs-on: ${{ matrix.os }} |
| 13 | + target: [linux, windows] |
| 14 | + |
15 | 15 | steps: |
16 | | - - name: Checkout source |
17 | | - uses: actions/checkout@v3 |
18 | | - |
19 | | - # --- Setup build dependencies |
20 | | - - name: Setup Linux build tools |
21 | | - if: matrix.os == 'ubuntu-latest' |
22 | | - run: | |
23 | | - sudo apt-get update |
24 | | - sudo apt-get install -y build-essential |
25 | | -
|
26 | | - - name: Setup Windows build tools |
27 | | - if: matrix.os == 'windows-latest' |
| 16 | + - name: Checkout Source |
| 17 | + uses: actions/checkout@v4 |
| 18 | + |
| 19 | + - name: Install Dependencies |
28 | 20 | run: | |
29 | | - choco install mingw -y |
30 | | - shell: powershell |
| 21 | + sudo apt update |
| 22 | + sudo apt install -y mingw-w64 build-essential |
31 | 23 |
|
32 | | - # --- Run your build script (adjust commands as needed) |
33 | | - - name: Build TinyCC |
| 24 | + - name: Build for Linux |
| 25 | + if: matrix.target == 'linux' |
34 | 26 | run: | |
35 | | - if [ "$(uname -s)" = "Linux" ]; then |
36 | | - # For Linux, assume you have a Makefile |
37 | | - make clean && make |
38 | | - else |
39 | | - # For Windows, run your batch file |
40 | | - ./build-tcc.bat |
41 | | - fi |
42 | | - shell: bash |
| 27 | + ./configure |
| 28 | + make -j$(nproc) |
| 29 | + tar -czvf tinycc-linux.tar.gz tcc |
43 | 30 |
|
44 | | - # --- Collect artifacts (adjust paths to your outputs) |
45 | | - - name: Prepare artifact folder |
| 31 | + - name: Build for Windows |
| 32 | + if: matrix.target == 'windows' |
46 | 33 | run: | |
47 | | - mkdir artifact |
48 | | - # For example, copy the built binaries or ZIP files: |
49 | | - cp tcc.exe artifact/ 2>/dev/null || true |
50 | | - cp libtcc.dll artifact/ 2>/dev/null || true |
51 | | - cp -r some_output_folder artifact/ 2>/dev/null || true |
| 34 | + ./configure --cross-prefix=x86_64-w64-mingw32- |
| 35 | + make -j$(nproc) |
| 36 | + zip -r tinycc-windows.zip tcc.exe |
52 | 37 |
|
53 | | - - name: Upload artifact |
54 | | - uses: actions/upload-artifact@v3 |
| 38 | + - name: Upload Artifacts |
| 39 | + uses: actions/upload-artifact@v4 |
55 | 40 | with: |
56 | | - name: build-${{ matrix.os }} |
57 | | - path: artifact/ |
58 | | - |
| 41 | + name: tinycc-${{ matrix.target }} |
| 42 | + path: tinycc-*.* |
| 43 | + |
59 | 44 | release: |
60 | 45 | needs: build |
61 | 46 | runs-on: ubuntu-latest |
62 | | - steps: |
63 | | - - name: Download Linux artifact |
64 | | - uses: actions/download-artifact@v3 |
65 | | - with: |
66 | | - name: build-ubuntu-latest |
67 | 47 |
|
68 | | - - name: Download Windows artifact |
69 | | - uses: actions/download-artifact@v3 |
| 48 | + steps: |
| 49 | + - name: Download Artifacts |
| 50 | + uses: actions/download-artifact@v4 |
70 | 51 | with: |
71 | | - name: build-windows-latest |
| 52 | + path: artifacts |
72 | 53 |
|
73 | | - # --- Combine both artifacts into one release folder and zip them |
74 | | - - name: Prepare release package |
75 | | - run: | |
76 | | - mkdir release |
77 | | - cp -r build-ubuntu-latest/* release/ || true |
78 | | - cp -r build-windows-latest/* release/ || true |
79 | | - cd release |
80 | | - zip -r ../latest-release.zip . |
81 | | - |
82 | | - # --- Clone the mirror repository (branch "mob") using a dedicated token |
83 | | - - name: Checkout mirror repository |
84 | | - uses: actions/checkout@v3 |
| 54 | + - name: Create GitHub Release |
| 55 | + uses: softprops/action-gh-release@v2 |
85 | 56 | with: |
| 57 | + tag_name: latest |
86 | 58 | repository: Tiny-C-Compiler/mirror-repository |
87 | | - ref: mob |
88 | | - token: ${{ secrets.MIRROR_REPO_TOKEN }} |
89 | | - path: mirror |
90 | | - |
91 | | - # --- Copy the release package into the mirror repository and push changes |
92 | | - - name: Update mirror repository with new release |
93 | | - run: | |
94 | | - cp latest-release.zip mirror/ |
95 | | - cd mirror |
96 | | - git config user.name "github-actions[bot]" |
97 | | - git config user.email "github-actions[bot]@users.noreply.github.com" |
98 | | - git add latest-release.zip |
99 | | - git commit -m "Update latest release" || echo "No changes to commit" |
100 | | - git push origin mob |
101 | | -
|
102 | | - # --- Create or update a GitHub Release on the mirror repository using gh CLI |
103 | | - - name: Create GitHub Release in mirror repository |
104 | | - run: | |
105 | | - gh release create latest latest-release.zip \ |
106 | | - --repo Tiny-C-Compiler/mirror-repository \ |
107 | | - --title "Latest Release" \ |
108 | | - --notes "Automated build and release on $(date -u)" |
109 | | - env: |
110 | | - GITHUB_TOKEN: ${{ secrets.MIRROR_REPO_TOKEN }} |
| 59 | + files: artifacts/tinycc-*/tinycc-* |
| 60 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 61 | + prerelease: true |
| 62 | + draft: false |
0 commit comments