-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from cytopia/release-0.3
Release v0.3
- Loading branch information
Showing
7 changed files
with
483 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
--- | ||
|
||
# ------------------------------------------------------------------------------------------------- | ||
# Job Name | ||
# ------------------------------------------------------------------------------------------------- | ||
name: build | ||
|
||
|
||
# ------------------------------------------------------------------------------------------------- | ||
# When to run | ||
# ------------------------------------------------------------------------------------------------- | ||
on: | ||
# Runs on Pull Requests | ||
pull_request: | ||
# Runs on Push | ||
push: | ||
|
||
|
||
# ------------------------------------------------------------------------------------------------- | ||
# What to run | ||
# ------------------------------------------------------------------------------------------------- | ||
jobs: | ||
build: | ||
name: "[ ${{ matrix.version }} ]" | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: False | ||
matrix: | ||
version: | ||
- 'latest' | ||
steps: | ||
|
||
# ------------------------------------------------------------ | ||
# Checkout repository | ||
# ------------------------------------------------------------ | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set variables | ||
id: vars | ||
run: | | ||
# Retrieve git info (tags, etc) | ||
git fetch --all | ||
# Branch, Tag or Commit | ||
GIT_TYPE="$( \ | ||
curl -sS https://raw.githubusercontent.com/cytopia/git-tools/master/git-info.sh \ | ||
| sh \ | ||
| grep '^GIT_TYPE' \ | ||
| sed 's|.*=||g' \ | ||
)" | ||
# Branch name, Tag name or Commit Hash | ||
GIT_SLUG="$( \ | ||
curl -sS https://raw.githubusercontent.com/cytopia/git-tools/master/git-info.sh \ | ||
| sh \ | ||
| grep '^GIT_NAME' \ | ||
| sed 's|.*=||g' \ | ||
)" | ||
# Docker Tag | ||
if [ "${GIT_TYPE}" = "BRANCH" ] && [ "${GIT_SLUG}" = "master" ]; then | ||
DOCKER_TAG="${VERSION}" | ||
else | ||
DOCKER_TAG="${VERSION}-${GIT_SLUG}" | ||
fi | ||
# Output | ||
echo "GIT_TYPE=${GIT_TYPE}" | ||
echo "GIT_SLUG=${GIT_SLUG}" | ||
echo "DOCKER_TAG=${DOCKER_TAG}" | ||
# Export variable | ||
# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#environment-files | ||
echo "GIT_TYPE=${GIT_TYPE}" >> ${GITHUB_ENV} | ||
echo "GIT_SLUG=${GIT_SLUG}" >> ${GITHUB_ENV} | ||
echo "DOCKER_TAG=${DOCKER_TAG}" >> ${GITHUB_ENV} | ||
env: | ||
VERSION: ${{ matrix.version }} | ||
|
||
|
||
# ------------------------------------------------------------ | ||
# Build | ||
# ------------------------------------------------------------ | ||
- name: Build | ||
run: | | ||
retry() { | ||
for n in $(seq ${RETRIES}); do | ||
echo "[${n}/${RETRIES}] ${*}"; | ||
if eval "${*}"; then | ||
echo "[SUCC] ${n}/${RETRIES}"; | ||
return 0; | ||
fi; | ||
sleep 2; | ||
echo "[FAIL] ${n}/${RETRIES}"; | ||
done; | ||
return 1; | ||
} | ||
retry make build VERSION=${VERSION} | ||
env: | ||
VERSION: ${{ matrix.version }} | ||
RETRIES: 20 | ||
|
||
- name: Test | ||
run: | | ||
retry() { | ||
for n in $(seq ${RETRIES}); do | ||
echo "[${n}/${RETRIES}] ${*}"; | ||
if eval "${*}"; then | ||
echo "[SUCC] ${n}/${RETRIES}"; | ||
return 0; | ||
fi; | ||
sleep 2; | ||
echo "[FAIL] ${n}/${RETRIES}"; | ||
done; | ||
return 1; | ||
} | ||
retry make test VERSION=${VERSION} | ||
git diff --quiet || { echo "Build Changes"; git diff; git status; false; } | ||
env: | ||
VERSION: ${{ matrix.version }} | ||
RETRIES: 20 | ||
|
||
|
||
# ------------------------------------------------------------ | ||
# Deploy | ||
# ------------------------------------------------------------ | ||
- name: Publish images (only repo owner) | ||
run: | | ||
retry() { | ||
for n in $(seq ${RETRIES}); do | ||
echo "[${n}/${RETRIES}] ${*}"; | ||
if eval "${*}"; then | ||
echo "[SUCC] ${n}/${RETRIES}"; | ||
return 0; | ||
fi; | ||
sleep ${PAUSE}; | ||
echo "[FAIL] ${n}/${RETRIES}"; | ||
done; | ||
return 1; | ||
} | ||
# Output | ||
echo "GIT_TYPE=${GIT_TYPE}" | ||
echo "GIT_SLUG=${GIT_SLUG}" | ||
echo "DOCKER_TAG=${DOCKER_TAG}" | ||
# Tag image | ||
retry make tag TAG=${DOCKER_TAG} | ||
docker images | ||
# Login and Push | ||
retry make login USER=${{ secrets.DOCKERHUB_USERNAME }} PASS=${{ secrets.DOCKERHUB_PASSWORD }} | ||
retry make push TAG=${DOCKER_TAG} | ||
env: | ||
RETRIES: 20 | ||
PAUSE: 10 | ||
# https://help.github.com/en/github/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions#functions | ||
if: github.event.pull_request.base.repo.id == github.event.pull_request.head.repo.id | ||
&& ( | ||
(github.event_name == 'schedule' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/'))) | ||
|| | ||
(github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/'))) | ||
|| | ||
(github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release-')) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
--- | ||
|
||
# ------------------------------------------------------------------------------------------------- | ||
# Job Name | ||
# ------------------------------------------------------------------------------------------------- | ||
name: lint | ||
|
||
|
||
# ------------------------------------------------------------------------------------------------- | ||
# When to run | ||
# ------------------------------------------------------------------------------------------------- | ||
on: | ||
# Runs on Pull Requests | ||
pull_request: | ||
|
||
|
||
# ------------------------------------------------------------------------------------------------- | ||
# What to run | ||
# ------------------------------------------------------------------------------------------------- | ||
jobs: | ||
lint: | ||
name: "Lint" | ||
runs-on: ubuntu-latest | ||
steps: | ||
# ------------------------------------------------------------ | ||
# Setup repository | ||
# ------------------------------------------------------------ | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
# ------------------------------------------------------------ | ||
# Lint repository | ||
# ------------------------------------------------------------ | ||
- name: Lint | ||
id: vars | ||
run: | | ||
make lint | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
--- | ||
|
||
# ------------------------------------------------------------------------------------------------- | ||
# Job Name | ||
# ------------------------------------------------------------------------------------------------- | ||
name: nightly | ||
|
||
|
||
# ------------------------------------------------------------------------------------------------- | ||
# When to run | ||
# ------------------------------------------------------------------------------------------------- | ||
on: | ||
# Runs daily | ||
schedule: | ||
- cron: '0 0 * * *' | ||
|
||
|
||
# ------------------------------------------------------------------------------------------------- | ||
# What to run | ||
# ------------------------------------------------------------------------------------------------- | ||
jobs: | ||
nightly: | ||
name: "[ ${{ matrix.version }} ] (ref: ${{ matrix.refs }})" | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: False | ||
matrix: | ||
version: | ||
- 'latest' | ||
refs: | ||
- 'master' | ||
- '0.3' | ||
steps: | ||
|
||
# ------------------------------------------------------------ | ||
# Checkout repository | ||
# ------------------------------------------------------------ | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
ref: ${{ matrix.refs }} | ||
|
||
- name: Set variables | ||
id: vars | ||
run: | | ||
# Retrieve git info (tags, etc) | ||
git fetch --all | ||
# Branch, Tag or Commit | ||
GIT_TYPE="$( \ | ||
curl -sS https://raw.githubusercontent.com/cytopia/git-tools/master/git-info.sh \ | ||
| sh \ | ||
| grep '^GIT_TYPE' \ | ||
| sed 's|.*=||g' \ | ||
)" | ||
# Branch name, Tag name or Commit Hash | ||
GIT_SLUG="$( \ | ||
curl -sS https://raw.githubusercontent.com/cytopia/git-tools/master/git-info.sh \ | ||
| sh \ | ||
| grep '^GIT_NAME' \ | ||
| sed 's|.*=||g' \ | ||
)" | ||
# Docker Tag | ||
if [ "${GIT_TYPE}" = "BRANCH" ] && [ "${GIT_SLUG}" = "master" ]; then | ||
DOCKER_TAG="${VERSION}" | ||
else | ||
DOCKER_TAG="${VERSION}-${GIT_SLUG}" | ||
fi | ||
# Output | ||
echo "GIT_TYPE=${GIT_TYPE}" | ||
echo "GIT_SLUG=${GIT_SLUG}" | ||
echo "DOCKER_TAG=${DOCKER_TAG}" | ||
# Export variable | ||
# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#environment-files | ||
echo "GIT_TYPE=${GIT_TYPE}" >> ${GITHUB_ENV} | ||
echo "GIT_SLUG=${GIT_SLUG}" >> ${GITHUB_ENV} | ||
echo "DOCKER_TAG=${DOCKER_TAG}" >> ${GITHUB_ENV} | ||
env: | ||
VERSION: ${{ matrix.version }} | ||
|
||
|
||
# ------------------------------------------------------------ | ||
# Build | ||
# ------------------------------------------------------------ | ||
- name: Build | ||
run: | | ||
retry() { | ||
for n in $(seq ${RETRIES}); do | ||
echo "[${n}/${RETRIES}] ${*}"; | ||
if eval "${*}"; then | ||
echo "[SUCC] ${n}/${RETRIES}"; | ||
return 0; | ||
fi; | ||
sleep 2; | ||
echo "[FAIL] ${n}/${RETRIES}"; | ||
done; | ||
return 1; | ||
} | ||
retry make build VERSION=${VERSION} | ||
env: | ||
VERSION: ${{ matrix.version }} | ||
RETRIES: 20 | ||
|
||
- name: Test | ||
run: | | ||
retry() { | ||
for n in $(seq ${RETRIES}); do | ||
echo "[${n}/${RETRIES}] ${*}"; | ||
if eval "${*}"; then | ||
echo "[SUCC] ${n}/${RETRIES}"; | ||
return 0; | ||
fi; | ||
sleep 2; | ||
echo "[FAIL] ${n}/${RETRIES}"; | ||
done; | ||
return 1; | ||
} | ||
retry make test VERSION=${VERSION} | ||
git diff --quiet || { echo "Build Changes"; git diff; git status; false; } | ||
env: | ||
VERSION: ${{ matrix.version }} | ||
RETRIES: 20 | ||
|
||
|
||
# ------------------------------------------------------------ | ||
# Deploy | ||
# ------------------------------------------------------------ | ||
- name: Publish images (only repo owner) | ||
run: | | ||
retry() { | ||
for n in $(seq ${RETRIES}); do | ||
echo "[${n}/${RETRIES}] ${*}"; | ||
if eval "${*}"; then | ||
echo "[SUCC] ${n}/${RETRIES}"; | ||
return 0; | ||
fi; | ||
sleep ${PAUSE}; | ||
echo "[FAIL] ${n}/${RETRIES}"; | ||
done; | ||
return 1; | ||
} | ||
# Output | ||
echo "GIT_TYPE=${GIT_TYPE}" | ||
echo "GIT_SLUG=${GIT_SLUG}" | ||
echo "DOCKER_TAG=${DOCKER_TAG}" | ||
# Tag image | ||
retry make tag TAG=${DOCKER_TAG} | ||
docker images | ||
# Login and Push | ||
retry make login USER=${{ secrets.DOCKERHUB_USERNAME }} PASS=${{ secrets.DOCKERHUB_PASSWORD }} | ||
retry make push TAG=${DOCKER_TAG} | ||
env: | ||
RETRIES: 20 | ||
PAUSE: 10 | ||
# https://help.github.com/en/github/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions#functions | ||
if: github.event.pull_request.base.repo.id == github.event.pull_request.head.repo.id | ||
&& ( | ||
(github.event_name == 'schedule' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/'))) | ||
|| | ||
(github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/'))) | ||
|| | ||
(github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release-')) | ||
) |
Oops, something went wrong.