1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
|
on: [push, pull_request]
env:
GOLANG_VERSION: 1
IMAGE_NAME: ghcr.io/tomwright/dasel
name: Container build, test and publish
jobs:
container:
strategy:
fail-fast: true
matrix:
include:
- distro: alpine
distro-tag: latest
- distro: debian
distro-tag: bookworm-slim
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Process version tag
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
uses: nowsprinting/check-version-format-action@v4
id: version
with:
prefix: 'v'
- name: Build and Export
uses: docker/build-push-action@v5
with:
context: .
load: true
build-args: |
GOLANG_VERSION=${{ env.GOLANG_VERSION }}
RELEASE_VERSION=${{ github.ref_name }}
MAJOR_VERSION=${{ steps.version.outputs.major || 'v2' }}
TARGET_BASE_IMAGE=${{ matrix.distro }}:${{ matrix.distro-tag }}
tags: dasel:test
- name: Test
run: |
echo '{"hello": "World"}' | docker run -i --rm dasel:test -r json 'hello'
- name: Set version tag variables
if: ${{ steps.version.outputs.is_valid == 'true' }}
run: |
IMAGE=${{ env.IMAGE_NAME }}
MAJOR=${{ steps.version.outputs.major_without_prefix }}
MINOR=${{ steps.version.outputs.minor }}
PATCH=${{ steps.version.outputs.patch }}
if [ "${{ matrix.distro }}" = "alpine" ]; then
echo "VERSIONED_TAGS<<EOF" >> $GITHUB_ENV
echo "${IMAGE}:alpine" >> $GITHUB_ENV
echo "${IMAGE}:${{ github.ref_name }}-alpine" >> $GITHUB_ENV
echo "${IMAGE}:${MAJOR}-alpine" >> $GITHUB_ENV
echo "${IMAGE}:${MAJOR}.${MINOR}-alpine" >> $GITHUB_ENV
echo "${IMAGE}:${MAJOR}.${MINOR}.${PATCH}-alpine" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
else
echo "VERSIONED_TAGS<<EOF" >> $GITHUB_ENV
echo "${IMAGE}:latest" >> $GITHUB_ENV
echo "${IMAGE}:${{ github.ref_name }}" >> $GITHUB_ENV
echo "${IMAGE}:${{ github.ref_name }}-${{ matrix.distro-tag }}" >> $GITHUB_ENV
echo "${IMAGE}:${MAJOR}-${{ matrix.distro-tag }}" >> $GITHUB_ENV
echo "${IMAGE}:${MAJOR}.${MINOR}-${{ matrix.distro-tag }}" >> $GITHUB_ENV
echo "${IMAGE}:${MAJOR}.${MINOR}.${PATCH}-${{ matrix.distro-tag }}" >> $GITHUB_ENV
echo "${IMAGE}:${MAJOR}" >> $GITHUB_ENV
echo "${IMAGE}:${MAJOR}.${MINOR}" >> $GITHUB_ENV
echo "${IMAGE}:${MAJOR}.${MINOR}.${PATCH}" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
fi
- name: Login to GitHub Container Registry
if: ${{ steps.version.outputs.is_valid == 'true' }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: TomWright
password: ${{ secrets.GHCR_PAT }}
- name: Build and Push
if: ${{ steps.version.outputs.is_valid == 'true' }}
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
build-args: |
GOLANG_VERSION=${{ env.GOLANG_VERSION }}
RELEASE_VERSION=${{ github.ref_name }}
MAJOR_VERSION=${{ steps.version.outputs.major }}
TARGET_BASE_IMAGE=${{ matrix.distro }}:${{ matrix.distro-tag }}
tags: ${{ env.VERSIONED_TAGS }}
|