Skip to content

Release v0.26.0 by ggrossetie #34

Release v0.26.0 by ggrossetie

Release v0.26.0 by ggrossetie #34

Workflow file for this run

name: Release
run-name: >-
${{ github.event_name == 'workflow_dispatch'
&& format('Release v{0} by {1}',
inputs.release_version,
github.actor)
|| format('Release {0}', github.ref_name) }}
on:
push:
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v2.1.3
workflow_dispatch:
inputs:
release_version:
description: 'Release version'
required: false
type: string
create_release:
description: 'Create a GitHub release'
required: false
default: false
type: boolean
jobs:
release:
runs-on: ubuntu-22.04
if: ${{ inputs.create_release }}
steps:
- uses: actions/checkout@v4
- name: Install GraphViz
run: sudo apt-get install graphviz -y
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
- name: Build Java server
run: make buildServer
- if: github.event_name == 'push'
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- if: github.event_name == 'workflow_dispatch'
run: echo "RELEASE_VERSION=v$RELEASE_VERSION" >> $GITHUB_ENV
env:
RELEASE_VERSION=${{ inputs.release_version }}
- name: Generate checksums
run: |
cp kroki-server.jar kroki-standalone-server-${{ env.RELEASE_VERSION }}.jar
sha512sum kroki-standalone-server-${{ env.RELEASE_VERSION }}.jar > kroki-standalone-server-${{ env.RELEASE_VERSION }}.sha512sum.txt
md5sum kroki-standalone-server-${{ env.RELEASE_VERSION }}.jar > kroki-standalone-server-${{ env.RELEASE_VERSION }}.md5sum.txt
working-directory: server/target
- name: Create release
run: |
gh release create "${{ env.RELEASE_VERSION }}"
gh release upload "${{ env.RELEASE_VERSION }}" ./server/target/kroki-standalone-server-* --clobber
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish_dockerhub:
runs-on: ubuntu-22.04
steps:
- name: Free up disk space
shell: bash
# workaround: https://github.com/jlumbroso/free-disk-space/issues/9
# copied from https://github.com/hirnidrin/free-disk-space/blob/4bacba7c412c8ace26b87b5b79977da05137e69d/action.yml
run: |
# ======
# MACROS
# ======
# macro to print a line of equals
# (silly but works)
printSeparationLine() {
str=${1:=}
num=${2:-80}
counter=1
output=""
while [ $counter -le $num ]
do
output="${output}${str}"
counter=$((counter+1))
done
echo "${output}"
}
# macro to compute available space
# REF: https://unix.stackexchange.com/a/42049/60849
# REF: https://stackoverflow.com/a/450821/408734
getAvailableSpace() { echo $(df -a $1 | awk 'NR > 1 {avail+=$4} END {print avail}'); }
# macro to make Kb human readable (assume the input is Kb)
# REF: https://unix.stackexchange.com/a/44087/60849
formatByteCount() { echo $(numfmt --to=iec-i --suffix=B --padding=7 $1'000'); }
# macro to output saved space
printSavedSpace() {
saved=${1}
title=${2:-}
echo ""
printSeparationLine '*' 80
if [ ! -z "${title}" ]; then
echo "=> ${title}: Saved $(formatByteCount $saved)"
else
echo "=> Saved $(formatByteCount $saved)"
fi
printSeparationLine '*' 80
echo ""
}
# macro to print output of dh with caption
printDH() {
caption=${1:-}
printSeparationLine '=' 80
echo "${caption}"
echo ""
echo "$ dh -h /"
echo ""
df -h /
echo "$ dh -a /"
echo ""
df -a /
echo "$ dh -a"
echo ""
df -a
printSeparationLine '=' 80
}
# ======
# SCRIPT
# ======
# Display initial disk space stats
AVAILABLE_INITIAL=$(getAvailableSpace)
AVAILABLE_ROOT_INITIAL=$(getAvailableSpace '/')
printDH "BEFORE CLEAN-UP:"
echo ""
# Remove Android library
BEFORE=$(getAvailableSpace)
sudo rm -rf /usr/local/lib/android
AFTER=$(getAvailableSpace)
SAVED=$((AFTER-BEFORE))
printSavedSpace $SAVED "Android library"
BEFORE=$(getAvailableSpace)
# https://github.community/t/bigger-github-hosted-runners-disk-space/17267/11
sudo rm -rf /usr/share/dotnet
AFTER=$(getAvailableSpace)
SAVED=$((AFTER-BEFORE))
printSavedSpace $SAVED ".NET runtime"
BEFORE=$(getAvailableSpace)
sudo rm -rf /opt/ghc
AFTER=$(getAvailableSpace)
SAVED=$((AFTER-BEFORE))
printSavedSpace $SAVED "Haskell runtime"
# Remove large packages
# REF: https://github.com/apache/flink/blob/master/tools/azure-pipelines/free_disk_space.sh
BEFORE=$(getAvailableSpace)
sudo apt-get remove -y '^aspnetcore-.*'
sudo apt-get remove -y '^dotnet-.*'
sudo apt-get remove -y '^llvm-.*'
sudo apt-get remove -y 'php.*'
sudo apt-get remove -y '^mongodb-.*'
sudo apt-get remove -y '^mysql-.*'
sudo apt-get remove -y azure-cli google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri
sudo apt-get autoremove -y
sudo apt-get clean
AFTER=$(getAvailableSpace)
SAVED=$((AFTER-BEFORE))
printSavedSpace $SAVED "Large misc. packages"
# Remove Docker images
BEFORE=$(getAvailableSpace)
sudo docker image prune --all --force
AFTER=$(getAvailableSpace)
SAVED=$((AFTER-BEFORE))
printSavedSpace $SAVED "Docker images"
# Remove Swap storage
BEFORE=$(getAvailableSpace)
sudo swapoff -a
sudo rm -f /mnt/swapfile
free -h
AFTER=$(getAvailableSpace)
SAVED=$((AFTER-BEFORE))
printSavedSpace $SAVED "Swap storage"
# Output saved space statistic
AVAILABLE_END=$(getAvailableSpace)
AVAILABLE_ROOT_END=$(getAvailableSpace '/')
echo ""
printDH "AFTER CLEAN-UP:"
echo ""
echo ""
echo "/dev/root:"
printSavedSpace $((AVAILABLE_ROOT_END - AVAILABLE_ROOT_INITIAL))
echo "overall:"
printSavedSpace $((AVAILABLE_END - AVAILABLE_INITIAL))
- uses: actions/checkout@v4
- name: Install GraphViz
run: sudo apt-get install graphviz -y
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
- name: Build Java server
run: make buildServer
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
config: .github/buildkitd.toml
- name: Login to Docker Hub
run: |
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
- if: github.event_name == 'workflow_dispatch'
name: Publish Docker images ${{ inputs.release_version }}
run: make publishDockerImages
env:
RELEASE_VERSION: ${{ inputs.release_version }}
- if: github.event_name == 'push'
run: RELEASE_VERSION=${GITHUB_REF#refs/*/v*} make publishDockerImages