Skip to content

Commit

Permalink
Add GitHub action to build artifact
Browse files Browse the repository at this point in the history
  • Loading branch information
Stypox committed May 27, 2024
1 parent 2a4cb7a commit 4657ba1
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: CI

on:
push:
branches:
- master
workflow_dispatch:

permissions:
contents: read

jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3

- name: Publish package
run: ./gradlew publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMMIT_SHA: ${{ vars.GITHUB_SHA }}
32 changes: 32 additions & 0 deletions numbers/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import java.net.URI

plugins {
alias(libs.plugins.org.jetbrains.kotlin.jvm)
id("java-library")
id("maven-publish")
}

group = "org.dicio"
version = System.getenv("COMMIT_SHA")

kotlin {
jvmToolchain(17)
}
Expand All @@ -11,3 +17,29 @@ dependencies {
implementation(libs.nanojson)
testImplementation(libs.junit)
}

val sourcesJar by tasks.registering(Jar::class) {
archiveClassifier.convention("sources");
archiveClassifier.set("sources");
from(sourceSets.main.get().allSource)
}

publishing {
repositories {
maven {
name = "GitHubPackages"
url = URI("https://maven.pkg.github.com/octocat/hello-world")
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}
publications {
register("mavenJava", MavenPublication::class) {
artifactId = "numbers"
from(components["java"])
artifact(sourcesJar.get())
}
}
}

0 comments on commit 4657ba1

Please sign in to comment.