Add publish in CI
This commit is contained in:
53
.github/workflows/publish.yml
vendored
Normal file
53
.github/workflows/publish.yml
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
name: Publish
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [ published ]
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up JDK 11
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 11
|
||||
|
||||
- name: Cache Gradle packages
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: |
|
||||
~/.gradle/caches
|
||||
~/.gradle/wrapper
|
||||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-gradle-
|
||||
|
||||
- name: Build
|
||||
uses: eskatos/gradle-command-action@v1
|
||||
with:
|
||||
gradle-version: '7.1'
|
||||
arguments: build -x test -x ktlintKotlinScriptCheck -x ktlintTestSourceSetCheck -x ktlintMainSourceSetCheck
|
||||
- name: Cleanup Gradle Cache
|
||||
# Remove some files from the Gradle cache, so they aren't cached by GitHub Actions.
|
||||
# Restoring these files from a GitHub Actions cache might cause problems for future builds.
|
||||
run: |
|
||||
rm -f ~/.gradle/caches/modules-2/modules-2.lock
|
||||
rm -f ~/.gradle/caches/modules-2/gc.properties
|
||||
|
||||
- name: Test
|
||||
uses: eskatos/gradle-command-action@v1
|
||||
with:
|
||||
gradle-version: '7.1'
|
||||
arguments: test
|
||||
|
||||
- name: Publish
|
||||
uses: eskatos/gradle-command-action@v1
|
||||
with:
|
||||
gradle-version: '7.1'
|
||||
arguments: publish
|
||||
env:
|
||||
GITHUB_ACTOR: ${{ secrets.GITHUB_ACTOR }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
2
.github/workflows/tests.yml
vendored
2
.github/workflows/tests.yml
vendored
@@ -9,7 +9,7 @@ on:
|
||||
- 'main'
|
||||
|
||||
jobs:
|
||||
Test:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
|
||||
@@ -7,7 +7,7 @@ plugins {
|
||||
id("org.sonarqube") version "+"
|
||||
}
|
||||
|
||||
group "io.github.flecomte"
|
||||
group = "io.github.flecomte"
|
||||
version = versioning.info.run {
|
||||
if (dirty) {
|
||||
versioning.info.full
|
||||
@@ -42,29 +42,33 @@ val sourcesJar by tasks.registering(Jar::class) {
|
||||
}
|
||||
|
||||
publishing {
|
||||
if (versioning.info.dirty == false) {
|
||||
repositories {
|
||||
maven {
|
||||
name = "skilningur"
|
||||
group = "io.github.flecomte"
|
||||
url = uri("https://maven.pkg.github.com/flecomte/skilningur")
|
||||
credentials {
|
||||
username = System.getenv("GITHUB_USERNAME")
|
||||
password = System.getenv("GITHUB_TOKEN")
|
||||
}
|
||||
repositories {
|
||||
maven {
|
||||
name = "access-control"
|
||||
url = uri("https://maven.pkg.github.com/flecomte/access-control")
|
||||
credentials {
|
||||
username = System.getenv("GITHUB_ACTOR")
|
||||
password = System.getenv("GITHUB_TOKEN")
|
||||
}
|
||||
}
|
||||
|
||||
publications {
|
||||
create<MavenPublication>("skilningur") {
|
||||
from(components["java"])
|
||||
artifact(sourcesJar)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
org.slf4j.LoggerFactory.getLogger("gradle")
|
||||
.error("The git is DIRTY (${versioning.info.full})")
|
||||
}
|
||||
|
||||
publications {
|
||||
create<MavenPublication>("access-control") {
|
||||
from(components["java"])
|
||||
artifact(sourcesJar)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<PublishToMavenRepository>().configureEach {
|
||||
onlyIf {
|
||||
versioning.info.run {
|
||||
!dirty && tag != null && tag.matches("""[0-9]+\.[0-9]+\.[0-9]+""".toRegex())
|
||||
}
|
||||
}
|
||||
|
||||
dependsOn(tasks.test)
|
||||
}
|
||||
|
||||
repositories {
|
||||
|
||||
Reference in New Issue
Block a user