0.3.0 🌈 #22
Workflow file for this run
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
--- | |
name: Build-Publish | |
on: | |
push: | |
branches: ["**"] | |
tags-ignore: ["**"] | |
release: | |
types: [released] | |
jobs: | |
build-publish: | |
name: "Python-${{ matrix.PYTHON }}" | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
PYTHON: | |
- 3.5.10 | |
- 3.6.15 | |
- 3.7.17 | |
- 3.8.19 | |
- 3.9.19 | |
- 3.10.14 | |
- 3.11.8 | |
- 3.12.2 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set Variables | |
id: vars | |
run: | | |
# Extract python subversion | |
PYTHON_MAJOR=$(echo $PYTHON | sed 's/\.[0-9]\+$//') | |
PYTHON_PATCH=$(echo $PYTHON | sed 's/^[0-9]\+\.[0-9]\+\.//') | |
# Build Docker image tag | |
if [ "${{ github.ref_type }}" = "tag" ]; then | |
TAG="${PYTHON_MAJOR}" | |
else | |
TAG="${PYTHON}" | |
fi | |
# Output for debugging | |
echo "TAG=${TAG}" | |
# Store GitHub Action env vars | |
echo "PYTHON_MAJOR=${PYTHON_MAJOR}" >> "${GITHUB_ENV}" | |
echo "PYTHON_PATCH=${PYTHON_PATCH}" >> "${GITHUB_ENV}" | |
echo "TAG=${TAG}" >> "${GITHUB_ENV}" | |
env: | |
PYTHON: ${{ matrix.PYTHON }} | |
- 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 PYTHON_MAJOR=${PYTHON_MAJOR} PYTHON_PATCH=${PYTHON_PATCH} | |
env: | |
RETRIES: 5 | |
- 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 PYTHON_MAJOR=${PYTHON_MAJOR} PYTHON_PATCH=${PYTHON_PATCH} | |
env: | |
RETRIES: 5 | |
- name: Tag | |
run: | | |
make tag TAG=${TAG} | |
docker images | |
- name: Login | |
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 login DOCKER_USER=${{ secrets.DOCKER_USERNAME }} DOCKER_PASS=${{ secrets.DOCKER_PASSWORD }} | |
env: | |
RETRIES: 5 | |
# 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_name == 'master') | |
|| | |
(github.event_name == 'push' && github.ref_name == 'master') | |
|| | |
(github.event_name == 'release' && github.event.action == 'released') | |
) | |
- name: Push | |
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 push TAG=${TAG} | |
env: | |
RETRIES: 5 | |
# 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_name == 'master') | |
|| | |
(github.event_name == 'push' && github.ref_name == 'master') | |
|| | |
(github.event_name == 'release' && github.event.action == 'released') | |
) |