release #11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: release | |
# Run workflow on commits to the `main` branch | |
on: | |
workflow_dispatch: | |
inputs: | |
branch: | |
description: "Branch to release from ?" | |
required: true | |
default: "main" | |
release-version: | |
description: "Release version ?" | |
required: true | |
release-tag: | |
description: "Release tag ?" | |
required: true | |
development-version: | |
description: "Development version ?" | |
required: true | |
latest-image: | |
description: "Tag image as 'latest' (y/n) ?" | |
required: true | |
default: "y" | |
jobs: | |
prepare-release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out Git repository | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.inputs.branch }} | |
- name: Setup git user | |
uses: fregante/setup-git-user@v2 | |
- name: Install Java and Maven | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 17 | |
distribution: "temurin" | |
- name: Perform maven release | |
run: > | |
mvn -B -ntp release:prepare | |
-DreleaseVersion=${{ github.event.inputs.release-version }} | |
-DdevelopmentVersion=${{ github.event.inputs.development-version }} | |
-Dtag=${{ github.event.inputs.release-tag }} | |
-Darguments="-DskipTests" | |
publish-image: | |
needs: prepare-release | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
contents: write | |
steps: | |
- name: checkout release tag | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.inputs.release-tag }} | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: "17" | |
distribution: "temurin" | |
cache: "maven" | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ghcr.io/${{ github.repository }} | |
tags: | | |
type=raw,value=${{ github.event.inputs.release-version }} | |
${{ (github.event.inputs.latest-image == 'y' && 'type=raw,value=latest') || '' }} | |
- name: Build with Maven | |
env: | |
IMAGE_NAME: ghcr.io/${{ github.repository }} | |
IMAGE_RAW_TAGS: ${{ steps.meta.outputs.tags }} | |
REGISTRY_USER: ${{ github.repository_owner }} | |
REGISTRY_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
LATEST_TAG: ${{ (github.event.inputs.latest-image == 'y' && 'y') || 'n' }} | |
run: | | |
export IMAGE_TAGS="${IMAGE_RAW_TAGS//$'\n'/,}" | |
if [[ $LATEST_TAG == "y" ]]; then export IMAGE_TAGS=$IMAGE_TAGS,ghcr.io/it-at-m/appswitcher-server:latest; fi | |
mvn -B -ntp -DskipTests -P build-image,publish verify | |
- name: Create GitHub Release | |
id: create_release | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: | | |
target/*.jar | |
tag_name: ${{ github.event.inputs.release-tag }} | |
draft: false | |
prerelease: false | |
generate_release_notes: true |