Skip to content

Commit

Permalink
remove duplicate tags + simplify tag variables
Browse files Browse the repository at this point in the history
  • Loading branch information
rhtenhove committed Feb 14, 2024
1 parent fda9d68 commit 2fef1c5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
37 changes: 18 additions & 19 deletions .github/workflows/container.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ on: [push, pull_request]

env:
GOLANG_VERSION: 1
IMAGE_NAME: ghcr.io/tomwright/dasel

name: Container build, test and publish
jobs:
Expand All @@ -12,14 +13,8 @@ jobs:
include:
- platform: alpine
platform-tag: latest
tags: |
ghcr.io/tomwright/dasel:alpine
ghcr.io/tomwright/dasel:${{ github.ref_name }}-alpine
- platform: debian
platform-tag: bookworm-slim
tags: |
ghcr.io/tomwright/dasel:latest
ghcr.io/tomwright/dasel:${{ github.ref_name }}
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -42,7 +37,7 @@ jobs:
build-args: |
GOLANG_VERSION=${{ env.GOLANG_VERSION }}
RELEASE_VERSION=${{ github.ref_name }}
MAJOR_VERSION=${{ steps.version.outputs.major }}
MAJOR_VERSION=${{ steps.version.outputs.major || 'v2' }}
TARGET_BASE_IMAGE=${{ matrix.platform }}:${{ matrix.platform-tag }}
tags: dasel:test
- name: Test
Expand All @@ -51,20 +46,26 @@ jobs:
- name: Set version tag variables
if: ${{ steps.version.outputs.is_valid == 'true' }}
run: |
IMAGE=${{ env.IMAGE_NAME }}
MAJOR=${{ steps.version.outputs.major }}
MINOR=${{ steps.version.outputs.minor }}
if [ "${{ matrix.platform }}" = "alpine" ]; then
echo "VERSIONED_TAGS<<EOF" >> $GITHUB_ENV
echo "ghcr.io/tomwright/dasel:${{ steps.version.outputs.major }}-alpine" >> $GITHUB_ENV
echo "ghcr.io/tomwright/dasel:${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}-alpine" >> $GITHUB_ENV
echo "${IMAGE}:${MAJOR}-alpine" >> $GITHUB_ENV
echo "${IMAGE}:${MAJOR}.${MINOR}-alpine" >> $GITHUB_ENV
echo "${IMAGE}:alpine" >> $GITHUB_ENV
echo "${IMAGE}:${{ github.ref_name }}-alpine" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
else
echo "VERSIONED_TAGS<<EOF" >> $GITHUB_ENV
echo "ghcr.io/tomwright/dasel:${{ github.ref_name }}-${{ matrix.platform-tag }}" >> $GITHUB_ENV
echo "ghcr.io/tomwright/dasel:${{ steps.version.outputs.major }}-${{ matrix.platform-tag }}" >> $GITHUB_ENV
echo "ghcr.io/tomwright/dasel:${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}-${{ matrix.platform-tag }}" >> $GITHUB_ENV
echo "ghcr.io/tomwright/dasel:${{ steps.version.outputs.major }}" >> $GITHUB_ENV
echo "ghcr.io/tomwright/dasel:${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}" >> $GITHUB_ENV
echo "ghcr.io/tomwright/dasel:${{ steps.version.outputs.major }}" >> $GITHUB_ENV
echo "ghcr.io/tomwright/dasel:${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}" >> $GITHUB_ENV
echo "${IMAGE}:latest" >> $GITHUB_ENV
echo "${IMAGE}:${{ github.ref_name }}" >> $GITHUB_ENV
echo "${IMAGE}:${{ github.ref_name }}-${{ matrix.platform-tag }}" >> $GITHUB_ENV
echo "${IMAGE}:${MAJOR}-${{ matrix.platform-tag }}" >> $GITHUB_ENV
echo "${IMAGE}:${MAJOR}.${MINOR}-${{ matrix.platform-tag }}" >> $GITHUB_ENV
echo "${IMAGE}:${MAJOR}" >> $GITHUB_ENV
echo "${IMAGE}:${MAJOR}.${MINOR}" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
fi
- name: Login to GitHub Container Registry
Expand All @@ -86,6 +87,4 @@ jobs:
RELEASE_VERSION=${{ github.ref_name }}
MAJOR_VERSION=${{ steps.version.outputs.major }}
TARGET_BASE_IMAGE=${{ matrix.platform }}:${{ matrix.platform-tag }}
tags: |
${{ matrix.tags }}
${{ env.VERSIONED_TAGS }}
tags: ${{ env.VERSIONED_TAGS }}
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ARG TARGET_BASE_IMAGE=debian:bookworm-slim
FROM golang:${GOLANG_VERSION} AS builder

ARG MAJOR_VERSION=v2
ARG RELEASE_VERSION
ARG RELEASE_VERSION=master
ARG CGO_ENABLED=0

COPY . .
Expand Down

0 comments on commit 2fef1c5

Please sign in to comment.