Skip to content

Release

Release #46

Workflow file for this run

---
name: Release
on:
workflow_dispatch:
inputs:
title:
description: "Release title"
required: false
bump:
description: "Bump type (major/minor/patch) defaults to auto"
default: "auto"
required: true
jobs:
release:
runs-on: ubuntu-latest
environment: deployment
name: Build, publish, release, and announce
steps:
- name: Checkout sources
uses: actions/checkout@v3
with:
fetch-depth: 0
ssh-key: ${{ secrets.DEPLOY_KEY }}
- name: Configure git
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
- name: Setup Python 3.10
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Cache pip repository
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt', 'requirements_docs.txt') }}
- name: Prepare python environment
run: |
pip install --upgrade pip
pip install -r requirements.txt -r requirements_docs.txt
- name: Build documentation site
run: mkdocs build
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ hashFiles('**/Dockerfile') }}
- name: Set up QEMU
uses: docker/[email protected]
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Login to DockerHub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Determine next SemVer
id: bumper
uses: tomerfi/[email protected]
with:
bump: '${{ github.event.inputs.bump }}'
- name: Set new project version
# yamllint disable rule:line-length
# editorconfig-checker-disable
run: |
echo "${{ steps.bumper.outputs.new_version }}" > VERSION
sed -i 's/ version: .*/ version: "${{ steps.bumper.outputs.new_version }}"/g' mkdocs.yml
# yamllint enable rule:line-length
# editorconfig-checker-enable
- name: Commit, tag, and push
run: |
git add VERSION
git add mkdocs.yml
git commit -m "build: bump version to ${{ steps.bumper.outputs.new_version }}"
git push
- name: Get current date
id: current_date
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- name: Build images and push to DockerHub
uses: docker/[email protected]
with:
context: .
push: true
platforms: linux/amd64,linux/arm/v7,linux/arm64/v8
tags: |
tomerfi/switcher_webapi:latest
tomerfi/switcher_webapi:${{ steps.bumper.outputs.new_version }}
build-args: |
VCS_REF=${{ github.sha }}
BUILD_DATE=${{ steps.current_date.outputs.date }}
VERSION=${{ steps.bumper.outputs.new_version }}
cache-from: |
type=local,src=/tmp/.buildx-cache
ghcr.io/tomerfi/switcher_webapi:early-access
cache-to: type=local,dest=/tmp/.buildx-cache
- name: Create a release name
id: release_name
uses: actions/github-script@v6
with:
script: |
var retval = '${{ steps.bumper.outputs.new_version }}'
if ('${{ github.event.inputs.title }}') {
retval = retval.concat(' - ${{ github.event.inputs.title }}')
}
core.setOutput('value', retval)
- name: Create a release
id: gh_release
uses: actions/github-script@v6
with:
github-token: ${{ secrets.RELEASE_PAT }}
script: |
const repo_name = context.payload.repository.full_name
const response = await github.request('POST /repos/' + repo_name + '/releases', {
tag_name: '${{ steps.bumper.outputs.new_version }}',
name: '${{ steps.release_name.outputs.value }}',
generate_release_notes: true
})
core.setOutput('html_url', response.data.html_url)
- name: Set development project version
run: echo "${{ steps.bumper.outputs.next_dev_iteration }}" > VERSION
- name: Commit and push
# yamllint disable rule:line-length
# editorconfig-checker-disable
run: |
git add VERSION
git commit -m "build: bump version to ${{ steps.bumper.outputs.next_dev_iteration }} [skip ci]"
git push
# yamllint enable rule:line-length
# editorconfig-checker-enable