128 lines
4.1 KiB
YAML
128 lines
4.1 KiB
YAML
name: build
|
|
|
|
on: [push, pull_request]
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
continue-on-error: true
|
|
strategy:
|
|
matrix:
|
|
version:
|
|
- '0.20'
|
|
- '0.20/alpine'
|
|
- '0.19'
|
|
- '0.19/alpine'
|
|
- '0.18'
|
|
- '0.18/alpine'
|
|
- '0.17'
|
|
- '0.17/alpine'
|
|
- '0.16'
|
|
- '0.16/alpine'
|
|
- '0.13'
|
|
- '0.13/alpine'
|
|
- '0.12'
|
|
- '0.12/alpine'
|
|
- '0.11'
|
|
- '0.11/alpine'
|
|
steps:
|
|
- name: Prepare Docker build
|
|
id: prepare
|
|
run: |
|
|
function version { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; }
|
|
|
|
REPO=ruimarinho/bitcoin-core
|
|
BITCOIN_VERSION=${{matrix.version}}
|
|
LATEST_BITCOIN_MAJOR_VERSION=$(ls | grep 0 | sort -n | tail -n 1)
|
|
TAGS=()
|
|
PUSH=false
|
|
PLATFORMS="linux/amd64"
|
|
|
|
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
|
TAG=${GITHUB_REF#refs/tags/}
|
|
PUSH=true
|
|
|
|
if [[ ${BITCOIN_VERSION} == *"alpine"* ]]; then
|
|
TAGS+=("$REPO:$TAG-alpine")
|
|
else
|
|
TAGS+=("$REPO:$TAG")
|
|
fi
|
|
else
|
|
TAGS+=("$REPO:${BITCOIN_VERSION/\//-}")
|
|
|
|
if [ $(version ${BITCOIN_VERSION}) -ge $(version $LATEST_BITCOIN_MAJOR_VERSION) ] && [[ ${BITCOIN_VERSION} != *"alpine"* ]]; then
|
|
TAGS+=("$REPO:latest")
|
|
fi
|
|
|
|
if [ $GITHUB_REF == "refs/heads/master" ]; then
|
|
PUSH=true
|
|
fi
|
|
fi
|
|
|
|
if [[ ${BITCOIN_VERSION} != *"alpine"* ]] && [ $(version ${BITCOIN_VERSION}) -ge $(version "0.19") ]; then
|
|
PLATFORMS="linux/amd64,linux/arm/v7,linux/arm64"
|
|
fi
|
|
|
|
echo ::set-output name=build_date::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
|
|
echo ::set-output name=docker_platforms::${PLATFORMS}
|
|
echo ::set-output name=docker_username::ruimarinho
|
|
echo ::set-output name=push::${PUSH}
|
|
echo ::set-output name=tags::${TAGS[@]}
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: crazy-max/ghaction-docker-buildx@v1
|
|
|
|
- name: Checkout
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Login into Docker Hub
|
|
env:
|
|
DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }}
|
|
run: |
|
|
echo "${DOCKER_HUB_PASSWORD}" | docker login --username "${{ steps.prepare.outputs.docker_username }}" --password-stdin
|
|
|
|
- name: Build Docker image
|
|
run: |
|
|
TAGS=(${{ steps.prepare.outputs.tags }})
|
|
|
|
echo "Build date: ${{ steps.prepare.outputs.build_date }}"
|
|
echo "Docker platform: ${{ steps.prepare.outputs.docker_platforms }}"
|
|
echo "Push: ${{ steps.prepare.outputs.push }}"
|
|
echo "Tags: ${{ steps.prepare.outputs.tags }}"
|
|
|
|
echo docker buildx build --platform ${{ steps.prepare.outputs.docker_platforms }} \
|
|
--output "type=image,push=${{steps.prepare.outputs.push}}" \
|
|
--progress=plain \
|
|
--build-arg "BUILD_DATE=${{ steps.prepare.outputs.build_date }}" \
|
|
--build-arg "VCS_REF=${GITHUB_SHA::8}" \
|
|
$(printf "%s" "${TAGS[@]/#/ --tag }" ) \
|
|
${{ matrix.version }}/
|
|
|
|
docker buildx build --platform ${{ steps.prepare.outputs.docker_platforms }} \
|
|
--output "type=image,push=${{steps.prepare.outputs.push}}" \
|
|
--progress=plain \
|
|
--build-arg "BUILD_DATE=${{ steps.prepare.outputs.build_date }}" \
|
|
--build-arg "VCS_REF=${GITHUB_SHA::8}" \
|
|
$(printf "%s" "${TAGS[@]/#/ --tag }" ) \
|
|
${{ matrix.version }}/
|
|
|
|
- name: Check Docker image manifest
|
|
run: |
|
|
PUSH=${{ steps.prepare.outputs.push }}
|
|
|
|
if [ "${PUSH}" = false ]; then
|
|
echo "Image has not been pushed, skipping..."
|
|
exit 0
|
|
fi
|
|
|
|
TAGS=(${{ steps.prepare.outputs.tags }})
|
|
|
|
for TAG in "${TAGS[@]}"; do
|
|
echo "Inspecting ${TAG}"
|
|
docker buildx imagetools inspect "${TAG}"
|
|
done
|
|
|
|
- name: Clear Docker credentials
|
|
run: |
|
|
rm -f ${HOME}/.docker/config.json
|