-
Notifications
You must be signed in to change notification settings - Fork 11
143 lines (132 loc) · 5.09 KB
/
Copy pathmain.yml
File metadata and controls
143 lines (132 loc) · 5.09 KB
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
143
# Copyright 2023 Aalyria Technologies, Inc., and its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Bazel
on:
pull_request: {}
push: {}
release:
types: [published]
workflow_dispatch:
inputs:
create_release:
description: "Create GitHub release"
type: boolean
default: false
ref:
description: "Release version ref"
required: false
type: string
jobs:
build-and-test:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.ref || github.ref }}
- uses: actions/cache@v4
with:
path: |
~/.cache/bazelisk
~/.cache/bazel
key: bazel-${{ hashFiles('common.bazelrc', '.bazelrc', '.bazelversion', 'WORKSPACE', 'MODULE.bazel', 'uv.lock') }}
restore-keys: bazel-
- run: bazelisk test //...
build-and-upload-tools:
needs: [build-and-test]
strategy:
matrix:
os: [linux, windows, darwin]
arch: [amd64, arm64]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.ref || github.ref }}
- uses: actions/cache@v4
with:
path: |
~/.cache/bazelisk
~/.cache/bazel
key: bazel-${{ hashFiles('common.bazelrc', '.bazelrc', '.bazelversion', 'WORKSPACE', 'MODULE.bazel', 'uv.lock') }}
restore-keys: bazel-
- run: bazel/tools/update_version_bzl.sh version.bzl
- name: Build artifacts
if: ${{ matrix.os != 'windows' }}
run: |
bazelisk build --stamp "--platforms=@rules_go//go/toolchain:${{ matrix.os }}_${{ matrix.arch }}" //tools/nbictl/cmd/nbictl
zip -j nbictl-${{ matrix.os }}-${{ matrix.arch }}.zip bazel-bin/tools/nbictl/cmd/nbictl/nbictl_/nbictl
bazelisk build --stamp "--platforms=@rules_go//go/toolchain:${{ matrix.os }}_${{ matrix.arch }}" //agent/cmd/agent
zip -j agent-${{ matrix.os }}-${{ matrix.arch }}.zip bazel-bin/agent/cmd/agent/agent_/agent
- name: Build artifacts - Windows
if: ${{ matrix.os == 'windows' }}
run: |
bazelisk build --stamp "--platforms=@rules_go//go/toolchain:${{ matrix.os }}_${{ matrix.arch }}" //tools/nbictl/cmd/nbictl
zip -j nbictl-${{ matrix.os }}-${{ matrix.arch }}.zip bazel-bin/tools/nbictl/cmd/nbictl/nbictl_/nbictl.exe
bazelisk build --stamp "--platforms=@rules_go//go/toolchain:${{ matrix.os }}_${{ matrix.arch }}" //agent/cmd/agent
zip -j agent-${{ matrix.os }}-${{ matrix.arch }}.zip bazel-bin/agent/cmd/agent/agent_/agent.exe
- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: tools-${{ matrix.os }}-${{ matrix.arch }}
path: "*.zip"
build-and-upload-docs:
needs: [build-and-test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.ref || github.ref }}
- uses: actions/cache@v4
with:
path: |
~/.cache/bazelisk
~/.cache/bazel
key: bazel-${{ hashFiles('common.bazelrc', '.bazelrc', '.bazelversion', 'WORKSPACE', 'MODULE.bazel', 'uv.lock') }}
restore-keys: bazel-
- run: bazelisk build "//api:api.html"
- name: Upload API docs
uses: actions/upload-artifact@v4
with:
name: api.html
path: |
bazel-bin/api/api.html/api.html
create-release:
needs: [build-and-upload-tools]
runs-on: ubuntu-latest
if: |
startsWith( github.ref, 'refs/heads/release-' ) ||
(github.event_name == 'workflow_dispatch' && inputs.create_release == true && inputs.ref != '')
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.ref || github.ref }}
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
pattern: tools-*
- run: bazel/tools/update_version_bzl.sh version.bzl
- name: Read version
id: version
run: echo "value=$(bazelisk run //:version)" >> $GITHUB_OUTPUT
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.version.outputs.value }}
name: Release v${{ steps.version.outputs.value }}
target_commitish: ${{ github.event.inputs.ref || github.ref }}
make_latest: legacy # determined based on the release creation date and higher semantic version
draft: false
files: |
tools-*/*.zip
generate_release_notes: true