BlueMap/.github/workflows/build.yml

81 lines
2.3 KiB
YAML
Raw Permalink Normal View History

name: Build
2019-12-29 16:32:35 +01:00
on:
push:
branches:
- "*"
tags:
- "*"
pull_request:
branches:
- "*"
2023-09-27 23:14:46 +02:00
workflow_dispatch:
2019-12-29 16:32:35 +01:00
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0 # needed for versioning
2023-09-27 23:09:53 +02:00
- name: Set up Java
2023-09-27 23:11:23 +02:00
uses: actions/setup-java@v3
with:
2023-09-27 23:09:53 +02:00
distribution: 'temurin'
java-version: |
16
17
cache: 'gradle'
- name: Build with Gradle
run: ./gradlew clean spotlessCheck test build
- uses: actions/upload-artifact@v2
with:
name: artifacts
path: build/release/*
docker:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
- uses: actions/download-artifact@v3
with:
name: artifacts
path: build/release
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Docker metadata
id: metadata
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository }}
2022-09-09 16:40:27 +02:00
# Always tagged as the pushed branch (ex. master)
# For releases: latest, full version and major version (ex. latest, v3.3 and v3)
tags: |
type=raw,value={{branch}}
2022-09-09 16:40:27 +02:00
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') }}
type=raw,value={{tag}},enable=${{ startsWith(github.ref, 'refs/tags/') }}
2022-09-09 16:40:27 +02:00
type=match,pattern=v\d+,group=0,enable=${{ startsWith(github.ref, 'refs/tags/') }}
flavor: |
latest=false
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64,linux/arm64
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
push: ${{ github.event_name != 'pull_request' }}
cache-from: type=gha
cache-to: type=gha,mode=max