chore: release 5.0.0 (#78) #8
Workflow file for this run
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: Docker Image CI | |
on: | |
workflow_dispatch: | |
inputs: | |
ref: | |
description: 'GitHub ref to checkout' | |
required: true | |
default: main | |
tag: | |
description: 'Docker tag to push (do NOT use "latest" or version numbers)' | |
required: true | |
default: 'HEAD' | |
push: | |
tags: | |
- v* | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
build: | |
name: Build and push image to registry | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
ref: ${{ github.event.inputs.ref }} | |
- name: Build image | |
run: docker build . --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}" | |
- name: Log in to registry | |
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login $REGISTRY -u ${{ github.actor }} --password-stdin | |
- name: Push image (manual) | |
if: github.event_name == 'workflow_dispatch' | |
run: | | |
IMAGE_ID="${REGISTRY}/${IMAGE_NAME}" | |
# Change all uppercase to lowercase | |
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') | |
TAG=${{ github.event.inputs.tag }} | |
echo IMAGE_ID=$IMAGE_ID | |
echo TAG=$TAG | |
docker tag $IMAGE_NAME $IMAGE_ID:$TAG | |
docker push $IMAGE_ID:$TAG | |
- name: Push image (release) | |
if: github.event_name != 'workflow_dispatch' | |
run: | | |
IMAGE_ID="${REGISTRY}/${IMAGE_NAME}" | |
# Change all uppercase to lowercase | |
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') | |
# Strip git ref prefix from version | |
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') | |
# Strip "v" prefix from tag name | |
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') | |
VERSION_START=${VERSION%%.*} | |
echo IMAGE_ID=$IMAGE_ID | |
echo VERSION=$VERSION | |
# Push latest | |
docker tag $IMAGE_NAME $IMAGE_ID:latest | |
docker push $IMAGE_ID:latest | |
# Push full version | |
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION | |
docker push $IMAGE_ID:$VERSION | |
# Push short version | |
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION_START | |
docker push $IMAGE_ID:$VERSION_START |