Skip to content

Commit

Permalink
Basic app and release jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
eirnym committed Feb 13, 2024
1 parent 5edcb4a commit 9924904
Show file tree
Hide file tree
Showing 12 changed files with 592 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"commitMessageExtra": "from {{{currentValue}}} to {{{newValue}}}{{#if isMajor}} (major v{{{newMajor}}}){{else}}{{/if}}",
"extends": [
"config:base"
],
"separateMajorMinor": true,
"separateMinorPatch": true,
"separateMultipleMajor": true
}
42 changes: 42 additions & 0 deletions .github/workflows/build-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
name: Build CI

on:
pull_request:
types: [assigned, opened, synchronize, reopened]

concurrency:
# Documentation suggests ${{ github.head_ref }}, but that's only available on pull_request/pull_request_target triggers, so using ${{ github.ref }}.
# On master, we want all builds to complete even if merging happens faster to make it easier to discover at which point something broke.
group: ${{ github.ref == 'refs/heads/main' && format('build-ci-main-{0}', github.sha) || format('build-ci-{0}', github.ref) }}
cancel-in-progress: true

env:
GRADLE_OPTS: -Dorg.gradle.internal.launcher.welcomeMessageEnabled=false

jobs:
build-and-test:
name: Build CLI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set variables
id: setvars
run: |
version=$(sed -n 's,palantir-version = "\(.*\)",\1,p' gradle/libs.dependencies.toml)
echo "palantir_version=$version" >> $GITHUB_OUTPUT
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 21
cache: gradle
- run: |
echo $PALANTIR_VERSION
./gradlew build -S --warning-mode all --no-daemon "-PprojVersion=${PALANTIR_VERSION}"
env:
PALANTIR_VERSION: ${{ steps.setvars.outputs.palantir_version }}
- run: |
java -jar "build/libs/palantir-cli-${PALANTIR_VERSION}-standalone.jar"
env:
PALANTIR_VERSION: ${{ steps.setvars.outputs.palantir_version }}
54 changes: 54 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
name: Release CI

on:
workflow_call:
push:
branches:
- main
tags-ignore:
- "*"
paths:
- gradle/libs.dependencies.toml

jobs:
release:
permissions:
contents: write

name: Release CLI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
git fetch --all
git reset --hard origin/main
- name: Set variables
id: setvars
run: |
version=$(sed -n 's,palantir-version = "\(.*\)",\1,p' gradle/libs.dependencies.toml)
echo "palantir_version=$version" >> $GITHUB_OUTPUT
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 21
cache: gradle
- run: |
./gradlew build -S --warning-mode all --no-daemon "-PprojVersion=${PALANTIR_VERSION}"
env:
PALANTIR_VERSION: ${{ steps.setvars.outputs.palantir_version }}
- run: |
java -jar "build/libs/palantir-cli-$PALANTIR_VERSION-standalone.jar"
env:
PALANTIR_VERSION: ${{ steps.setvars.outputs.palantir_version }}
- name: Release palantir cli ${{steps.setvars.outputs.palantir_version}}"
run: |
gh release create \
"$PALANTIR_VERSION" \
-t "Palantir CLI $PALANTIR_VERSION" \
--generate-notes \
"build/libs/palantir-cli-${PALANTIR_VERSION}-standalone.jar"
env:
PALANTIR_VERSION: ${{ steps.setvars.outputs.palantir_version }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51 changes: 51 additions & 0 deletions .github/workflows/renovate-automerge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: "Renovate Automerge"

on:
pull_request_target:

jobs:
wait_and_automerge:
runs-on: ubuntu-latest

if: github.actor == 'renovate[bot]'
permissions:
contents: write
pull-requests: write

steps:
- name: 'Wait for status checks'
id: waitforstatuschecks
uses: WyriHaximus/[email protected]
with:
ignoreActions: worker,WIP
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Auto-merge
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

changes:
needs: wait_and_automerge
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
palantir: ${{ steps.filter.outputs.palantir }}
steps:
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
palantir:
- gradle/libs.dependencies.toml
auto_release:
needs: changes
if: ${{ needs.changes.outputs.palantir == 'true' }}
permissions:
contents: write

uses: ./.github/workflows/release.yml
35 changes: 35 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
= Basic Palantir Java Format CLI
:palantir_base: https://github.com/palantir/palantir-java-format
:palantir: {palantir_base}[Palantir Java Format]
:palantir_issues: {palantir_base}/issues[Palantir Java Format Issues]

Basic {palantir} CLI app builder.

This builder doesn't alter anything to the code.

== License

License is the same as the {palantir_base}[base project].

== Versioning

Version is always matches the {palantir_base}[base project].

Give me a shout if any older versions are needed.

== Java version required

Java version required is the same as {palantir_base}[base project].
This project is just a re-pack of the original project by creating fat jar.

== Transitive dependency policy and security issues

This project doesn't care about transitive dependencies.
If any vulnerabilities has been found, please report to {palantir_issues}.

== Testing

Every jar is tested only if `java -jar <filename>.jar` won't fail (main class exists).

If Palantir stopped work for you or parameters has been changed
please report to {palantir_issues}.
36 changes: 36 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
plugins {
application
id("org.jetbrains.kotlin.jvm") version "1.9.22"
}
// FYI: project group is not used anywhere.
project.group = "org.github.eirnym.palantir"
project.version = project.properties["projVersion"] ?: "1.0.0"

application {
mainClass.set("com.palantir.javaformat.java.Main")
}

tasks {
val fatJar = register<Jar>("fatJar") {
dependsOn.addAll(
listOf("compileJava", "compileKotlin", "processResources"),
) // We need this for Gradle optimization to work
archiveClassifier.set("standalone") // Naming the jar
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
manifest {
attributes(mapOf("Main-Class" to application.mainClass))
} // Provided we set it up in the application plugin configuration
val sourcesMain = sourceSets.main.get()
val contents = configurations.runtimeClasspath.get()
.map { if (it.isDirectory) it else zipTree(it) } +
sourcesMain.output
from(contents)
}
build {
dependsOn(fatJar) // Trigger fat jar creation during build
}
}

dependencies {
implementation(libs.palantir)
}
7 changes: 7 additions & 0 deletions gradle/libs.dependencies.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[versions]
# Version of Kotlin Gradle Plugin used for compilation.
palantir-version = "2.30.0"

[libraries]

palantir = { module = "com.palantir.javaformat:palantir-java-format", version.ref = "palantir-version" }
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 6 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 9924904

Please sign in to comment.