Build #2268
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: | |
push: | |
branches: | |
- main | |
tags: | |
- '*' | |
# - 'v*.*.*' | |
paths-ignore: | |
- LICENSE | |
- '*.md' | |
- 'docs/**' | |
- '.github/config/labels.yml' | |
pull_request: | |
branches: | |
- main | |
schedule: | |
- cron: "0 0 * * *" | |
workflow_dispatch: | |
defaults: | |
run: | |
shell: bash | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
GITHUB_PUBLISH: 'false' | |
SEGMENT_DOWNLOAD_TIMEOUT_MINS: '15' | |
releaseBuild: ${{ github.event_name == 'push' && contains(github.ref, 'refs/tags/') }} | |
jobs: | |
# Gradle Build Action | |
build: | |
name: 🏗️ Gradle Build | |
# if: github.event_name == 'pull_request' | |
permissions: | |
contents: write | |
packages: write | |
discussions: write | |
strategy: | |
fail-fast: true | |
max-parallel: 3 | |
matrix: | |
os: [ ubuntu-latest, macos-latest, windows-latest ] | |
jdk: [ ea ] | |
include: | |
- os: ubuntu-latest | |
cmd: ./gradlew | |
- os: macos-latest | |
cmd: ./gradlew | |
- os: windows-latest | |
cmd: ./gradlew.bat | |
runs-on: ${{ matrix.os }} | |
timeout-minutes: 20 | |
continue-on-error: false | |
outputs: | |
version: ${{ steps.gradle-build.outputs.version }} | |
artifact_name: ${{ steps.gradle-build.outputs.uberjar_name }} | |
artifact_path: ${{ steps.gradle-build.outputs.uberjar_path }} | |
# Output JSON 'matrix' | |
# matrix: ${{ steps.gradle-build.outputs.matrix }} | |
# services: | |
# postgres: | |
# image: postgres | |
# env: | |
# POSTGRES_PASSWORD: postgres | |
# options: >- | |
# --health-cmd pg_isready | |
# --health-interval 10s | |
# --health-timeout 5s | |
# --health-retries 5 | |
# ports: | |
# - 5432:5432 | |
steps: | |
# - name: ⏹️ Cancel Previous Runs | |
# uses: styfle/[email protected] | |
# with: | |
# access_token: ${{ github.token }} | |
- name: 🛎️ Check out the source code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
# repository: sureshg/openjdk-playground | |
# path: main | |
# ref: ${{ github.event.pull_request.head.sha }} | |
# submodules: recursive | |
- name: ⬇️ Download OpenJDK ${{ matrix.jdk }} build from ☁️jdk.java.net | |
id: download-jdk | |
uses: oracle-actions/setup-java@main | |
with: | |
website: jdk.java.net | |
release: ${{ matrix.jdk }} | |
version: latest | |
install: false | |
- name: ☕ Set up OpenJDK ${{ matrix.jdk }} | |
id: setup-java | |
uses: actions/setup-java@v4 | |
if: always() && steps.download-jdk.outcome == 'success' | |
with: | |
distribution: jdkfile | |
java-version: ${{ steps.download-jdk.outputs.version }} | |
jdkFile: ${{ steps.download-jdk.outputs.archive }} | |
# cache: 'gradle' | |
# settings-path: ${{ github.workspace }} # OR $GITHUB_WORKSPACE | |
- name: 🚄 Cache Gradle | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: ⛵️Install jextract tool | |
if: ${{ false }} | |
run: | | |
./scripts/jextract.sh /tmp | |
echo "/tmp/jextract/bin" >> $GITHUB_PATH | |
- name: 🧰 Export Gradle Properties | |
if: ${{ false }} | |
id: gradle-properties | |
run: | | |
PROPERTIES="$(./gradlew properties --console=plain -q)" | |
VERSION="$(echo "$PROPERTIES" | grep "^version:" | cut -f2- -d ' ')" | |
NAME="$(echo "$PROPERTIES" | grep "^name:" | cut -f2- -d ' ')" | |
ARTIFACT="${NAME}-${VERSION}.jar" | |
echo "version=$VERSION" >> $GITHUB_OUTPUT | |
echo "name=$NAME" >> $GITHUB_OUTPUT | |
echo "artifact=$ARTIFACT" >> $GITHUB_OUTPUT | |
echo "Runner Tool Cache: ${RUNNER_TOOL_CACHE}" | |
- name: 📦 Publish to GitHub Packages (Linux) | |
id: gradle-publish | |
if: env.GITHUB_PUBLISH == 'true' && runner.os == 'Linux' | |
run: | | |
./gradlew publish | |
env: | |
GITHUB_USER: ${{ github.repository_owner }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
- name: 🏗️ Gradle Build & Run | |
id: gradle-build | |
run: | | |
MKTEMP_PATH="$(dirname "$(mktemp -u)")/" | |
echo "MKTEMP_PATH=$MKTEMP_PATH" >> $GITHUB_ENV | |
./gradlew ciBuild --no-daemon | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
- name: 📤 Uploading ${{ matrix.os }} executable jar | |
if: steps.gradle-build.outcome == 'success' && runner.os == 'Linux' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ steps.gradle-build.outputs.execjar_name }} | |
path: | | |
${{ steps.gradle-build.outputs.execjar_path }} | |
if-no-files-found: error | |
- name: 🚀 Deploy html docs to 🕸️website | |
if: startsWith(github.ref, 'refs/tags/') && runner.os == 'Linux' | |
uses: JamesIves/[email protected] | |
with: | |
branch: main | |
folder: build/dokka | |
target-folder: docs/apidoc/ | |
clean: true | |
commit-message: 'doc: Deployed dokka website' | |
- name: 🏖️ Deploy coverage report to website | |
if: startsWith(github.ref, 'refs/tags/') && runner.os == 'Linux' | |
uses: JamesIves/[email protected] | |
with: | |
branch: main | |
folder: build/reports | |
target-folder: docs/reports/ | |
clean: true | |
commit-message: 'doc: Deployed coverage report' | |
- name: 📌 Push the changes to Github | |
if: ${{ false }} | |
id: push-to-github | |
run: | | |
# date > generated.txt | |
git diff | |
git config user.name github-actions | |
git config user.email [email protected] | |
git add . | |
# git commit -m "doc: Update generated.txt" || exit 0 | |
if [ -z "$(git status --porcelain)" ]; then | |
echo 'No changes detected.' | |
exit 0 | |
else | |
git commit --message "doc: Update generated.txt" | |
git push | |
# git push origin HEAD:${{ github.event.repository.default_branch }} | |
fi | |
- name: 💥 Uploading JVM error logs | |
if: steps.gradle-build.outcome == 'failure' && always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.os }}-jvm-error-logs | |
path: | | |
hs_err* | |
${{ github.workspace }}/hs_err* | |
${{ env.MKTEMP_PATH }}/*hs-err* | |
if-no-files-found: warn | |
retention-days: 30 | |
# GitHub Release Action on tag push | |
release: | |
name: 🚰 Release new version. | |
needs: [ build ] | |
if: startsWith(github.ref, 'refs/tags/') && needs.build.result == 'success' | |
runs-on: ubuntu-latest | |
# strategy: | |
# matrix: ${{ fromJson(needs.build.outputs.matrix) }} | |
steps: | |
- name: 🛎️Check out the source code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
submodules: recursive | |
- name: ⚙️Build Changelog | |
id: github_release | |
uses: mikepenz/release-changelog-builder-action@v5 | |
with: | |
configuration: ".github/config/configuration.json" | |
commitMode: true | |
ignorePreReleases: ${{ !contains(github.ref, '-') }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: ⏬Download all the build artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: release-artifacts | |
- name: ✨Github Release (version = ${{ needs.build.outputs.version }}) | |
uses: softprops/action-gh-release@v2 | |
with: | |
# body_path: ${{ github.workspace }}-CHANGELOG.txt | |
body: ${{ steps.github_release.outputs.changelog }} | |
files: | | |
${{ github.workspace }}/release-artifacts/** | |
generate_release_notes: true | |
fail_on_unmatched_files: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# Run Java Application on OpenJDK docker images | |
container-build: | |
name: 🚢 Java on Container | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: true | |
matrix: | |
jdk: [ "openjdk:24-slim" ] | |
defaults: | |
run: | |
shell: sh | |
container: | |
image: ${{ matrix.jdk }} | |
steps: | |
- name: 🛎️Check out the source code | |
uses: actions/checkout@v4 | |
- name: ☕ Run Java App on OpenJDK ${{ matrix.jdk }} container image | |
if: always() | |
run: | | |
java --enable-preview --show-version src/main/java/JavaApp.java | |
env: | |
RUNNER_CONTEXT: ${{ toJson(runner) }} | |
- name: ⏳Github Action Contexts | |
run: | | |
echo "$JOB_CONTEXT" | |
echo "$STEPS_CONTEXT" | |
echo "$RUNNER_CONTEXT" | |
env: | |
JOB_CONTEXT: ${{ toJson(job) }} | |
STEPS_CONTEXT: ${{ toJson(steps) }} | |
RUNNER_CONTEXT: ${{ toJson(runner) }} |