Add a release actions

Github workflows to create a nightly release automatically and a
stable release semi-automatic (a 2-step process).
This commit is contained in:
eikek 2021-05-31 00:08:30 +02:00
parent d7363b9c8e
commit 71b913b19f
5 changed files with 198 additions and 18 deletions

22
.github/workflows/docker-image.yml vendored Normal file
View File

@ -0,0 +1,22 @@
name: Publish Docker Images
on:
release:
types: [ published ]
jobs:
docker-images:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2.3.4
with:
fetch-depth: 0
- name: Set current version
run: echo "DOCSPELL_VERSION=$(cat version.sbt | grep version | cut -d= -f2 | xargs)" >> $GITHUB_ENV
- name: Build Docker Images (${{ env.DOCSPELL_VERSION }})
run: ./docker/dockerfiles/build.sh ${{ env.DOCSPELL_VERSION }}
- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Publish Images (${{ env.DOCSPELL_VERSION }})
run: ./docker/dockerfiles/push.sh ${{ env.DOCSPELL_VERSION }}

52
.github/workflows/release-nightly.yml vendored Normal file
View File

@ -0,0 +1,52 @@
name: Release Nightly
on:
push:
branches:
- "master"
jobs:
release-nightly:
runs-on: ubuntu-20.04
strategy:
fail-fast: true
matrix:
java: [ 'openjdk@1.11' ]
steps:
- uses: actions/checkout@v2.3.4
with:
fetch-depth: 0
- uses: olafurpg/setup-scala@v10
with:
java-version: ${{ matrix.java }}
- uses: jorelali/setup-elm@v3
with:
elm-version: 0.19.1
- uses: bahmutov/npm-install@v1
- name: Coursier cache
uses: coursier/cache-action@v6
- name: Set current version
run: echo "DOCSPELL_VERSION=$(cat version.sbt | grep version | cut -d= -f2 | xargs)" >> $GITHUB_ENV
- name: sbt ci ${{ github.ref }}
run: sbt ci
- name: sbt make-pkg (${{ env.DOCSPELL_VERSION }})
run: sbt make-pkg
- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "nightly"
prerelease: true
title: "Docspell Nightly"
files: |
modules/restserver/target/docspell-restserver_${{ env.DOCSPELL_VERSION }}_all.deb
modules/restserver/target/universal/docspell-restserver-${{ env.DOCSPELL_VERSION }}.zip
modules/joex/target/docspell-joex_${{ env.DOCSPELL_VERSION }}_all.deb
modules/joex/target/universal/docspell-joex-${{ env.DOCSPELL_VERSION }}.zip
tools/target/docspell-tools-${{ env.DOCSPELL_VERSION }}.zip
- name: Build Docker Images (${{ env.DOCSPELL_VERSION }})
run: ./docker/dockerfiles/build.sh ${{ env.DOCSPELL_VERSION }}
- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Publish Images (${{ env.DOCSPELL_VERSION }})
run: ./docker/dockerfiles/push.sh ${{ env.DOCSPELL_VERSION }}

43
.github/workflows/release.yml vendored Normal file
View File

@ -0,0 +1,43 @@
name: Release
on:
push:
tags:
- 'v*'
jobs:
release:
runs-on: ubuntu-20.04
strategy:
fail-fast: true
matrix:
java: [ 'openjdk@1.11' ]
steps:
- uses: actions/checkout@v2.3.4
with:
fetch-depth: 0
- uses: olafurpg/setup-scala@v10
with:
java-version: ${{ matrix.java }}
- uses: jorelali/setup-elm@v3
with:
elm-version: 0.19.1
- uses: bahmutov/npm-install@v1
- name: Coursier cache
uses: coursier/cache-action@v6
- name: Set current version
run: echo "DOCSPELL_VERSION=$(cat version.sbt | grep version | cut -d= -f2 | xargs)" >> $GITHUB_ENV
- name: sbt make-pkg (${{ env.DOCSPELL_VERSION }})
run: sbt make-pkg
- uses: meeDamian/github-release@2.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: Docspell ${{ env.DOCSPELL_VERSION }}
gzip: false
draft: true
prerelease: false
allow_override: false
files: >
modules/restserver/target/docspell-restserver_${{ env.DOCSPELL_VERSION }}_all.deb
modules/restserver/target/universal/docspell-restserver-${{ env.DOCSPELL_VERSION }}.zip
modules/joex/target/docspell-joex_${{ env.DOCSPELL_VERSION }}_all.deb
modules/joex/target/universal/docspell-joex-${{ env.DOCSPELL_VERSION }}.zip
tools/target/docspell-tools-${{ env.DOCSPELL_VERSION }}.zip

View File

@ -10,25 +10,50 @@ if [[ $version == v* ]]; then
version="${version:1}"
fi
set -e
cd "$(dirname "$0")"
echo "============ Building Tools ============"
docker build \
--build-arg version=$version \
--tag docspell/tools:v$version \
--tag docspell/tools:latest \
-f tools.dockerfile .
if [[ $version == *SNAPSHOT* ]]; then
echo ">>>> Building nightly images for $version <<<<<"
url_base="https://github.com/eikek/docspell/releases/download/nightly"
echo "============ Building Restserver ============"
docker build \
--build-arg version=$version \
--tag docspell/restserver:v$version \
--tag docspell/restserver:latest \
-f restserver.dockerfile .
echo "============ Building Tools ============"
docker build \
--build-arg tools_url="$url_base/docspell-tools-$version.zip" \
--tag docspell/tools:nightly \
-f tools.dockerfile .
echo "============ Building Joex ============"
docker build \
--build-arg version=$version \
--tag docspell/joex:v$version \
--tag docspell/joex:latest \
-f joex.dockerfile .
echo "============ Building Restserver ============"
docker build \
--build-arg restserver_url="$url_base/docspell-restserver-$version.zip" \
--tag docspell/restserver:nightly \
-f restserver.dockerfile .
echo "============ Building Joex ============"
docker build \
--build-arg joex_url="$url_base/docspell-joex-$version.zip" \
--tag docspell/joex:nightly \
-f joex.dockerfile .
else
echo ">>>> Building release images for $version <<<<<"
echo "============ Building Tools ============"
docker build \
--build-arg version=$version \
--tag docspell/tools:v$version \
--tag docspell/tools:latest \
-f tools.dockerfile .
echo "============ Building Restserver ============"
docker build \
--build-arg version=$version \
--tag docspell/restserver:v$version \
--tag docspell/restserver:latest \
-f restserver.dockerfile .
echo "============ Building Joex ============"
docker build \
--build-arg version=$version \
--tag docspell/joex:v$version \
--tag docspell/joex:latest \
-f joex.dockerfile .
fi

38
docker/dockerfiles/push.sh Executable file
View File

@ -0,0 +1,38 @@
#!/usr/bin/env bash
if [ -z "$1" ]; then
echo "Please specify a version"
exit 1
fi
version="$1"
if [[ $version == v* ]]; then
version="${version:1}"
fi
set -e
cd "$(dirname "$0")"
if [[ $version == *SNAPSHOT* ]]; then
echo "============ Push Tools ============"
docker push docspell/tools:nightly
echo "============ Push Restserver ============"
docker push docspell/restserver:nightly
echo "============ Push Joex ============"
docker push docspell/joex:nightly
else
echo "============ Push Tools ============"
docker push docspell/tools:v$version
docker push docspell/tools:latest
echo "============ Push Restserver ============"
docker push docspell/restserver:v$version
docker push docspell/restserver:latest
echo "============ Push Joex ============"
docker push docspell/joex:v$version
docker push docspell/joex:latest
fi