Skip to content

Commit

Permalink
ADD: release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
wiemanboy committed Oct 7, 2024
1 parent 1427962 commit c49d2f2
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 1 deletion.
65 changes: 65 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Create Docker image and release

on:
push:
branches:
- master
- release/*
workflow_dispatch:
inputs:
version:
description: 'Version of the application'
required: false

jobs:
build:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.set-version.outputs.version }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set version
id: set-version
run: echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV

- name: Install xmllint
run: |
sudo apt-get update
sudo apt-get install -y libxml2-utils
- name: Extract version from pom.xml
if: github.event.inputs.version == ''
id: extract-version
run: |
VERSION=$(xmllint --xpath 'string(/*[local-name()="project"]/*[local-name()="version"])' pom.xml)
echo "VERSION=${VERSION}" >> $GITHUB_ENV
- name: Authorize in Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
push: true
tags: |
${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_IMAGE_NAME }}:${{ env.VERSION }}
${{ github.ref == 'refs/heads/master' && format('{0}/{1}:latest', secrets.DOCKER_HUB_USERNAME, vars.DOCKER_IMAGE_NAME) || '' }}
- name: Create release
uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: "${{ secrets.TOKEN }}"
automatic_release_tag: ${{ env.VERSION }}
prerelease: ${{ github.ref != 'refs/heads/master' }}
title: "${{ github.event.repository.name }} v${{ env.VERSION }}"
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>
<groupId>com.wiemanboy</groupId>
<artifactId>WiemanApi</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>0.0.1</version>
<name>WiemanApi</name>
<description>WiemanApi</description>
<url/>
Expand Down

0 comments on commit c49d2f2

Please sign in to comment.