-
Notifications
You must be signed in to change notification settings - Fork 39
107 lines (101 loc) · 3.48 KB
/
release.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
name: "Release"
# @see https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#onpushpull_requestbranchestags
on:
push:
branches:
- 'ubuntu20-cache-cross-aarch64'
jobs:
env-prod:
name: setup env
runs-on: ubuntu-20.04
steps:
################################################################
# Git checkout
- name: Checkout repository
uses: actions/checkout@v3
################################################################
# Build
# The github.ref is, for example, refs/tags/dev @see https://docs.github.com/en/actions/learn-github-actions/contexts#github-context
# Generate variables like:
# SRS_TAG=dev
# @see https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
- name: Generate varaiables
id: srs-vars
run: |
SRS_TAG=$(echo ${{ github.ref }}| awk -F '/' '{print $3}')
echo "SRS_TAG=$SRS_TAG" >> $GITHUB_ENV
echo "::set-output name=SRS_TAG::${SRS_TAG}"
outputs:
SRS_TAG: ${{ steps.srs-vars.outputs.SRS_TAG }}
docker-prod:
name: for docker
runs-on: ubuntu-20.04
needs:
- env-prod
steps:
################################################################
- name: Covert output to env
run: |
SRS_TAG=${{ needs.env-prod.outputs.SRS_TAG }}
echo "SRS_TAG=$SRS_TAG" >> $GITHUB_ENV
################################################################
# Git checkout
- name: Checkout repository
uses: actions/checkout@v3
# See https://github.com/crazy-max/ghaction-docker-buildx#moved-to-docker-organization
# https://github.com/docker/setup-qemu-action
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
################################################################
# Docker
- name: Login docker hub
uses: docker/login-action@v2
with:
username: "${{ secrets.DOCKER_USERNAME }}"
password: "${{ secrets.DOCKER_PASSWORD }}"
- name: Build docker image
run: |
docker build --tag ossrs/srs:$SRS_TAG .
- name: Push to docker hub
run: |
docker push ossrs/srs:$SRS_TAG
outputs:
SRS_DOCKER_PROD_DONE: ok
aliyun-prod:
name: for aliyun
runs-on: ubuntu-20.04
needs:
- env-prod
- docker-prod
steps:
################################################################
- name: Covert output to env
run: |
SRS_TAG=${{ needs.env-prod.outputs.SRS_TAG }}
echo "SRS_TAG=$SRS_TAG" >> $GITHUB_ENV
################################################################
- name: Login aliyun hub
uses: docker/login-action@v2
with:
registry: registry.cn-hangzhou.aliyuncs.com
username: "${{ secrets.ACR_USERNAME }}"
password: "${{ secrets.ACR_PASSWORD }}"
- name: Copy to Aliyun registry
uses: akhilerm/[email protected]
with:
src: ossrs/srs:${{ env.SRS_TAG }}
dst: |
registry.cn-hangzhou.aliyuncs.com/ossrs/srs:${{ env.SRS_TAG }}
outputs:
SRS_ALIYUN_PROD_DONE: ok
done:
name: done
runs-on: ubuntu-20.04
needs:
- docker-prod
- aliyun-prod
steps:
- run: echo 'All done'