Merge pull request #162 from okp4/ci/install-workflows #108
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: Publish | |
on: | |
push: | |
branches: [main] | |
tags: ["v*"] | |
concurrency: | |
group: publish-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
publish-maven: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v3 | |
- uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '11' | |
- name: Configure gradle.properties | |
run: | | |
cat <<EOF >> gradle.properties | |
maven.credentials.username=${{ secrets.MAVEN_REPOSITORY_USERNAME }} | |
maven.credentials.password=${{ secrets.MAVEN_REPOSITORY_PASSWORD }} | |
EOF | |
- name: Publish maven snapshot | |
if: "!contains(github.ref, 'refs/tags/')" | |
uses: gradle/gradle-build-action@v2 | |
with: | |
arguments: publish | |
- name: Publish maven release | |
if: contains(github.ref, 'refs/tags/') | |
uses: gradle/gradle-build-action@v2 | |
with: | |
arguments: publish -Prelease | |
publish-docker: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v3 | |
- name: Set up context | |
id: project_context | |
uses: FranzDiebold/[email protected] | |
- uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '11' | |
- name: Configure gradle.properties | |
run: | | |
cat <<EOF >> gradle.properties | |
maven.credentials.username=${{ secrets.MAVEN_REPOSITORY_USERNAME }} | |
maven.credentials.password=${{ secrets.MAVEN_REPOSITORY_PASSWORD }} | |
EOF | |
- name: Build kotlin snapshot | |
if: "!contains(github.ref, 'refs/tags/')" | |
uses: gradle/gradle-build-action@v2 | |
with: | |
arguments: build | |
- name: Build kotlin release | |
if: contains(github.ref, 'refs/tags/') | |
uses: gradle/gradle-build-action@v2 | |
with: | |
arguments: build -Prelease | |
- name: Extract metadata (tags, labels) for Docker | |
id: docker_metadata | |
uses: docker/metadata-action@v3 | |
with: | |
images: ghcr.io/${{ github.repository }} | |
tags: | | |
type=raw,enable=${{ !endsWith(github.ref, github.event.repository.default_branch) }},value=${{ env.CI_ACTION_REF_NAME_SLUG }} | |
type=raw,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }},value=nightly | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}} | |
labels: | | |
org.opencontainers.image.vendor=OKP4 | |
- name: Login to Docker registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ secrets.DOCKER_REGISTRY_ID }} | |
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} | |
- name: Build and publish docker image(s) | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
platforms: linux/amd64 | |
push: true | |
tags: ${{ steps.docker_metadata.outputs.tags }} | |
labels: ${{ steps.docker_metadata.outputs.labels }} |