Publishing to GitHub Package Registry
and Docker Hub
#71
Workflow file for this run
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: Build | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 0 1 */1 *' | |
pull_request: | |
push: | |
branches: | |
- main | |
paths: | |
- 'Dockerfile' | |
- '.github/workflows/build*.yaml' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.head.ref || github.ref }} | |
cancel-in-progress: ${{ github.event_name == 'pull_request' }} | |
jobs: | |
koltin-versions: | |
name: Get latest Kotlin versions | |
runs-on: ubuntu-latest | |
outputs: | |
versions: ${{ steps.fetch.outputs.versions }} | |
latest: ${{ steps.fetch.outputs.latest }} | |
steps: | |
- name: Fetch Kotlin versions | |
id: fetch | |
env: | |
GH_TOKEN: ${{ github.token }} | |
# Gets the latest 3 major versions, latest patch of them | |
run: | | |
VERSIONS=$(gh release list \ | |
--repo JetBrains/kotlin \ | |
--exclude-drafts \ | |
--exclude-pre-releases \ | |
--json tagName \ | |
--jq '[map(.tagName | sub("^v"; "")) | group_by(. | sub("(?<major>\\d+).*"; .major))[] | sort_by(. | split(".") | map(tonumber))[-1]] | sort_by(. | split(".") | map(-tonumber))[0:3]' | |
) | |
LATEST=$(jq -r '.[0]' <<< "$VERSIONS") | |
echo "::notice::versions=$VERSIONS, latest=$LATEST" | |
echo "versions=$VERSIONS" >> "$GITHUB_OUTPUT" | |
echo "latest=$LATEST" >> "$GITHUB_OUTPUT" | |
build: | |
name: Build ${{ matrix.kotlin-version }}-${{ format(matrix.base-image, matrix.java-version) }} | |
needs: koltin-versions | |
uses: ./.github/workflows/build-flavor.yaml | |
secrets: inherit | |
strategy: | |
fail-fast: ${{ github.event_name == 'pull_request' }} | |
matrix: | |
kotlin-version: ${{ fromJSON(needs.koltin-versions.outputs.versions) }} | |
java-version: [ 11, 17, 21 ] | |
base-image: | |
- eclipse-temurin:{0} | |
- eclipse-temurin:{0}-alpine | |
- amazoncorretto:{0} | |
- amazoncorretto:{0}-alpine | |
- azul/zulu-openjdk:{0} | |
- azul/zulu-openjdk-alpine:{0} | |
include: | |
- kotlin-version: ${{ needs.koltin-versions.outputs.latest }} | |
java-version: 21 | |
base-image: eclipse-temurin:{0}-alpine | |
latest: true | |
exclude: | |
- java-version: 11 | |
base-image: eclipse-temurin:{0}-alpine | |
- java-version: 17 | |
base-image: eclipse-temurin:{0}-alpine | |
with: | |
kotlin-version: ${{ matrix.kotlin-version }} | |
base-image: ${{ format(matrix.base-image, matrix.java-version) }} | |
latest: ${{ matrix.latest || false }} | |
only-validate: ${{ github.event_name == 'pull_request' }} | |
build-completed: | |
name: Build completed | |
needs: build | |
runs-on: ubuntu-latest | |
if: ${{ !cancelled() }} | |
steps: | |
- name: Fail if Build has failed | |
if: ${{ contains(needs.*.result, 'failure') }} | |
run: | | |
echo "::error::Build failed" | |
exit 1 |