docker-bitcoin-core/.github/workflows/build.yaml

136 lines
4.6 KiB
YAML
Raw Permalink Normal View History

2020-06-07 15:50:21 +00:00
name: build
2020-06-08 10:55:29 +00:00
on: [push, pull_request]
2020-06-07 15:50:21 +00:00
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
version:
2022-12-01 18:01:33 +00:00
- '24'
- '24/alpine'
2022-04-26 01:43:52 +00:00
- '23'
- '23/alpine'
2021-09-15 15:33:17 +00:00
- '22'
- '22/alpine'
2020-12-05 12:26:11 +00:00
- '0.21'
- '0.21/alpine'
2020-06-07 15:50:21 +00:00
- '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'
fail-fast: false
2020-06-07 15:50:21 +00:00
steps:
- name: Set up Docker Buildx
uses: crazy-max/ghaction-docker-buildx@v1
- name: Checkout
uses: actions/checkout@v2
2020-06-07 15:50:21 +00:00
- name: Prepare Docker build
id: prepare
run: |
function version { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; }
BITCOIN_VERSION=${{matrix.version}}
2021-09-15 15:33:17 +00:00
LATEST_BITCOIN_MAJOR_VERSION=$(find . -type d -maxdepth 1 -not -path '*/\.*' | sort -n | tail -n 1 | cut -c 3-)
2020-06-07 15:50:21 +00:00
PLATFORMS="linux/amd64"
PUSH=false
REPO=ruimarinho/bitcoin-core
TAGS=()
2020-06-07 15:50:21 +00:00
if [[ $GITHUB_REF == refs/tags/* ]]; then
TAG=${GITHUB_REF#refs/tags/}
2020-06-08 00:36:42 +00:00
PUSH=true
2020-06-07 15:50:21 +00:00
if [[ ${BITCOIN_VERSION} == *"alpine"* ]]; then
TAGS+=("$REPO:$TAG-alpine")
else
TAGS+=("$REPO:$TAG")
fi
2021-09-15 15:33:17 +00:00
if [ $(version ${TAG}) -ge $(version "22.0") ]; then
TAG_MAJOR_MINOR=$(echo $TAG | cut -c -2)"
else
TAG_MAJOR_MINOR=$(echo $TAG | cut -c -4)"
fi
2020-09-16 09:23:39 +00:00
if [ $(version ${TAG_MAJOR_MINOR}) -ne $(version ${BITCOIN_VERSION}) ]; then
echo "Skipping build of base image $BITCOIN_VERSION/ as ${TAG} is targeted at ${TAG_MAJOR_MINOR}/"
exit 0
fi
2020-06-08 01:08:10 +00:00
else
TAGS=("$REPO:${BITCOIN_VERSION/\//-}")
if [ $(version ${BITCOIN_VERSION}) -ge $(version ${LATEST_BITCOIN_MAJOR_VERSION}) ]; then
echo "Version $(version ${BITCOIN_VERSION}) is greater than or equal to $(version ${LATEST_BITCOIN_MAJOR_VERSION}), tagging as latest"
2020-06-08 00:36:42 +00:00
if [[ ${BITCOIN_VERSION} != *"alpine"* ]]; then
TAGS+=("$REPO:latest")
else
TAGS+=("$REPO:alpine")
fi
2020-06-08 00:36:42 +00:00
fi
2020-06-08 01:08:10 +00:00
if [ $GITHUB_REF == "refs/heads/master" ]; then
PUSH=true
fi
2020-06-07 15:50:21 +00:00
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[@]}
2021-02-08 00:21:51 +00:00
echo ::set-output name=build::true
2021-11-22 22:49:27 +00:00
- if: ${{ steps.prepare.outputs.build }} == 'true'
name: Login into Docker Hub
uses: docker/login-action@v1
with:
username: ruimarinho
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
2020-06-07 15:50:21 +00:00
2021-11-22 22:49:27 +00:00
- if: ${{ steps.prepare.outputs.build }} == 'true'
name: Build Docker image
2020-06-07 15:50:21 +00:00
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 }}/