-
Notifications
You must be signed in to change notification settings - Fork 4
142 lines (130 loc) · 3.97 KB
/
main.yaml
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# GitHub Workflows file
name: main
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
inputs:
version:
description: 'Version `x.y.z` (without leading `v`)'
type: string
required: true
jobs:
test:
name: Build and test
runs-on: ${{ matrix.os }}
strategy:
matrix:
build:
- linux
- windows
include:
- build: linux
os: ubuntu-20.04
config: gnu
- build: windows
os: windows-2019
config: cl
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Bazel cache
uses: actions/cache@v4
with:
path: |
~/.cache/bazel_build_cache
key: ${{ runner.os }}-bazel-test-${{ hashFiles('WORKSPACE') }}
restore-keys: |
${{ runner.os }}-bazel-test-
- name: Run bazel test
run: bazel test --config=${{ matrix.config }} --config=ci --disk_cache=~/.cache/bazel_build_cache //...
buildpkg:
name: Build Release Asset
runs-on: ${{ matrix.os }}
needs: test
strategy:
matrix:
build:
- linux
- macos-universal
include:
- build: linux
os: ubuntu-20.04
config: gnu
- build: macos-universal
os: macos-latest
config: gnu
- build: windows
os: windows-2019
config: cl
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Bazel cache
uses: actions/cache@v4
with:
path: |
~/.cache/bazel_build_cache
key: ${{ runner.os }}-bazel-buildpkg-${{ hashFiles('WORKSPACE') }}
restore-keys: |
${{ runner.os }}-bazel-buildpkg-
- name: Build Release Package
run: bazel build --config=${{ matrix.config }} --config=ci --config=release --//:version=${{ github.event.inputs.version || 0 }} --disk_cache=~/.cache/bazel_build_cache //:pkg
- name: Output file
id: outfile
run: |
from os import environ as env
from subprocess import check_output
cfg = env.get("CONFIG", "gnu")
v = env.get("VERSION", "0")
stdout = check_output(["bazel", "cquery", f"--config={cfg}", "--config=release", f"--//:version={v}", "--output=files", "//:pkg"], text= True)
lines = stdout.split('\n', 1)
path = lines[0].strip()
print(f"path={path}")
print(f"path={path}", file=open(env.get("GITHUB_OUTPUT", "stdout.txt"), "a"))
shell: python3 {0}
env:
CONFIG: ${{ matrix.config }}
VERSION: ${{ github.event.inputs.version || 0 }}
- name: Upload package artifact
uses: actions/upload-artifact@v4
with:
name: pkg-bazel-${{ matrix.build }}
path: ${{ steps.outfile.outputs.path }}
mkrelease:
name: Create Release
runs-on: ubuntu-latest
needs: buildpkg
if: github.event_name == 'workflow_dispatch'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download pkg artifact
uses: actions/download-artifact@v4
with:
pattern: pkg-*
merge-multiple: true
- name: Create Release
run: |
gh release create v${{ github.event.inputs.version }} --generate-notes *.deb *.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
format_check:
name: Style check
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Install LLVM
uses: KyleMayes/[email protected]
with:
version: "15.0.6"
- name: clang-format --version
run: clang-format --version
- name: Style check
run: ./tools/clang-format --dry-run -Werror