Skip to content

Change build file and actions configurations #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
Draft
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
49 changes: 49 additions & 0 deletions .github/workflows/feature-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: On push to a feature branch

on:
push:
branches:
- '*'
paths-ignore:
- '**.md'
- '**.adoc'
- '**/.gitignore'
- './github/**'
- '!./github/workflow/feature-branch.yml'
pull_request:
branches:
- '*'

jobs:
snapshot:
runs-on: ubuntu-latest
steps:
- name: Install packages
run: |
sudo apt update
sudo apt install -y git
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Get sv4git
run: |
wget -O /tmp/sv4git.zip https://github.com/bvieira/sv4git/releases/download/v2.4.0/git-sv_2.4.0_linux_amd64.tar.gz
cd /usr/local/bin
tar xzf /tmp/sv4git.zip
chmod +x git-sv
- name: Get Version
id: get-version
run: |
VERSION="$(git sv next-version)-SNAPSHOT-$(git rev-parse --short HEAD)"
echo "VERSION=$VERSION"
echo "::set-output name=version::$VERSION"
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build
run: ./gradlew build -Pversion=${{steps.get-version.outputs.version}}
51 changes: 51 additions & 0 deletions .github/workflows/feature-merged.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: On merge into main

on:
push:
branches:
- 'main'
paths-ignore:
- '**.md'
- '**.adoc'
- '**/.gitignore'
- './github/**'
- '!./github/workflow/feature-merged.yml'

jobs:
snapshot:
runs-on: ubuntu-latest
steps:
- name: Install packages
run: |
sudo apt update
sudo apt install -y git
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Get sv4git
run: |
wget -O /tmp/sv4git.zip https://github.com/bvieira/sv4git/releases/download/v2.4.0/git-sv_2.4.0_linux_amd64.tar.gz
cd /usr/local/bin
tar xzf /tmp/sv4git.zip
chmod +x git-sv
- name: Get Version
id: get-version
run: |
VERSION="$(git sv next-version)-SNAPSHOT-$(git rev-parse --short HEAD)"
echo "VERSION=$VERSION"
echo "::set-output name=version::$VERSION"
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build and publish to maven central snapshots
run: ./gradlew publishAllPublicationsToOss -Pversion=${{steps.get-version.outputs.version}}
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_PRIVATE_PASSWORD: ${{ secrets.GPG_PRIVATE_PASSWORD }}
5 changes: 2 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Release workflow
name: After release published

on:
release:
Expand All @@ -18,10 +18,9 @@ jobs:
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build and publish to maven central
run: ./gradlew publishAllPublicationsToOss -PsnapshotVersion=false
run: ./gradlew publishAllPublicationsToOss
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_PRIVATE_PASSWORD: ${{ secrets.GPG_PRIVATE_PASSWORD }}

34 changes: 0 additions & 34 deletions .github/workflows/snapshot.yml

This file was deleted.

37 changes: 0 additions & 37 deletions .github/workflows/wip.yml

This file was deleted.

79 changes: 38 additions & 41 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,45 @@ plugins {
}

group = "io.github.vfmunhoz"
version = "1.0.0"

val snapshotVersion: String =
if(project.hasProperty("snapshotVersion")) project.findProperty("snapshotVersion").toString()
else "true"
version = "0.0.1-SNAPSHOT"

val sonatypeReleaseRepo: String by project
val sonatypeSnapshotRepo: String by project
val sonatypeUsername: String? = System.getenv("SONATYPE_USERNAME")
val sonatypePassword: String? = System.getenv("SONATYPE_PASSWORD")
val repositoryId: String? = System.getenv("SONATYPE_REPOSITORY_ID")
val sonatypeRepositoryId: String? = System.getenv("SONATYPE_REPOSITORY_ID")

val gpgPrivateKey: String? = System.getenv("GPG_PRIVATE_KEY")
val gpgPrivatePassword: String? = System.getenv("GPG_PRIVATE_PASSWORD")

val dokkaOutputDir = "$buildDir/dokka"

repositories {
mavenCentral()
}

dependencies {
implementation(kotlin("stdlib"))
implementation(kotlin("reflect"))

compileOnly("com.fasterxml.jackson.module:jackson-module-kotlin:2.12.+")

testImplementation(kotlin("test"))
testImplementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.12.+")

dokkaHtmlPlugin("org.jetbrains.dokka:kotlin-as-java-plugin:1.5.0")
}

tasks.test {
useJUnitPlatform()
}

// Suppressing test compile warnings since we intentionally
// cause an overflow on arithmetic operation for integer types.
tasks.compileTestKotlin {
kotlinOptions.suppressWarnings = true
}

tasks.getByName<org.jetbrains.dokka.gradle.DokkaTask>("dokkaHtml") {
outputDirectory.set(file(dokkaOutputDir))
}
Expand All @@ -37,14 +64,10 @@ val sourcesJar = tasks.register<Jar>("sourcesJar") {
from(sourceSets.getByName("main").allSource)
}

repositories {
mavenCentral()
}

signing {
useInMemoryPgpKeys(
System.getenv("GPG_PRIVATE_KEY"),
System.getenv("GPG_PRIVATE_PASSWORD")
gpgPrivateKey,
gpgPrivatePassword
)

sign(publishing.publications)
Expand All @@ -55,14 +78,10 @@ publishing {
maven {
name = "oss"

val releasesRepoUrl = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
val snapshotsRepoUrl = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
val repoUri = if (version.toString().contains("SNAPSHOT")) { sonatypeSnapshotRepo }
else { sonatypeReleaseRepo }

if(snapshotVersion == "false" && version.toString().endsWith("SNAPSHOT")) {
throw Exception("To publish the release the version must not end with -SNAPSHOT")
}

url = if (snapshotVersion == "true") snapshotsRepoUrl else releasesRepoUrl
url = uri(repoUri)

credentials {
username = sonatypeUsername
Expand Down Expand Up @@ -108,25 +127,3 @@ publishing {
}
}
}

dependencies {
implementation(kotlin("stdlib"))
implementation(kotlin("reflect"))

compileOnly("com.fasterxml.jackson.module:jackson-module-kotlin:2.12.+")

testImplementation(kotlin("test"))
testImplementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.12.+")

dokkaHtmlPlugin("org.jetbrains.dokka:kotlin-as-java-plugin:1.5.0")
}

tasks.test {
useJUnitPlatform()
}

// Suppressing test compile warnings since we intentionally
// cause an overflow on arithmetic operation for integer types.
tasks.compileTestKotlin {
kotlinOptions.suppressWarnings = true
}
5 changes: 4 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
kotlin.code.style=official
kotlin.code.style=official

sonatypeReleaseRepo="https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
sonatypeSnapshotRepo="https://s01.oss.sonatype.org/content/repositories/snapshots/"
1 change: 0 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
rootProject.name = 'kotlin-protected-types'