Skip to content

Release

Release #19

Workflow file for this run

name: Release
on:
workflow_dispatch:
inputs:
releaseType:
type: choice
options:
- minor
- patch
default: minor
required: true
description: 'minor: v0.X.0, patch: v0.0.X'
debug:
type: boolean
default: true
description: 'executes the workflow in debug mode (skip the publishing tag, docker image and release steps)'
jobs:
check-permission:
name: Check permission
if: contains(github.ref, 'refs/heads/master')
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Check user permission
uses: actions-cool/check-user-permission@v2.2.0
id: check
with:
require: 'write'
outputs:
hasWritePermission: ${{ steps.check.outputs.require-result }}
publish-tag:
name: Publish tag
needs: check-permission
if: contains(needs.check-permission.outputs.hasWritePermission, 'true')
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout prebid cache
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Create & publish tag
id: release
run: |
currentTag=$(git describe --abbrev=0 --tags)
echo "Current release tag ${currentTag}"
echo ${currentTag} | grep -q "^v\?[0-9]\+\.[0-9]\+\.[0-9]\+$"
if [ $? -ne 0 ]; then
echo "Current tag format won't let us compute the new tag name. Required format v[0-9]\+\.[0-9]\+\.[0-9]\+"
exit 1
fi
if [[ "${currentTag:0:1}" != "v" ]]; then
currentTag="v${currentTag}"
fi
nextTag=''
releaseType=${{ inputs.releaseType }}
if [ $releaseType == "minor" ]; then
# increment minor version and reset patch version
nextTag=$(echo "${currentTag}" | awk -F. '{OFS="."; $2+=1; $3=0; print $0}')
else
# increment patch version
nextTag=$(echo "${currentTag}" | awk -F. '{OFS="."; $3+=1; print $0}')
fi
if [ ${{ inputs.debug }} == 'true' ]; then
echo "running workflow in debug mode, next ${releaseType} tag: ${nextTag}"
else
git tag $nextTag
git push origin $nextTag
echo "tag=${nextTag}" >> $GITHUB_OUTPUT
fi
outputs:
releaseTag: ${{ steps.release.outputs.tag }}
publish-docker-image:
name: Publish docker image
needs: publish-tag
if: contains(inputs.debug, 'false')
runs-on: ubuntu-latest
steps:
- name: Checkout prebid cache
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Build image
run: |
docker build --build-arg DEPLOY_VERSION=${{ needs.publish-tag.outputs.releaseTag }} -t docker.io/prebid/prebid-cache:${{ needs.publish-tag.outputs.releaseTag }} .
- name: Login to docker Hub
if: contains(inputs.debug, 'false')
uses: docker/login-action@v2.1.0
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Publish to docker Hub
run: |
docker push docker.io/prebid/prebid-cache:${{ needs.publish-tag.outputs.releaseTag }}
publish-release:
name: Publish release
needs: [publish-tag, publish-docker-image]
if: contains(inputs.debug, 'false')
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout prebid cache
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Create & publish release
uses: release-drafter/release-drafter@v5.22.0
with:
name: ${{ needs.publish-tag.outputs.releaseTag }}
tag: ${{ needs.publish-tag.outputs.releaseTag }}
version: ${{ needs.publish-tag.outputs.releaseTag }}
publish: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}