Skip to content

Merge pull request #552 from sudo-bmitch/pr-define-tag #156

Merge pull request #552 from sudo-bmitch/pr-define-tag

Merge pull request #552 from sudo-bmitch/pr-define-tag #156

Workflow file for this run

name: release
on:
push:
branches:
- main
tags:
- v*
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Prepare
id: prepare
run: |
VERSION=${GITHUB_REF#refs/*/}
IMAGE=ghcr.io/${{ github.repository }}/conformance
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
elif [[ $GITHUB_REF == refs/heads/* ]]; then
VERSION=${GITHUB_REF#refs/heads/}
fi
VERSION=$(echo "${VERSION}" | sed -r 's#/+#-#g')
TAGS="${IMAGE}:${VERSION}"
if [[ $VERSION == "${{ github.event.repository.default_branch }}" ]]; then
GITSHA="$(git rev-parse --short HEAD)"
TAGS="${TAGS},${IMAGE}:${GITSHA}"
fi
if [[ $VERSION =~ ^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
MINOR=${VERSION%.*}
MAJOR=${MINOR%.*}
TAGS="${TAGS},${IMAGE}:${MINOR},${IMAGE}:${MAJOR}"
fi
echo ::set-output name=version::${VERSION}
echo ::set-output name=tags::${TAGS}
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
- name: Docker Login
uses: docker/login-action@v2
if: github.repository_owner == 'opencontainers'
with:
registry: ghcr.io
username: ${{ secrets.GHCR_USER }}
password: ${{ secrets.GHCR_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v3
with:
context: conformance/
# platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x
push: ${{ github.event_name != 'pull_request' && github.repository_owner == 'opencontainers' }}
tags: ${{ steps.prepare.outputs.tags }}
build-args: |
VERSION=${{ steps.prepare.outputs.version }}
labels: |
org.opencontainers.image.created=${{ steps.prepare.outputs.created }}
org.opencontainers.image.source=${{ github.repositoryUrl }}
org.opencontainers.image.version=${{ steps.prepare.outputs.version }}
org.opencontainers.image.revision=${{ github.sha }}