Merge pull request #562 from sudo-bmitch/pr-release-specs #162
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: release | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- v* | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- 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 "version=${VERSION}" >>$GITHUB_OUTPUT | |
echo "tags=${TAGS}" >>$GITHUB_OUTPUT | |
echo "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >>$GITHUB_OUTPUT | |
- name: Docker Login | |
uses: docker/login-action@v3 | |
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@v6 | |
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 }} |