summaryrefslogtreecommitdiff
path: root/.github/workflows/cosmocc.yml
blob: 1857e546e38dbe286f54be9e2043dbd35bdfba71 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
name: Cosmocc

on:
  pull_request:
  push:
  release:
    types: [published]

jobs:
  build:
    strategy:
      matrix:
        os: [ubuntu-latest, macos-13]
        arch: [x86_64]

    runs-on: ${{ matrix.os }}

    concurrency:
      group: ${{ github.ref }}-${{ github.base_ref }}-${{ github.head_ref }}-Cosmocc-${{ matrix.os }}-${{ matrix.arch }}
      cancel-in-progress: true

    steps:
      - uses: actions/checkout@v2
        with:
          submodules: true

      - uses: little-core-labs/[email protected]
        id: tagName

      - name: Prepare local xmake
        run: cp -rf . ../xmake-source

      - uses: xmake-io/github-action-setup-xmake@v1
        with:
          xmake-version: local#../xmake-source

      - uses: bjia56/setup-cosmocc@main
        with:
          version: "4.0.2"

      - name: Build
        run: |
          cd core
          xmake f -p linux --cosmocc=y --embed=y -y -cvD
          xmake -v
          cd ..

      - name: Prepare (Linux)
        if: matrix.os == 'ubuntu-latest'
        run: |
          sudo apt update
          sudo apt install -y ruby ruby-dev rubygems build-essential llvm libc++-dev
          sudo apt install -y libgl1-mesa-dev libglu1-mesa-dev
          clang --version

      - name: Prepare (macOS)
        if: matrix.os == 'macos-13'
        run: |
          brew install dmd
          brew install dub

      # In the tests, cmake tries to use make from the cosmopolitan toolchain and fails, so uninstall it
      - name: Remove cosmocc
        if: matrix.os == 'macos-13'
        run: |
          INSTALL_DIR="${{runner.temp}}/cosmocc-4.0.2"
          echo "Removing cosmocc from PATH"
          echo "::remove-path::${INSTALL_DIR}/bin"
          rm -r "${INSTALL_DIR}"

      - name: Tests
        run: |
          ls -l core/build/
          core/build/xmake --version
          core/build/xmake lua -v -D tests/run.lua

      - name: Artifact
        if: matrix.os == 'ubuntu-latest'
        uses: actions/upload-artifact@v4
        with:
          name: xmake-bundle.cosmocc
          path: core/build/xmake

      - name: Publish bundle binary
        if: github.event.action == 'published' && matrix.os == 'ubuntu-latest'
        uses: actions/[email protected]
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ github.event.release.upload_url }}
          asset_path: core/build/xmake
          asset_name: xmake-bundle-${{ steps.tagName.outputs.tag }}.cosmocc
          asset_content_type: application/zip