Skip to content

Relay versioned workflow fixes #3

Relay versioned workflow fixes

Relay versioned workflow fixes #3

# This workflow is used to tag an existing container image with a semver version
# and create a GitHub Release
name: Publish a Relay Versioned Release
on:
push:
tags:
- v*
env:
project: ./app/Hutch.Relay
image-name: hutch/relay
repo-owner: ${{ github.repository_owner }}
registry: ghcr.io
jobs:
version-tag:
runs-on: ubuntu-latest
permissions:
packages: write # container images
contents: write # releases
steps:
- name: Check out the repo
uses: actions/checkout@v4
# some docker actions need all lowercase, but our org name is mixed case 😠
- name: downcase repo-owner
run: |
echo "REPO_OWNER_LOWER=${GITHUB_REPOSITORY_OWNER,,}" >>${GITHUB_ENV}
# read source version
- name: Read version
id: read_version
uses: bbonkr/get-version-action@v1
with:
project: ${{ env.project }}/Hutch.Relay.csproj
- name: Parse version from tag
id: version
uses: release-kit/semver@v2
- name: Fail on Version Mismatch
if: ${{ steps.read_version.outputs.version != steps.version.outputs.full }}
run: |
echo "::error::Tag version '${{ steps.version.outputs.full }}' doesn't match source version '${{ steps.read_version.outputs.version }}'"
exit 1
# check image exists for commit
- uses: tyriis/[email protected]
with:
registry: ${{ env.registry }}
repository: ${{ env.REPO_OWNER_LOWER }}/${{ env.image-name }}
tag: ${{ github.sha }}
# TODO: Check binaries exist for workflow run?
# standard login to the container registry
- name: Docker Login
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
registry: ${{ env.registry }}
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}
# We still use the metadata action to help build out our tags from the Workflow Run
- name: Docker Metadata action
id: meta
uses: docker/[email protected]
with:
images: ${{ env.registry }}/${{ env.repo-owner }}/${{ env.image-name }}
tags: | # new tags only
type=semver,pattern={{version}}
type=semver,pattern={{major}}
type=semver,pattern={{major}}.{{minor}}
# TODO: Download binaries from merge-to-main workflow run
# Create Github Release # TODO: with binaries
- uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref_name }}
name: ${{ github.ref_name }}
body: |
# Hutch Relay ${{ github.ref_name }}
## Assets available for download:
- [Tagged Container images](https://github.com/Health-Informatics-UoN/hutch-relay/pkgs/container/hutch%2Frelay)
# TODO: published Binaries
# - Hutch Relay for Windows (x64) native
# - Hutch Relay for Linux (x64) native
# - Hutch Relay for the .NET Runtime (cross platform)
# For Database migration guidance refer to the [documentation](https://health-informatics-uon.github.io/hutch/relay/deployment#database-migrations).
# TODO: ### Database Migrations bundles
# - Hutch Relay for Windows (x64) native
# - Hutch Relay for Linux (x64) native
generateReleaseNotes: true
prerelease: ${{ steps.version.outputs.prerelease != '' }}
makeLatest: false # TODO: can we reliably detect and automate this in future?
# apply the new tags to the existing images
- name: Push updated image tags
uses: akhilerm/[email protected]
with:
src: ${{ env.registry }}/${{ env.REPO_OWNER_LOWER }}/${{ env.image-name }}:${{ github.sha }}
dst: |
${{ steps.meta.outputs.tags }}