Skip to content

Commit

Permalink
Hopefully set up CI
Browse files Browse the repository at this point in the history
  • Loading branch information
lukebemish committed Aug 16, 2023
1 parent ddf8274 commit 04c2e09
Show file tree
Hide file tree
Showing 18 changed files with 406 additions and 22 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/pullrequest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Publish PR
on:
workflow_run:
workflows: [Test]
types: [completed]
jobs:
publish:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' }}
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
repository: lukebemish/artifact-sync
ref: refs/heads/main
- run: mkdir repo
- name: 'Download artifact'
uses: actions/github-script@v6
with:
script: |
const pull_requests = ${{ toJSON(github.event.workflow_run.pull_requests) }};
if (!pull_requests.length) {
return core.error("This workflow doesn't match any pull requests!");
}
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name == "artifacts"
})[0];
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/repo.zip`, Buffer.from(download.data));
- name: 'Unzip artifacts'
run: unzip repo.zip -d repo
- name: 'Publish artifacts'
run: python3 run.py
env:
MAVEN_USER: github
MAVEN_PASSWORD: ${{ secrets.PR_MAVEN_PASSWORD }}
MAVEN_URL: "https://maven.lukebemish.dev/pullrequests/"
ALLOWED_VERSION: '*-pr${{ github.event.workflow_run.pull_requests[0].number }}'
ALLOWED_PATHS: "dev/lukebemish/opensesame/opensesame-*"
37 changes: 37 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Release
concurrency: ci-${{ github.ref }}
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: fregante/setup-git-user@v2
- uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: 17ZjI2NzVjNTUyZDhmOTczOGY2OTJkYmVlNDYyYjFlZmM0MTc5MGJjYzg5MjZkZGU1
- uses: gradle/gradle-build-action@v2
with:
arguments: tagRelease
cache-read-only: ${{ !startsWith(github.ref, 'refs/heads/1.') }}
- uses: gradle/gradle-build-action@v2
with:
arguments: build
cache-read-only: ${{ !startsWith(github.ref, 'refs/heads/1.') }}
- uses: gradle/gradle-build-action@v2
with:
arguments: publish
cache-read-only: ${{ !startsWith(github.ref, 'refs/heads/1.') }}
env:
IS_RELEASE: true
MAVEN_USER: github
MAVEN_PASSWORD: ${{ secrets.RELEASE_MAVEN_PASSWORD }}
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
- run: |
git push
git push --tags
33 changes: 33 additions & 0 deletions .github/workflows/snapshot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Snapshot
concurrency: ci-${{ github.ref }}
on:
workflow_dispatch:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
fetch-depth: 0
- uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: 17
- uses: gradle/gradle-build-action@v2
with:
arguments: build
cache-read-only: ${{ !startsWith(github.ref, 'refs/heads/1.') }}
- uses: gradle/gradle-build-action@v2
with:
arguments: publish
cache-read-only: ${{ !startsWith(github.ref, 'refs/heads/1.') }}
env:
MAVEN_USER: github
MAVEN_PASSWORD: ${{ secrets.SNAPSHOT_MAVEN_PASSWORD }}
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
SNAPSHOT_MAVEN_URL: https://maven.lukebemish.dev/snapshots/
30 changes: 30 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Test
concurrency: ci-${{ github.ref }}
on: [workflow_dispatch, pull_request]
jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
fetch-depth: 0
- uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: 17
- uses: gradle/gradle-build-action@v2
with:
arguments: build
cache-read-only: ${{ !startsWith(github.ref, 'refs/heads/1.') }}
- uses: gradle/gradle-build-action@v2
with:
arguments: publish
cache-read-only: ${{ !startsWith(github.ref, 'refs/heads/1.') }}
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
- name: Archive publishable artifacts
uses: actions/upload-artifact@v3
with:
name: artifacts
path: build/repo
81 changes: 68 additions & 13 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,74 @@
plugins {
id 'groovy'
id 'java-library'
id 'maven-publish'
id 'io.github.gradle-nexus.publish-plugin' version '1.3.0'
}

java.withSourcesJar()
apply from: 'version.gradle'

subprojects {
apply plugin: 'java-library'
apply plugin: 'maven-publish'
apply plugin: 'signing'

afterEvaluate {
if (System.getenv('IS_RELEASE') || System.getenv('SNAPSHOT_MAVEN_URL')) {
signing {
final signingKey = System.getenv('SIGNING_KEY') ?: ''
final signingPassword = System.getenv('SIGNING_PASSWORD') ?: ''
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications.mavenJava
}
}
}

processResources {
from rootProject.file('LICENSE')
}

jar {
manifest {
attributes([
'Specification-Version' : rootProject.version,
'Implementation-Commit-Time': versioning.getGitCommitDate(),
'Implementation-Commit': versioning.getGitCommit()
])
}
}
}

if (System.getenv('PR_NUMBER')) {
publishing {
repositories {
maven {
name = 'LocalMaven'
url = rootProject.layout.buildDirectory.dir('repo')
}
}
}
} else if (System.getenv('SNAPSHOT_MAVEN_URL')) {
publishing {
repositories {
maven {
name = 'PersonalMaven'
url = uri(System.getenv('SNAPSHOT_MAVEN_URL'))
credentials {
username = System.getenv('MAVEN_USER')
password = System.getenv('MAVEN_PASSWORD')
}
}
}
}
} else {
nexusPublishing {
repositories {
sonatype {
username.set(System.getenv('SONATYPE_USER') ?: '')
password.set(System.getenv('SONATYPE_PASSWORD') ?: '')
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
}
}
}
}

repositories {
mavenCentral()
Expand All @@ -13,8 +77,7 @@ repositories {
dependencies {
implementation 'org.apache.groovy:groovy:4.0.12'
implementation project(':opensesame-runtime')

compileOnly 'org.jetbrains:annotations:24.0.1'
implementation project(':opensesame-transform')

testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
Expand All @@ -27,12 +90,4 @@ test {
exceptionFormat = 'full'
events = ['passed', 'failed', 'skipped']
}
}

publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}
3 changes: 1 addition & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
group=dev.lukebemish
version=0.1.0
group=dev.lukebemish.opensesame
33 changes: 28 additions & 5 deletions opensesame-runtime/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
plugins {
id 'java-library'
id 'maven-publish'
}

java.withSourcesJar()
java.withJavadocJar()

Expand All @@ -18,6 +13,34 @@ publishing {
publications {
mavenJava(MavenPublication) {
from components.java

pom {
name = "OpenSesame - Runtime"
packaging = 'jar'
description = 'Runtime metafactory used for OpenSesame, a tool for fase typesafe access of private members with groovy'
url = 'https://github.com/lukebemish/OpenSesame'
inceptionYear = '2023'

licenses {
license {
name = '3-Clause BSD License'
url = 'https://opensource.org/license/bsd-3-clause/'
}
}
developers {
developer {
id = 'lukebemish'
name = 'Luke Bemish'
email = '[email protected]'
url = 'https://github.com/lukebemish/'
}
}
scm {
connection='scm:git:git://github.com/lukebemish/OpenSesame.git'
developerConnection='scm:git:ssh://github.com/lukebemish/OpenSesame.git'
url='https://github.com/lukebemish/OpenSesame'
}
}
}
}
}
59 changes: 59 additions & 0 deletions opensesame-transform/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
plugins {
id 'groovy'
}

java.withSourcesJar()
groovydoc.use = true

tasks.register('groovydocJar', Jar) {
dependsOn groovydoc
archiveClassifier.set 'javadoc'
from groovydoc.destinationDir
}

repositories {
mavenCentral()
}

dependencies {
implementation 'org.apache.groovy:groovy:4.0.12'
implementation project(':opensesame-runtime')
compileOnly 'org.jetbrains:annotations:24.0.1'
}

publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact tasks.groovydocJar

pom {
name = "OpenSesame - Transform"
packaging = 'jar'
description = 'Compile-time groovy ASTT used for OpenSesame, a tool for fase typesafe access of private members with groovy'
url = 'https://github.com/lukebemish/OpenSesame'
inceptionYear = '2023'

licenses {
license {
name = '3-Clause BSD License'
url = 'https://opensource.org/license/bsd-3-clause/'
}
}
developers {
developer {
id = 'lukebemish'
name = 'Luke Bemish'
email = '[email protected]'
url = 'https://github.com/lukebemish/'
}
}
scm {
connection='scm:git:git://github.com/lukebemish/OpenSesame.git'
developerConnection='scm:git:ssh://github.com/lukebemish/OpenSesame.git'
url='https://github.com/lukebemish/OpenSesame'
}
}
}
}
}
3 changes: 2 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
rootProject.name = 'opensesame'

include 'opensesame-runtime'
include 'opensesame-runtime'
include 'opensesame-transform'
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import dev.lukebemish.opensesame.OpenSesame
import dev.lukebemish.opensesame.test.otherpackage.HasPrivateCtor
import dev.lukebemish.opensesame.test.otherpackage.ToOpen
import groovy.transform.CompileStatic
import groovy.transform.TypeChecked
import org.junit.jupiter.api.Test

@CompileStatic
Expand Down
Loading

0 comments on commit 04c2e09

Please sign in to comment.