on 7fbc464 help sign in
114 lines 3.1 kB history raw
1name: Build
3on:
4 push:
5 branches: [master]
6 pull_request:
8env:
9 CARGO_TERM_COLOR: always
11jobs:
12 build:
13 strategy:
14 fail-fast: false
15 matrix:
16 include:
17 - runner: ubuntu-latest
18 name: linux-x86_64
19 musl-target: x86_64-unknown-linux-musl
20 - runner: ubuntu-24.04-arm
21 name: linux-arm64
22 musl-target: aarch64-unknown-linux-musl
23 - runner: macos-latest
24 name: macos-arm64
25 - runner: macos-13
26 name: macos-x86_64
27 runs-on: ${{ matrix.runner }}
28 steps:
29 - uses: actions/checkout@v4
31 - uses: actions/checkout@v4
32 with:
33 repository: ilyakooo0/knot
34 path: knot
36 - uses: dtolnay/rust-toolchain@stable
38 - name: Install musl toolchain
39 if: runner.os == 'Linux'
40 run: |
41 sudo apt-get update
42 sudo apt-get install -y musl-tools
43 rustup target add ${{ matrix.musl-target }}
45 - uses: actions/cache@v4
46 with:
47 path: |
48 ~/.cargo/registry
49 ~/.cargo/git
50 knot/target
51 key: ${{ matrix.name }}-cargo-${{ hashFiles('knot/Cargo.lock') }}
53 - name: Build knotc
54 working-directory: knot
55 run: cargo build --release -p knot-compiler
57 - name: Build musl runtime
58 if: runner.os == 'Linux'
59 working-directory: knot
60 run: cargo build --release -p knot-runtime --target ${{ matrix.musl-target }}
62 - name: Compile server (Linux static)
63 if: runner.os == 'Linux'
64 run: |
65 printf '#!/bin/sh\nexec musl-gcc -static "$@"\n' > /tmp/static-cc
66 chmod +x /tmp/static-cc
67 CC=/tmp/static-cc \
68 KNOT_RUNTIME_LIB=${{ github.workspace }}/knot/target/${{ matrix.musl-target }}/release/libknot_runtime.a \
69 ./knot/target/release/knotc build server.knot
71 - name: Compile server (macOS)
72 if: runner.os == 'macOS'
73 run: ./knot/target/release/knotc build server.knot
75 - name: Verify binary
76 run: file server
78 - uses: actions/upload-artifact@v4
79 with:
80 name: server-${{ matrix.name }}
81 path: server
83 release:
84 needs: build
85 if: github.ref == 'refs/heads/master' && github.event_name == 'push'
86 runs-on: ubuntu-latest
87 permissions:
88 contents: write
89 steps:
90 - uses: actions/download-artifact@v4
92 - uses: actions/checkout@v4
93 with:
94 path: repo
96 - name: Generate version
97 id: version
98 run: echo "tag=$(git -C repo log -1 --format='%cd' --date='format:%Y.%m.%d.%H%M')" >> "$GITHUB_OUTPUT"
100 - name: Prepare release assets
101 run: |
102 for dir in server-*/; do
103 name="${dir%/}"
104 mv "${dir}server" "${name}.tmp"
105 rm -rf "$dir"
106 mv "${name}.tmp" "$name"
107 done
108 chmod +x server-*
110 - uses: softprops/action-gh-release@v2
111 with:
112 tag_name: ${{ steps.version.outputs.tag }}
113 name: ${{ steps.version.outputs.tag }}
114 files: server-*