Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: CI

on:
push:
branches: [master]
pull_request:

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 21
- uses: gradle/actions/setup-gradle@v5
- run: ./gradlew test javadoc
41 changes: 41 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Release

# Publishing a GitHub Release (e.g. tag "1.3") publishes that version to
# Maven Central and attaches fastjavaio.jar to the release.
on:
release:
types: [published]

permissions:
contents: write # upload the jar to the release

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 21
- uses: gradle/actions/setup-gradle@v5

- name: Determine version from tag
id: version
run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"

- name: Test
run: ./gradlew test -PreleaseVersion=${{ steps.version.outputs.version }}

- name: Publish to Maven Central
run: ./gradlew publishToMavenCentral makeJar -PreleaseVersion=${{ steps.version.outputs.version }}
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_KEY_PASSWORD }}

- name: Attach fastjavaio.jar to the release
run: gh release upload "$GITHUB_REF_NAME" fastjavaio.jar --clobber
env:
GH_TOKEN: ${{ github.token }}
48 changes: 42 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
plugins {
id 'java-library'
id 'com.vanniktech.maven.publish' version '0.37.0'
}

group = 'io.github.williamfiset'
version = '1.2'
// Release builds pass -PreleaseVersion=<tag>; local builds are snapshots.
version = providers.gradleProperty('releaseVersion').getOrElse('1.3-SNAPSHOT')

repositories {
mavenCentral()
Expand All @@ -14,11 +16,6 @@ dependencies {
testImplementation 'junit:junit:4.13.2'
}

java {
withSourcesJar()
withJavadocJar()
}

// Compile against the Java 8 API so the jar runs on any judge or JVM from Java 8 onward.
tasks.withType(JavaCompile).configureEach {
options.release = 8
Expand Down Expand Up @@ -51,3 +48,42 @@ tasks.register('makeJar') {
java.nio.file.StandardCopyOption.REPLACE_EXISTING)
}
}

// Maven Central publishing (sources and javadoc jars are added by the plugin).
// Credentials come from Gradle properties / ORG_GRADLE_PROJECT_* env vars:
// mavenCentralUsername, mavenCentralPassword, signingInMemoryKey, signingInMemoryKeyPassword
mavenPublishing {
publishToMavenCentral(true) // true = release automatically once validation passes
// Central requires signatures; skip signing for local builds that have no key.
if (providers.gradleProperty('signingInMemoryKey').isPresent()) {
signAllPublications()
}

coordinates(project.group.toString(), 'fastjavaio', project.version.toString())

pom {
name = 'FastJavaIO'
description = 'A lightweight, dependency-free, fast input reader for Java.'
inceptionYear = '2017'
url = 'https://github.com/williamfiset/FastJavaIO'
licenses {
license {
name = 'GNU General Public License v3.0'
url = 'https://www.gnu.org/licenses/gpl-3.0.txt'
distribution = 'repo'
}
}
developers {
developer {
id = 'williamfiset'
name = 'William Fiset'
url = 'https://github.com/williamfiset'
}
}
scm {
url = 'https://github.com/williamfiset/FastJavaIO'
connection = 'scm:git:git://github.com/williamfiset/FastJavaIO.git'
developerConnection = 'scm:git:ssh://git@github.com/williamfiset/FastJavaIO.git'
}
}
}
Loading