-
Notifications
You must be signed in to change notification settings - Fork 0
92 lines (92 loc) · 3.41 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
name: build
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.20.5'
- name: Install Docker compose
run: |
set -euxo pipefail
docker_compose_version='v2.19.1'
# download.
# see https://github.com/docker/compose/releases
# see https://docs.docker.com/compose/cli-command/#install-on-linux
docker_compose_url="https://github.com/docker/compose/releases/download/$docker_compose_version/docker-compose-linux-$(uname -m)"
wget -qO /tmp/docker-compose "$docker_compose_url"
# install.
install -d ~/.docker/cli-plugins
install -m 555 /tmp/docker-compose ~/.docker/cli-plugins
rm /tmp/docker-compose
docker compose version
- name: Build (Linux)
run: |
set -euxo pipefail
mkdir -p tmp
docker compose build
docker build --tag turn-ping turn-ping
cd tmp
docker run --rm --entrypoint /bin/cat turn-ping /app/turn-ping >turn-ping
chmod +x turn-ping
tar czf turn-ping-linux.tgz turn-ping
- name: Build (Windows)
run: |
set -euxo pipefail
mkdir -p tmp
pushd turn-ping
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags="-s" -o ../tmp/turn-ping.exe
popd
cd tmp
tar czf turn-ping-windows.tgz turn-ping.exe
- name: Test
run: |
set -euxo pipefail
# replace the ip address.
ip_address="$(ip addr show eth0 | perl -n -e'/ inet (\d+(\.\d+)+)/ && print $1')"
sed -i -E "s,(external-ip|listening-ip)=.+,\1=$ip_address,g" turnserver.conf
# start coturn in background.
docker compose up -d
docker compose exec coturn sqlite3 /var/lib/coturn/turndb .schema
docker compose exec coturn turnadmin --userdb /var/lib/coturn/turndb --add-admin --realm coturn --user admin --password admin
docker compose exec coturn turnadmin --userdb /var/lib/coturn/turndb --add --realm coturn --user alice --password alice
docker compose exec coturn turnadmin --userdb /var/lib/coturn/turndb --list-admin
docker compose exec coturn turnadmin --userdb /var/lib/coturn/turndb --list
# test.
docker run --rm turn-ping -host $ip_address -port 3478 -realm coturn -user alice=alice -protocol tcp -count 2
docker run --rm turn-ping -host $ip_address -port 3478 -realm coturn -user alice=alice -protocol udp -count 2
# show logs.
docker compose logs
# teardown.
docker compose down
- name: Archive Artifacts
uses: actions/upload-artifact@v2
with:
name: turn-ping-artifacts
path: |
tmp/*.tgz
release:
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-22.04
needs:
- build
permissions:
contents: write
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: .artifacts
- name: Release
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
draft: true
artifacts: |
.artifacts/*/*