Debian Codegraph @

.github/workflows/container.yaml

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