Release #20
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 | |
on: [workflow_dispatch] | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
if: ${{ ! contains(github.event.head_commit.message, '[ci skip]') }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 2 | |
- name: Extract data from pom.xml | |
id: pom-data | |
uses: andreacomo/maven-gav-extractor@v2 | |
- name: Get Changelog Entry based on pom.xml version | |
id: changelog_for_pom_version | |
uses: mindsers/changelog-reader-action@v2 | |
with: | |
version: ${{ steps.pom-data.outputs.version }} | |
validation_level: error | |
validation_depth: 5 | |
- name: check tag on version | |
uses: mukunku/[email protected] | |
id: tag-for-pom-version | |
with: | |
tag: elBook-${{ steps.pom-data.outputs.version }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: cancel action on tag exist | |
if: steps.tag-for-pom-version.outputs.exists == 'true' | |
run: | | |
echo "::error::Tag for version ${{ steps.pom-data.outputs.version }} already exist." | |
exit 1 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: 17 | |
distribution: 'zulu' | |
- name: Build with Maven | |
id: build_maven | |
run: | | |
mvn -B package --file pom.xml | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
${{ secrets.DOCKER_HUB_USER }}/elbook | |
tags: | | |
type=raw,value=latest | |
type=match,pattern=[0-9]+.[0-9]+.[0-9]+,value=v${{ steps.pom-data.outputs.version }} | |
#type=match,pattern=[0-9]+.[0-9]+,value=v${{ steps.pom-data.outputs.version }} | |
#type=sha | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Inspect builder | |
run: | | |
echo "Name: ${{ steps.buildx.outputs.name }}" | |
echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}" | |
echo "Status: ${{ steps.buildx.outputs.status }}" | |
echo "Flags: ${{ steps.buildx.outputs.flags }}" | |
echo "Platforms: ${{ steps.buildx.outputs.platforms }}" | |
echo "Tags: ${{ steps.meta.outputs.tags }}" | |
- name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USER }} | |
password: ${{ secrets.DOCKER_HUB_TOKEN }} | |
- name: Build and push docker images | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: docker/Dockerfile | |
platforms: linux/amd64,linux/arm64 | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Publish new version | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: target/elbook-${{ steps.pom-data.outputs.version }}.jar | |
tag: elBook-${{ steps.pom-data.outputs.version }} | |
overwrite: false | |
body: ${{ steps.changelog_for_pom_version.outputs.changes }} |