Skip to content

Commit

Permalink
(ci) fix file path & add task for package publish at nyaaci
Browse files Browse the repository at this point in the history
  • Loading branch information
Lori3f6 committed Aug 19, 2024
1 parent 2728f7b commit cd338b4
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 5 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/package-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path
# also ref:
# Publishing packages to GitHub Packages:
# https://docs.github.com/en/actions/use-cases-and-examples/publishing-packages/publishing-java-packages-with-maven#publishing-packages-to-github-packages
#
# Upgrade to Automatic token authentication, no need for personal access token anymore
# ref: https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions#upgrading-a-workflow-that-accesses-a-registry-using-a-personal-access-token
#

name: Publish to GitHub Packages

run-name: 'Package Publish #${{github.run_number}}'

on:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

permissions:
packages: write
contents: read

steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'oracle'
server-id: 'github-package'

- name: Publish to GitHub Packages Apache Maven
run: ./gradlew publishToGithubPackage
env:
GITHUB_MAVEN_URL: https://maven.pkg.github.com/${{github.repository}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
3 changes: 1 addition & 2 deletions src/main/Jenkinsfile → Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

pipeline {
agent any
stages {
Expand All @@ -7,7 +6,7 @@ pipeline {
jdk "jdk21"
}
steps {
sh './gradlew build'
sh './gradlew publishMavenJavaPublicationToNyaaCatCILocalRepository'
}
}
}
Expand Down
22 changes: 19 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,34 @@ publishing {
create<MavenPublication>("mavenJava") {
from(components["java"])
groupId = project.group.toString()
artifactId = "lockettepro"
artifactId = rootProject.name.lowercase()
version = project.version.toString()
}
}
repositories {
maven {
name = "github-package"
url = URI(System.getenv("GITHUB_MAVEN_URL") ?: "https://github.com")
name = "GithubPackage"
url =
URI(System.getenv("GITHUB_MAVEN_URL") ?: "https://github.com/")
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
maven {
name = "NyaaCatCILocal"
//local maven repository
url = uri("file://${System.getenv("MAVEN_DIR")}")
}
}
}

// Custom tasks for publishing to specific repositories
tasks.register("publishToGithubPackage") {
dependsOn("publishMavenJavaPublicationToGithubPackageRepository")
// auto generated task: publish<PublicationName>PublicationTo<RepositoryName>Repository
}

tasks.register("publishToNyaaCatCILocal") {
dependsOn("publishMavenJavaPublicationToNyaaCatCILocalRepository")
}

0 comments on commit cd338b4

Please sign in to comment.