Skip to content

Build

Build #22

Workflow file for this run

name: Build
on:
release:
types: [created]
jobs:
build:
runs-on: ubuntu-latest
env:
REGISTRY_HOST: ghcr.io
steps:
- uses: actions/checkout@v2
- shell: bash
run: |
echo "##[set-output name=name;]$(echo ${GITHUB_REPOSITORY#*/})"
echo "##[set-output name=ver;]$(echo ${GITHUB_REF#refs/*/})"
echo "##[set-output name=minor_ver;]$(TMP_VAR=${GITHUB_REF#refs/*/}; echo ${TMP_VAR%.*})"
echo "##[set-output name=major_ver;]$(TMP_VAR=${GITHUB_REF#refs/*/}; echo ${TMP_VAR%.*.*})"
echo "##[set-output name=sha;]$(git rev-parse --short "$GITHUB_SHA")"
id: extract_name_and_version
- uses: docker/setup-qemu-action@v1
- uses: docker/setup-buildx-action@v1
- uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_PASS }}
- uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY_HOST }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- run: sed -i 's/0.1.0/'"${{ steps.extract_name_and_version.outputs.ver }}"'/' pyproject.toml
- run: sed -i 's/0.1.0/'"${{ steps.extract_name_and_version.outputs.ver }}"'/' makeqr/version.py
- uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
push: true
tags: |
"${{ env.REGISTRY_HOST }}/${{ github.repository }}:latest"
"${{ env.REGISTRY_HOST }}/${{ github.repository }}:${{ steps.extract_name_and_version.outputs.sha }}"
"${{ env.REGISTRY_HOST }}/${{ github.repository }}:${{ steps.extract_name_and_version.outputs.major_ver }}"
"${{ env.REGISTRY_HOST }}/${{ github.repository }}:${{ steps.extract_name_and_version.outputs.minor_ver }}"
"${{ env.REGISTRY_HOST }}/${{ github.repository }}:${{ steps.extract_name_and_version.outputs.ver }}"
"${{ github.repository }}:latest"
"${{ github.repository }}:${{ steps.extract_name_and_version.outputs.sha }}"
"${{ github.repository }}:${{ steps.extract_name_and_version.outputs.major_ver }}"
"${{ github.repository }}:${{ steps.extract_name_and_version.outputs.minor_ver }}"
"${{ github.repository }}:${{ steps.extract_name_and_version.outputs.ver }}"
labels:
"org.opencontainers.image.source=https://github.com/${{ github.repository }}"
build-args: |
SHORTENER_VERSION=${{ steps.extract_name_and_version.outputs.ver }}
cache-from: type=registry,ref=${{ env.REGISTRY_HOST }}/${{ github.repository }}:${{ steps.extract_name_and_version.outputs.minor_ver }}
cache-to: type=inline