mirror of
https://github.com/imgfloat/server.git
synced 2026-02-05 03:39:26 +00:00
112 lines
3.1 KiB
YAML
112 lines
3.1 KiB
YAML
name: CI
|
|
|
|
on:
|
|
pull_request:
|
|
paths-ignore:
|
|
- '**/*.md'
|
|
- 'README*'
|
|
- 'LICENSE*'
|
|
- 'shell.nix*'
|
|
push:
|
|
branches:
|
|
- master
|
|
paths-ignore:
|
|
- '**/*.md'
|
|
- 'README*'
|
|
- 'LICENSE*'
|
|
- 'shell.nix*'
|
|
|
|
jobs:
|
|
build:
|
|
timeout-minutes: 10
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
lfs: false
|
|
|
|
- name: Set up JDK
|
|
uses: actions/setup-java@v4
|
|
with:
|
|
distribution: temurin
|
|
java-version: '17'
|
|
cache: maven
|
|
|
|
- name: Build and test
|
|
run: mvn -B verify
|
|
|
|
docker:
|
|
timeout-minutes: 10
|
|
runs-on: ubuntu-latest
|
|
needs: build
|
|
outputs:
|
|
pom_version: ${{ steps.read_version.outputs.pom_version }}
|
|
version_changed: ${{ steps.version_check.outputs.version_changed }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
lfs: true
|
|
|
|
- name: Check for pom.xml changes
|
|
id: version_check
|
|
run: |
|
|
if [ "${{ github.event_name }}" != "push" ]; then
|
|
echo "version_changed=false" >> "$GITHUB_OUTPUT"
|
|
exit 0
|
|
fi
|
|
|
|
if git diff --name-only "${{ github.event.before }}" "${{ github.sha }}" -- pom.xml | grep -q '^pom.xml$'; then
|
|
echo "version_changed=true" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "version_changed=false" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
- name: Read pom.xml version
|
|
id: read_version
|
|
run: |
|
|
VERSION=$(mvn -q -DforceStdout help:evaluate -Dexpression=project.version)
|
|
echo "pom_version=$VERSION" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Set Docker tags
|
|
id: docker_tags
|
|
run: |
|
|
TAGS="kruhlmann/imgfloat-j:latest,kruhlmann/imgfloat-j:${{ github.sha }}"
|
|
if [ "${{ steps.version_check.outputs.version_changed }}" = "true" ]; then
|
|
TAGS="$TAGS,kruhlmann/imgfloat-j:${{ steps.read_version.outputs.pom_version }}"
|
|
fi
|
|
echo "tags=$TAGS" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Log in to Docker Hub
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: kruhlmann
|
|
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
|
|
|
|
- name: Build and push Docker image
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
push: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
|
|
tags: ${{ steps.docker_tags.outputs.tags }}
|
|
|
|
release:
|
|
timeout-minutes: 10
|
|
runs-on: ubuntu-latest
|
|
needs: docker
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/master' && needs.docker.outputs.version_changed == 'true'
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
lfs: false
|
|
|
|
- name: Create GitHub Release
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
tag_name: v${{ needs.docker.outputs.pom_version }}
|
|
name: v${{ needs.docker.outputs.pom_version }}
|
|
generate_release_notes: true
|