|
| 1 | +name: Cosmocc |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + push: |
| 6 | + release: |
| 7 | + types: [published] |
| 8 | + |
| 9 | +jobs: |
| 10 | + build: |
| 11 | + strategy: |
| 12 | + matrix: |
| 13 | + os: [ubuntu-latest, macos-13] |
| 14 | + arch: [x86_64] |
| 15 | + |
| 16 | + runs-on: ${{ matrix.os }} |
| 17 | + |
| 18 | + concurrency: |
| 19 | + group: ${{ github.ref }}-${{ github.base_ref }}-${{ github.head_ref }}-Cosmocc-${{ matrix.os }}-${{ matrix.arch }} |
| 20 | + cancel-in-progress: true |
| 21 | + |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@v2 |
| 24 | + with: |
| 25 | + submodules: true |
| 26 | + |
| 27 | + - uses: little-core-labs/[email protected] |
| 28 | + id: tagName |
| 29 | + |
| 30 | + - name: Prepare local xmake |
| 31 | + run: cp -rf . ../xmake-source |
| 32 | + |
| 33 | + - uses: xmake-io/github-action-setup-xmake@v1 |
| 34 | + with: |
| 35 | + xmake-version: local#../xmake-source |
| 36 | + |
| 37 | + - uses: bjia56/setup-cosmocc@main |
| 38 | + with: |
| 39 | + version: "4.0.2" |
| 40 | + |
| 41 | + - name: Build |
| 42 | + run: | |
| 43 | + cd core |
| 44 | + xmake f -p linux --cosmocc=y --embed=y -y -cvD |
| 45 | + xmake -v |
| 46 | + cd .. |
| 47 | +
|
| 48 | + - name: Prepare (Linux) |
| 49 | + if: matrix.os == 'ubuntu-latest' |
| 50 | + run: | |
| 51 | + sudo apt update |
| 52 | + sudo apt install -y ruby ruby-dev rubygems build-essential llvm libc++-dev |
| 53 | + sudo apt install -y libgl1-mesa-dev libglu1-mesa-dev |
| 54 | + clang --version |
| 55 | +
|
| 56 | + - name: Prepare (macOS) |
| 57 | + if: matrix.os == 'macos-13' |
| 58 | + run: | |
| 59 | + brew install dmd |
| 60 | + brew install dub |
| 61 | + |
| 62 | + # In the tests, cmake tries to use make from the cosmopolitan toolchain and fails, so uninstall it |
| 63 | + - name: Remove cosmocc |
| 64 | + if: matrix.os == 'macos-13' |
| 65 | + run: | |
| 66 | + INSTALL_DIR="${{runner.temp}}/cosmocc-4.0.2" |
| 67 | + echo "Removing cosmocc from PATH" |
| 68 | + echo "::remove-path::${INSTALL_DIR}/bin" |
| 69 | + rm -r "${INSTALL_DIR}" |
| 70 | +
|
| 71 | + - name: Tests |
| 72 | + run: | |
| 73 | + ls -l core/build/ |
| 74 | + core/build/xmake --version |
| 75 | + core/build/xmake lua -v -D tests/run.lua |
| 76 | + |
| 77 | + - name: Artifact |
| 78 | + if: matrix.os == 'ubuntu-latest' |
| 79 | + uses: actions/upload-artifact@v4 |
| 80 | + with: |
| 81 | + name: xmake-bundle.cosmocc.x86_64 |
| 82 | + path: core/build/xmake |
| 83 | + |
| 84 | + - name: Publish bundle binary |
| 85 | + if: github.event.action == 'published' && matrix.os == 'ubuntu-latest' |
| 86 | + |
| 87 | + env: |
| 88 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 89 | + with: |
| 90 | + upload_url: ${{ github.event.release.upload_url }} |
| 91 | + asset_path: core/build/xmake |
| 92 | + asset_name: xmake-bundle-${{ steps.tagName.outputs.tag }}.cosmocc.x86_64 |
| 93 | + asset_content_type: application/zip |
0 commit comments