Skip to content

Updated GitHub Actions #6

Updated GitHub Actions

Updated GitHub Actions #6

name: Release Artifacts
on:
push:
tags:
- '**'
permissions:
contents: read
id-token: write
packages: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-and-publish-jar:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
repository-projects: write
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file
- name: Set env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Build with Maven
run: mvn -B -Drevision=${{ env.RELEASE_VERSION }} clean package --file pom.xml -Pproduction
- name: Release Assets
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: startsWith(github.ref, 'refs/tags/')
with:
files: target/*.jar
build-and-push-docker-image:
runs-on: ubuntu-latest
needs:
- build-and-publish-jar
permissions:
contents: write
pull-requests: write
repository-projects: write
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file
- name: Set env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Build with Maven
run: mvn -B -Drevision=${{ env.RELEASE_VERSION }} clean package --file pom.xml -Pproduction
- name: Log in to Docker Hub
run: docker login -u amithkoujalgi -p ${{ secrets.DOCKERHUB_ACCESS_TOKEN }}
- name: Build and push Docker image - as tag='latest'
uses: docker/build-push-action@v5
if: startsWith(github.ref, 'refs/tags/')
with:
context: .
file: Dockerfile
push: true
tags: amithkoujalgi/ollama4j-web-ui:latest
- name: Build and push Docker image - as tag with release version number
uses: docker/build-push-action@v5
if: startsWith(github.ref, 'refs/tags/')
with:
context: .
file: Dockerfile
push: true
tags: amithkoujalgi/ollama4j-web-ui:${{ env.RELEASE_VERSION }}