-
Notifications
You must be signed in to change notification settings - Fork 12
171 lines (145 loc) · 4.54 KB
/
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
name: "build"
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
schedule:
- cron: '0 0 1 * *'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
linux-images:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
image:
- env-alpine
- env-android:jdk17
- env-android:jdk21
- env-android:latest
- env-archlinux
- env-debian
- env-fedora
- env-flutter:android
- env-flutter:linux
- env-opensuse
- env-sphinx
- env-ubuntu:14.04
- env-ubuntu:16.04
- env-ubuntu:18.04
- env-ubuntu:20.04
- env-ubuntu:22.04
- env-ubuntu:24.04
- env-ubuntu:latest
- env-ubuntu:nolibs
- toolchain-aarch64-linux-gnu
- toolchain-arm-bcm2708hardfp-linux-gnueabi
- toolchain-arm-linux-gnueabihf
- toolchain-mips-openwrt-linux-atheros
- toolchain-linux-android
name: linux/${{ matrix.image }}
env:
CACHE_FROM: /tmp/dockercache
CACHE_TO: /tmp/dockercache-new
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Restore cache
uses: actions/cache/restore@v4
with:
path: ${{ env.CACHE_FROM }}
key: ${{ runner.os }}-${{ matrix.image }}
- name: Setup buildx
run: |
docker buildx create --use
- name: Detect env
if: |
github.repository_owner == 'roc-streaming' &&
github.event_name == 'push' &&
github.ref == 'refs/heads/main'
run: |
echo "ENABLE_PUSH=1" >> $GITHUB_ENV
- name: Run docker
run: |
set -x
if [[ $ENABLE_PUSH = 1 ]]; then \
docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASSWORD }}
./make.py --push \
--cache-from=${{ env.CACHE_FROM }} --cache-to=${{ env.CACHE_TO }} \
${{ matrix.image }}
else
./make.py \
--cache-from=${{ env.CACHE_FROM }} --cache-to=${{ env.CACHE_TO }} \
${{ matrix.image }}
fi
- name: Save cache
uses: actions/cache/save@v4
if: always()
with:
path: ${{ env.CACHE_TO }}
key: ${{ runner.os }}-${{ matrix.image }}-${{ github.sha }}
windows-images:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
image:
- env-flutter
name: windows/${{ matrix.image }}
env:
CACHE_DIR: C:\dockercache
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Restore cache
uses: actions/cache/restore@v4
with:
path: ${{ env.CACHE_DIR }}
key: ${{ runner.os }}-${{ matrix.image }}
- name: Load images
run: |
Set-PSDebug -Trace 1
if (Test-Path -Path ${{ env.CACHE_DIR }}\rocstreaming) {
Get-ChildItem -Path ${{ env.CACHE_DIR }}\rocstreaming -Filter *.tar | ForEach-Object {
docker load -i $_.FullName
Remove-Item $_.FullName
}
}
- name: Detect env
if: |
github.repository_owner == 'roc-streaming' &&
github.event_name == 'push' &&
github.ref == 'refs/heads/main'
run: |
echo "ENABLE_PUSH=1" >> $env:GITHUB_ENV
- name: Run docker
run: |
Set-PSDebug -Trace 1
if ($env:ENABLE_PUSH -eq "1") {
docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASSWORD }}
python make.py --push ${{ matrix.image }}
} else {
python make.py ${{ matrix.image }}
}
- name: Save images
if: always()
run: |
Set-PSDebug -Trace 1
New-Item -ItemType Directory -Path ${{ env.CACHE_DIR }}\rocstreaming -Force `
-ErrorAction SilentlyContinue
docker images --format '{{.Repository}}:{{.Tag}}' `
| Select-String -Pattern "^rocstreaming/${{ matrix.image }}(:|$)" | ForEach-Object {
$image = $_.ToString()
$file = $image -Replace ":", "-"
docker save $image -o "${{ env.CACHE_DIR }}\$file.tar"
}
- name: Save cache
uses: actions/cache/save@v4
if: always()
with:
path: ${{ env.CACHE_DIR }}
key: ${{ runner.os }}-${{ matrix.image }}-${{ github.sha }}