Skip to content

Cut Release account-v0.0.1 #26

Cut Release account-v0.0.1

Cut Release account-v0.0.1 #26

Workflow file for this run

name: 'Release'
run-name: 'Cut Release ${{ github.event.release.tag_name || github.event.inputs.release-tag}}'
concurrency:
group: ${{github.workflow}}-${{github.ref}}
cancel-in-progress: true
on:
release:
types: [published]
workflow_dispatch:
inputs:
release-tag:
description: 'Release tag ([servicename-]v#.#.#[-rc#])'
required: true
env:
FULL_TAG: ${{ github.event.release.tag_name || github.event.inputs.release-tag}}
DOCKER_HUB_PROFILE: projectlibertylabs
ALL_SERVICES: '["account", "content-publishing", "content-watcher", "graph"]'
jobs:
set_variables:
runs-on: ubuntu-latest
outputs:
full_tag: ${{ steps.set_version_tag.outputs.TAG }}
version_tag: ${{ steps.set_version_tag.outputs.VERSION }}
service_name: ${{ steps.set_version_tag.outputs.SERVICE }}
service_matrix: ${{ steps.set_version_tag.outputs.SERVICE_MATRIX }}
valid_semver: ${{ steps.set_version_tag.outputs.valid }}
test_run: ${{ steps.set_version_tag.outputs.test_run }}
steps:
- name: Extract and Validate Version Tag
id: set_version_tag
run: |
valid=false
test_run=false
ENTIRE_TAG_RE="^(([[:alpha:]\-]+)-)?(.*)$"
VERSION_TAG_RE="^v[\.]?([[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+(-[[:alpha:][:digit:]\.]+)*)$"
TAG="${{ github.event.release.tag_name }} || ${{ github.event.inputs.release-tag }}"
echo "Running with tag: ${TAG}"
if [[ "$TAG" =~ ${ENTIRE_TAG_RE} ]] ; then
SERVICE=${BASH_REMATCH[2]}
VERSION_TAG=${BASH_REMATCH[3]}
if [[ ${VERSION_TAG} =~ ${VERSION_TAG_RE} ]] ; then
version=${BASH_REMATCH[1]}
valid=true
if [[ ${version} = "0.0.1" ]] ; then
test_run=true
fi
if [[ -z "${SERVICE}" ]] ; then
SERVICE_MATRIX="${ALL_SERVICES}"
else
SERVICE_MATRIX="[\"${SERVICE}\"]"
fi
echo "TAG=${TAG}" >> $GITHUB_OUTPUT
echo "VERSION=${VERSION_TAG}" >> $GITHUB_OUTPUT
echo "SERVICE=${SERVICE}" >> $GITHUB_OUTPUT
echo "SERVICE_MATRIX=${SERVICE_MATRIX}" >> $GITHUB_OUTPUT
echo "valid=${valid}" >> $GITHUB_OUTPUT
echo "test_run=${test_run}" >> $GITHUB_OUTPUT
fi
fi
if [[ "${valid}" = false ]]
then
echo "SERVICE_MATRIX=[]" >> $GITHUB_OUTPUT
echo "valid=${valid}" >> $GITHUB_OUTPUT
echo "Release tag '${TAG}' is not valid for deployment."
echo "ERROR: Entered tag ${TAG} is not valid."
echo "Please use [service-]v#.#.#[-rc#] format."
exit 1
fi
build-and-publish-container-image:
name: Build and publish container image
needs: set_variables
runs-on: ubuntu-latest
if: needs.set_variables.outputs.valid_semver == 'true'
strategy:
matrix:
service: ${{ fromJson(needs.set_variables.outputs.service_matrix) }}
steps:
- name: Check Out Repo
uses: actions/checkout@v4
with:
ref: ${{ needs.set_variables.outputs.full_tag }}
- name: Deploy Service
run: |
echo "Deploying service: ${{ matrix.service }}"
- name: Set up tags for cp image
id: cp-tags
uses: docker/metadata-action@v5
with:
flavor: |
latest=auto
images: |
${{env.DOCKER_HUB_PROFILE}}/${{matrix.service}}-service
tags: |
type=semver,pattern={{version}},value=${{ needs.set_variables.outputs.version_tag }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: |
linux/amd64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{secrets.DOCKERHUB_USERNAME}}
password: ${{secrets.DOCKERHUB_TOKEN}}
- name: Build and Push Docker Image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64
push: ${{ needs.set_variables.outputs.test_run != 'true'}}
file: Docker/Dockerfile.${{ matrix.service }}
tags: ${{ steps.cp-tags.outputs.tags }}
- name: Update DockerHub Description
uses: peter-evans/dockerhub-description@e98e4d1628a5f3be2be7c231e50981aee98723ae
with:
username: ${{secrets.DOCKERHUB_USERNAME}}
password: ${{secrets.DOCKERHUB_TOKEN}}
repository: ${{env.DOCKER_HUB_PROFILE}}/${{matrix.service}}-service
readme-filepath: Docker/${{matrix.service}}-service.overview.md