-
Notifications
You must be signed in to change notification settings - Fork 109
149 lines (125 loc) · 4.14 KB
/
ci-build.yml
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
144
145
146
147
148
149
name: CI Build
on:
push:
branches:
- '**'
tags-ignore:
- '**'
paths-ignore:
- 'docs/**'
- 'website/**'
# cancel older, redundant builds that haven't started yet
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
jobs:
ubuntu-build:
name: Build Linux AMD64 CLI
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: setup-go
uses: actions/setup-go@v5
with:
go-version-file: ./go.mod
- name: setup-node
uses: actions/setup-node@v4
with:
node-version: 20.x
- name: install ui node modules
shell: bash
run: npm install
working-directory: ui
- name: build ui
shell: bash
run: npm run build
working-directory: ui
env:
CI: "true"
- name: install agent ui node modules
shell: bash
run: npm install
working-directory: agent/agentUi
- name: build agent ui
shell: bash
run: npm run build
working-directory: agent/agentUi
- name: go install
shell: bash
run: go install -ldflags "-X github.com/openziti/zrok/build.Version=${{ github.ref }} -X github.com/openziti/zrok/build.Hash=${{ github.sha }}" ./...
- name: go test
shell: bash
run: go test -v ./...
- name: setup python
uses: actions/setup-python@v3
with:
python-version: '3.10'
- name: python deps
shell: bash
run: python -m pip install -U pip flake8
- name: python lint
shell: bash
run: flake8 sdk/python/sdk/zrok
- name: solve GOBIN
id: solve_go_bin
shell: bash
run: |
echo DEBUG: go_path="$(go env GOPATH)"
echo go_bin="$(go env GOPATH)/bin" >> $GITHUB_OUTPUT
- name: upload build artifact
uses: actions/upload-artifact@v4
with:
name: linux-amd64
path: ${{ steps.solve_go_bin.outputs.go_bin }}/zrok
if-no-files-found: error
# build a release candidate container image for branches named "main" or like "v*"
rc-container-build:
needs: ubuntu-build
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/v')
name: Build Release Candidate Container Image
runs-on: ubuntu-latest
steps:
- name: Set a container image tag from the branch name
id: slug
shell: bash
run: |
echo branch_tag=$(sed 's/[^a-z0-9_-]/__/gi' <<< "${GITHUB_REF#refs/heads/}") >> $GITHUB_OUTPUT
- name: Checkout Workspace
uses: actions/checkout@v4
- name: Download Branch Build Artifact
uses: actions/download-artifact@v4
with:
name: linux-amd64
path: ./dist/amd64/linux/
- name: Set Up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: amd64,arm64
- name: Set Up Docker BuildKit
id: buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKER_HUB_API_USER || secrets.DOCKER_HUB_API_USER }}
password: ${{ secrets.DOCKER_HUB_API_TOKEN }}
- name: Set Up Container Image Tags for zrok CLI Container
env:
ZROK_CONTAINER_IMAGE_REPO: ${{ vars.ZROK_CONTAINER_IMAGE_REPO || 'openziti/zrok' }}
ZROK_CONTAINER_IMAGE_TAG: ${{ steps.slug.outputs.branch_tag }}
id: tagprep_cli
shell: bash
run: |
echo DOCKER_TAGS="${ZROK_CONTAINER_IMAGE_REPO}:${ZROK_CONTAINER_IMAGE_TAG}" \
| tee -a $GITHUB_OUTPUT
- name: Build & Push Linux AMD64 CLI Container Image to Hub
uses: docker/build-push-action@v3
with:
builder: ${{ steps.buildx.outputs.name }}
context: ${{ github.workspace }}/
file: ${{ github.workspace }}/docker/images/zrok/Dockerfile
platforms: linux/amd64
tags: ${{ steps.tagprep_cli.outputs.DOCKER_TAGS }}
build-args: |
DOCKER_BUILD_DIR=./docker/images/zrok
ARTIFACTS_DIR=./dist
push: true