-
Notifications
You must be signed in to change notification settings - Fork 22
154 lines (134 loc) · 4.28 KB
/
ci.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
150
151
152
153
154
name: CI
on:
workflow_dispatch:
pull_request:
push:
schedule:
# Run every 6 days to help us stay on our toes
- cron: '0 0 */6 * *'
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Install dependencies
run: |
sudo apt install -y xvfb yarn
- name: Run yarn
run: |
yarn install --frozen-lockfile --network-timeout 300000
yarn lint
yarn typecheck
yarn build
xvfb-run --auto-servernum yarn test:ci
deploy-electron:
needs: test
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: macos-latest
suffix: macos
extension: dmg
- os: ubuntu-latest
suffix: linux
extension: AppImage
- os: windows-latest
suffix: windows
extension: exe
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
# Use node to install yarn in all OSs
- name: Install node
uses: actions/setup-node@v3
with:
node-version: 16
- name: Build electron
run: |
npm install --global yarn
yarn install --frozen-lockfile --network-timeout 300000
yarn build
yarn deploy:electron
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: cockpit-${{ matrix.suffix }}
path: dist/cockpit*.${{ matrix.extension }}
if-no-files-found: error
- name: Upload Release
uses: svenstaro/upload-release-action@v2
if: startsWith(github.ref, 'refs/tags/') && success()
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: dist/cockpit*.${{ matrix.extension }}
tag: ${{ github.ref }}
overwrite: true
prerelease: true
file_glob: true
deploy-blueos-extension:
needs: test
runs-on: ubuntu-latest
env:
PLATFORMS: "linux/arm/v7,linux/arm64/v8,linux/amd64"
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
steps:
- name: Login to Docker Hub
if: success() && github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Prepare
id: prepare
run: |
# Deploy image with the name of the branch, if the build is a git tag, replace tag with the tag name.
# If git tag matches semver, append latest tag to the push.
DOCKER_IMAGE=${DOCKER_USERNAME:-bluerobotics}/cockpit
VERSION=${GITHUB_REF##*/}
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
fi
TAGS="--tag ${DOCKER_IMAGE}:${VERSION}"
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
TAGS="$TAGS --tag ${DOCKER_IMAGE}:latest"
fi
echo "docker_image=${DOCKER_IMAGE}" >> $GITHUB_OUTPUT
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "buildx_args=${TAGS} --file Dockerfile ." >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: all
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
version: latest
- name: Docker Buildx (build)
run: |
docker buildx build \
--output "type=image,push=false" \
--platform $PLATFORMS \
${{ steps.prepare.outputs.buildx_args }}
- name: Docker Buildx (push)
if: success() && github.event_name != 'pull_request'
run: |
docker buildx build \
--output "type=image,push=true" \
--platform $PLATFORMS \
${{ steps.prepare.outputs.buildx_args }}
- name: Inspect image
if: always() && github.event_name != 'pull_request'
run: |
docker buildx imagetools \
inspect ${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.version }}