Skip to content

Commit ba6494a

Browse files
authored
Merge pull request #8 from cytopia/release-0.3
Release v0.3
2 parents 70e2311 + 8934622 commit ba6494a

File tree

7 files changed

+483
-97
lines changed

7 files changed

+483
-97
lines changed

.github/workflows/build.yml

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
---
2+
3+
# -------------------------------------------------------------------------------------------------
4+
# Job Name
5+
# -------------------------------------------------------------------------------------------------
6+
name: build
7+
8+
9+
# -------------------------------------------------------------------------------------------------
10+
# When to run
11+
# -------------------------------------------------------------------------------------------------
12+
on:
13+
# Runs on Pull Requests
14+
pull_request:
15+
# Runs on Push
16+
push:
17+
18+
19+
# -------------------------------------------------------------------------------------------------
20+
# What to run
21+
# -------------------------------------------------------------------------------------------------
22+
jobs:
23+
build:
24+
name: "[ ${{ matrix.version }} ]"
25+
runs-on: ubuntu-latest
26+
strategy:
27+
fail-fast: False
28+
matrix:
29+
version:
30+
- 'latest'
31+
steps:
32+
33+
# ------------------------------------------------------------
34+
# Checkout repository
35+
# ------------------------------------------------------------
36+
- name: Checkout repository
37+
uses: actions/checkout@v2
38+
with:
39+
fetch-depth: 0
40+
41+
- name: Set variables
42+
id: vars
43+
run: |
44+
# Retrieve git info (tags, etc)
45+
git fetch --all
46+
47+
# Branch, Tag or Commit
48+
GIT_TYPE="$( \
49+
curl -sS https://raw.githubusercontent.com/cytopia/git-tools/master/git-info.sh \
50+
| sh \
51+
| grep '^GIT_TYPE' \
52+
| sed 's|.*=||g' \
53+
)"
54+
# Branch name, Tag name or Commit Hash
55+
GIT_SLUG="$( \
56+
curl -sS https://raw.githubusercontent.com/cytopia/git-tools/master/git-info.sh \
57+
| sh \
58+
| grep '^GIT_NAME' \
59+
| sed 's|.*=||g' \
60+
)"
61+
# Docker Tag
62+
if [ "${GIT_TYPE}" = "BRANCH" ] && [ "${GIT_SLUG}" = "master" ]; then
63+
DOCKER_TAG="${VERSION}"
64+
else
65+
DOCKER_TAG="${VERSION}-${GIT_SLUG}"
66+
fi
67+
68+
# Output
69+
echo "GIT_TYPE=${GIT_TYPE}"
70+
echo "GIT_SLUG=${GIT_SLUG}"
71+
echo "DOCKER_TAG=${DOCKER_TAG}"
72+
73+
# Export variable
74+
# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#environment-files
75+
echo "GIT_TYPE=${GIT_TYPE}" >> ${GITHUB_ENV}
76+
echo "GIT_SLUG=${GIT_SLUG}" >> ${GITHUB_ENV}
77+
echo "DOCKER_TAG=${DOCKER_TAG}" >> ${GITHUB_ENV}
78+
env:
79+
VERSION: ${{ matrix.version }}
80+
81+
82+
# ------------------------------------------------------------
83+
# Build
84+
# ------------------------------------------------------------
85+
- name: Build
86+
run: |
87+
retry() {
88+
for n in $(seq ${RETRIES}); do
89+
echo "[${n}/${RETRIES}] ${*}";
90+
if eval "${*}"; then
91+
echo "[SUCC] ${n}/${RETRIES}";
92+
return 0;
93+
fi;
94+
sleep 2;
95+
echo "[FAIL] ${n}/${RETRIES}";
96+
done;
97+
return 1;
98+
}
99+
retry make build VERSION=${VERSION}
100+
env:
101+
VERSION: ${{ matrix.version }}
102+
RETRIES: 20
103+
104+
- name: Test
105+
run: |
106+
retry() {
107+
for n in $(seq ${RETRIES}); do
108+
echo "[${n}/${RETRIES}] ${*}";
109+
if eval "${*}"; then
110+
echo "[SUCC] ${n}/${RETRIES}";
111+
return 0;
112+
fi;
113+
sleep 2;
114+
echo "[FAIL] ${n}/${RETRIES}";
115+
done;
116+
return 1;
117+
}
118+
retry make test VERSION=${VERSION}
119+
git diff --quiet || { echo "Build Changes"; git diff; git status; false; }
120+
env:
121+
VERSION: ${{ matrix.version }}
122+
RETRIES: 20
123+
124+
125+
# ------------------------------------------------------------
126+
# Deploy
127+
# ------------------------------------------------------------
128+
- name: Publish images (only repo owner)
129+
run: |
130+
retry() {
131+
for n in $(seq ${RETRIES}); do
132+
echo "[${n}/${RETRIES}] ${*}";
133+
if eval "${*}"; then
134+
echo "[SUCC] ${n}/${RETRIES}";
135+
return 0;
136+
fi;
137+
sleep ${PAUSE};
138+
echo "[FAIL] ${n}/${RETRIES}";
139+
done;
140+
return 1;
141+
}
142+
143+
# Output
144+
echo "GIT_TYPE=${GIT_TYPE}"
145+
echo "GIT_SLUG=${GIT_SLUG}"
146+
echo "DOCKER_TAG=${DOCKER_TAG}"
147+
148+
# Tag image
149+
retry make tag TAG=${DOCKER_TAG}
150+
docker images
151+
152+
# Login and Push
153+
retry make login USER=${{ secrets.DOCKERHUB_USERNAME }} PASS=${{ secrets.DOCKERHUB_PASSWORD }}
154+
retry make push TAG=${DOCKER_TAG}
155+
env:
156+
RETRIES: 20
157+
PAUSE: 10
158+
# https://help.github.com/en/github/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions#functions
159+
if: github.event.pull_request.base.repo.id == github.event.pull_request.head.repo.id
160+
&& (
161+
(github.event_name == 'schedule' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')))
162+
||
163+
(github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')))
164+
||
165+
(github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release-'))
166+
)

.github/workflows/lint.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
3+
# -------------------------------------------------------------------------------------------------
4+
# Job Name
5+
# -------------------------------------------------------------------------------------------------
6+
name: lint
7+
8+
9+
# -------------------------------------------------------------------------------------------------
10+
# When to run
11+
# -------------------------------------------------------------------------------------------------
12+
on:
13+
# Runs on Pull Requests
14+
pull_request:
15+
16+
17+
# -------------------------------------------------------------------------------------------------
18+
# What to run
19+
# -------------------------------------------------------------------------------------------------
20+
jobs:
21+
lint:
22+
name: "Lint"
23+
runs-on: ubuntu-latest
24+
steps:
25+
# ------------------------------------------------------------
26+
# Setup repository
27+
# ------------------------------------------------------------
28+
- name: Checkout repository
29+
uses: actions/checkout@v2
30+
with:
31+
fetch-depth: 0
32+
33+
# ------------------------------------------------------------
34+
# Lint repository
35+
# ------------------------------------------------------------
36+
- name: Lint
37+
id: vars
38+
run: |
39+
make lint
40+

.github/workflows/nightly.yml

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
---
2+
3+
# -------------------------------------------------------------------------------------------------
4+
# Job Name
5+
# -------------------------------------------------------------------------------------------------
6+
name: nightly
7+
8+
9+
# -------------------------------------------------------------------------------------------------
10+
# When to run
11+
# -------------------------------------------------------------------------------------------------
12+
on:
13+
# Runs daily
14+
schedule:
15+
- cron: '0 0 * * *'
16+
17+
18+
# -------------------------------------------------------------------------------------------------
19+
# What to run
20+
# -------------------------------------------------------------------------------------------------
21+
jobs:
22+
nightly:
23+
name: "[ ${{ matrix.version }} ] (ref: ${{ matrix.refs }})"
24+
runs-on: ubuntu-latest
25+
strategy:
26+
fail-fast: False
27+
matrix:
28+
version:
29+
- 'latest'
30+
refs:
31+
- 'master'
32+
- '0.3'
33+
steps:
34+
35+
# ------------------------------------------------------------
36+
# Checkout repository
37+
# ------------------------------------------------------------
38+
- name: Checkout repository
39+
uses: actions/checkout@v2
40+
with:
41+
fetch-depth: 0
42+
ref: ${{ matrix.refs }}
43+
44+
- name: Set variables
45+
id: vars
46+
run: |
47+
# Retrieve git info (tags, etc)
48+
git fetch --all
49+
50+
# Branch, Tag or Commit
51+
GIT_TYPE="$( \
52+
curl -sS https://raw.githubusercontent.com/cytopia/git-tools/master/git-info.sh \
53+
| sh \
54+
| grep '^GIT_TYPE' \
55+
| sed 's|.*=||g' \
56+
)"
57+
# Branch name, Tag name or Commit Hash
58+
GIT_SLUG="$( \
59+
curl -sS https://raw.githubusercontent.com/cytopia/git-tools/master/git-info.sh \
60+
| sh \
61+
| grep '^GIT_NAME' \
62+
| sed 's|.*=||g' \
63+
)"
64+
# Docker Tag
65+
if [ "${GIT_TYPE}" = "BRANCH" ] && [ "${GIT_SLUG}" = "master" ]; then
66+
DOCKER_TAG="${VERSION}"
67+
else
68+
DOCKER_TAG="${VERSION}-${GIT_SLUG}"
69+
fi
70+
71+
# Output
72+
echo "GIT_TYPE=${GIT_TYPE}"
73+
echo "GIT_SLUG=${GIT_SLUG}"
74+
echo "DOCKER_TAG=${DOCKER_TAG}"
75+
76+
# Export variable
77+
# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#environment-files
78+
echo "GIT_TYPE=${GIT_TYPE}" >> ${GITHUB_ENV}
79+
echo "GIT_SLUG=${GIT_SLUG}" >> ${GITHUB_ENV}
80+
echo "DOCKER_TAG=${DOCKER_TAG}" >> ${GITHUB_ENV}
81+
env:
82+
VERSION: ${{ matrix.version }}
83+
84+
85+
# ------------------------------------------------------------
86+
# Build
87+
# ------------------------------------------------------------
88+
- name: Build
89+
run: |
90+
retry() {
91+
for n in $(seq ${RETRIES}); do
92+
echo "[${n}/${RETRIES}] ${*}";
93+
if eval "${*}"; then
94+
echo "[SUCC] ${n}/${RETRIES}";
95+
return 0;
96+
fi;
97+
sleep 2;
98+
echo "[FAIL] ${n}/${RETRIES}";
99+
done;
100+
return 1;
101+
}
102+
retry make build VERSION=${VERSION}
103+
env:
104+
VERSION: ${{ matrix.version }}
105+
RETRIES: 20
106+
107+
- name: Test
108+
run: |
109+
retry() {
110+
for n in $(seq ${RETRIES}); do
111+
echo "[${n}/${RETRIES}] ${*}";
112+
if eval "${*}"; then
113+
echo "[SUCC] ${n}/${RETRIES}";
114+
return 0;
115+
fi;
116+
sleep 2;
117+
echo "[FAIL] ${n}/${RETRIES}";
118+
done;
119+
return 1;
120+
}
121+
retry make test VERSION=${VERSION}
122+
git diff --quiet || { echo "Build Changes"; git diff; git status; false; }
123+
env:
124+
VERSION: ${{ matrix.version }}
125+
RETRIES: 20
126+
127+
128+
# ------------------------------------------------------------
129+
# Deploy
130+
# ------------------------------------------------------------
131+
- name: Publish images (only repo owner)
132+
run: |
133+
retry() {
134+
for n in $(seq ${RETRIES}); do
135+
echo "[${n}/${RETRIES}] ${*}";
136+
if eval "${*}"; then
137+
echo "[SUCC] ${n}/${RETRIES}";
138+
return 0;
139+
fi;
140+
sleep ${PAUSE};
141+
echo "[FAIL] ${n}/${RETRIES}";
142+
done;
143+
return 1;
144+
}
145+
146+
# Output
147+
echo "GIT_TYPE=${GIT_TYPE}"
148+
echo "GIT_SLUG=${GIT_SLUG}"
149+
echo "DOCKER_TAG=${DOCKER_TAG}"
150+
151+
# Tag image
152+
retry make tag TAG=${DOCKER_TAG}
153+
docker images
154+
155+
# Login and Push
156+
retry make login USER=${{ secrets.DOCKERHUB_USERNAME }} PASS=${{ secrets.DOCKERHUB_PASSWORD }}
157+
retry make push TAG=${DOCKER_TAG}
158+
env:
159+
RETRIES: 20
160+
PAUSE: 10
161+
# https://help.github.com/en/github/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions#functions
162+
if: github.event.pull_request.base.repo.id == github.event.pull_request.head.repo.id
163+
&& (
164+
(github.event_name == 'schedule' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')))
165+
||
166+
(github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')))
167+
||
168+
(github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release-'))
169+
)

0 commit comments

Comments
 (0)