Skip to content

Release

Release #28

Workflow file for this run

name: Release
on:
push:
tags:
- 'v*.*.*'
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
docker:
runs-on: ubicloud
permissions:
contents: read
packages: write
id-token: write
timeout-minutes: 45
steps:
- name: Check out
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build image
run: |
CARGO_VERSION=$(grep -Po '(?<=version = ")\d+\.\d+\.\d+' Cargo.toml)
TAG_VERSION=${GITHUB_REF#refs/tags/v}
if [ "$CARGO_VERSION" != "$TAG_VERSION" ]; then
echo "Version mismatch: Cargo.toml version ($CARGO_VERSION) doesn't match tag version ($TAG_VERSION)"
exit 1
fi
echo "Version $CARGO_VERSION matches tag"
docker build -f Dockerfile .\
-t "${REGISTRY}/${IMAGE_NAME}:${GITHUB_SHA::6}"\
-t "${REGISTRY}/${IMAGE_NAME}:${TAG_VERSION}"\
-t "${REGISTRY}/${IMAGE_NAME}:latest"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish image
run: |
docker login ${REGISTRY} -u ${DOCKER_USERNAME} -p ${DOCKER_PASSWORD}
docker image push --all-tags "${REGISTRY}/${IMAGE_NAME}"
env:
DOCKER_USERNAME: ${{ github.actor }}
DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }}