Skip to content

Commit

Permalink
Action to publish packages to mzio (#2285)
Browse files Browse the repository at this point in the history
* add publish actions to upload packages in mzio repo

* update publish actions

* update publish actions

* publish locally for testing

use
./gradlew convention-plugins:java-convention:publish
for convention plugins

* update action to publish convention plugins

* update publish task names

* make publish tasks publish on github

* add centralised publishing config

* update package names

* review
  • Loading branch information
SteffenHeu authored Dec 12, 2024
1 parent d812816 commit bfdee8b
Show file tree
Hide file tree
Showing 10 changed files with 328 additions and 7 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/gradle_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,3 @@ jobs:
prerelease: true
title: "Release build"
files: build/*/*


38 changes: 38 additions & 0 deletions .github/workflows/push_stable_packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

# GitHub recommends pinning actions to a commit SHA.
# To get a newer version, you will need to update the SHA.
# You can also reference a tag or branch, but the action may change without warning.

name: Publish packages to GitHub Packages
on:
workflow_dispatch
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
java-version: '22.0.1'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0

- name: Publish mzmine packages
run: ./gradlew publish
env:
PUBLISH_PACKAGE_USERNAME: ${{ secrets.PUBLISH_PACKAGE_USERNAME }}
PUBLISH_PACKAGE_TOKEN: ${{ secrets.PUBLISH_PACKAGE_TOKEN }}
- name: Publish convention plugins
run: ./gradlew convention-plugins:java-convention:publish
env:
PUBLISH_PACKAGE_USERNAME: ${{ secrets.PUBLISH_PACKAGE_USERNAME }}
PUBLISH_PACKAGE_TOKEN: ${{ secrets.PUBLISH_PACKAGE_TOKEN }}
40 changes: 40 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
plugins {
`maven-publish`
}

// list of sub projects that create a java library
val publishingSubProjects = listOf(
"convention-plugins",
"java-convention",
"javafx-framework",
"mzmine-community",
"taskcontroller",
"utils"
)


subprojects {
// this variable is set by running .\gradlew publish with the command line argument -Pmziorepo=true
val pushOnline: Boolean = project.findProperty("mziorepo")?.toString()?.toBoolean() ?: false
if(name in publishingSubProjects) {
apply(plugin = "maven-publish")

publishing {
repositories {
if (pushOnline) {
maven {
url = uri("https://maven.pkg.github.com/mzio-gmbh/mzio_mzmine")
credentials {
username = System.getenv("PUBLISH_PACKAGE_USERNAME")
password = System.getenv("PUBLISH_PACKAGE_TOKEN")
}
}
} else {
maven {
url = uri(layout.projectDirectory.dir("../local-repo/"))
}
}
}
}
}
}
7 changes: 6 additions & 1 deletion convention-plugins/README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@ https://docs.gradle.org/current/samples/sample_building_java_applications_multi_

https://docs.gradle.org/current/samples/sample_convention_plugins.html

https://docs.gradle.org/current/samples/sample_sharing_convention_plugins_with_build_logic.html
https://docs.gradle.org/current/samples/sample_sharing_convention_plugins_with_build_logic.html


## Version

The version of this project is bound to the mzmine community version.
51 changes: 51 additions & 0 deletions convention-plugins/java-convention/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,11 +1,62 @@
plugins {
`kotlin-dsl`
id("maven-publish")
alias(libs.plugins.semver)
}

semver {
properties = "../../mzmine-community/src/main/resources/mzmineversion.properties"
}

// this variable is set by running .\gradlew publish with the command line argument -Pmziorepo=true
val pushOnline: Boolean = project.findProperty("mziorepo")?.toString()?.toBoolean() ?: false


kotlin {
jvmToolchain(21)
}

dependencies {
implementation(libs.javafx.plugin)
}

afterEvaluate {
// the repositories must be set in the afterEvaluate block, because the semver plugin will
// not be initialised otherwise. The convention plugin version is bound to the mzmine community version.
publishing {
repositories {
if (pushOnline) {
maven {
url = uri("https://maven.pkg.github.com/mzio-gmbh/mzio_mzmine")
credentials {
username = System.getenv("PUBLISH_PACKAGE_USERNAME")
password = System.getenv("PUBLISH_PACKAGE_TOKEN")
}
}
} else {
maven {
url = uri(layout.projectDirectory.dir("../../local-repo/"))
}
}
}
publications {
register<MavenPublication>("publish-convention-plugins") {
from(components["java"])
pom {
group = "io.github.mzmine"
artifactId = "convention-plugins"
name = "mzmine-community convention-plugins"
description = "mzmine-community convention plugins"
url = "https://github.com/mzmine/mzmine"
version = semver.version
developers {
developer {
id = "mzmine"
name = "mzmine"
}
}
}
}
}
}
}
59 changes: 58 additions & 1 deletion javafx-framework/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,33 @@
/*
* Copyright (c) 2004-2024 The mzmine Development Team
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/

plugins {
id("io.github.mzmine.java-library-conv")
id("io.github.mzmine.javafx-conv")
id("maven-publish")
alias(libs.plugins.semver)
}

repositories {
Expand All @@ -16,4 +43,34 @@ dependencies {
implementation("io.mzio:memory-management:1.0.0")
implementation("io.mzio:taskcontroller:1.0.0")
implementation(libs.guava)
}
}

semver {
properties = "../mzmine-community/src/main/resources/mzmineversion.properties"
}

afterEvaluate {
// the repositories must be set in the afterEvaluate block, because the semver plugin will
// not be initialised otherwise. The version of this library is bound to the mzmine community version.
publishing {
publications {
register<MavenPublication>("publish-javafx-framework") {
from(components["java"])
pom {
group = "io.github.mzmine"
artifactId = "javafx-framework"
name = "mzmine-javafx-framework"
description = "mzmine-community java fx framework"
url = "https://github.com/mzmine/mzmine"
version = semver.version
developers {
developer {
id = "mzmine"
name = "mzmine"
}
}
}
}
}
}
}
45 changes: 44 additions & 1 deletion mzmine-community/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ plugins {
// https://github.com/ethauvin/semver-gradle
alias(libs.plugins.semver)
alias(libs.plugins.licensereport)

id("maven-publish")
id("version-catalog")
}

// save version to main resources
Expand All @@ -53,7 +56,14 @@ plugins {
// version with -beta is currently not supported by jpackage (maybe windows --app-version)
// java.lang.IllegalArgumentException: "Version [3.0.0-beta] contains invalid component [0-beta]"
semver {
properties = "src/main/resources/mzmineversion.properties"
def versionFile = getLayout().getProjectDirectory().dir("src/main/resources").file("mzmineversion.properties").getAsFile()
properties = versionFile.toString()
}

catalog {
versionCatalog {
from(files("$rootDir/gradle/libs.versions.toml"))
}
}

// version is now in version.properties
Expand Down Expand Up @@ -611,3 +621,36 @@ tasks.compileJava.dependsOn(checkLicense, copyLicenseInformationToResources, cop
// copying must be finished before packaging
tasks.processResources.dependsOn(copyLicenseInformationToResources, copyLicenseInformationToBuild)
tasks.processResources.dependsOn(copyLicenseInformationToResources, copyLicenseInformationToBuild)


// make sure the publish action is run after the semver plugin has been evaluated,
// otherwise the version will always be 1.0.0
afterEvaluate {
publishing {
publications {
register("mzmine-community-package", MavenPublication) {
from(components["java"])
pom {
name = "mzmine-community"
description = "mzmine-community"
artifactId = "mzmine-community"
url = "https://github.com/mzmine/mzmine"
version = semver.version
developers {
developer {
id = "mzmine"
name = "mzmine"
}
}
}
}

register("versionCatalog", MavenPublication) {
from(components["versionCatalog"])
version = semver.version
artifactId = 'mzmine-community-version-catalog'
// This is important so the published artifact registers as a .toml file, rather than a library
}
}
}
}
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ include(
"javafx-framework",
"config",
)
//includeBuild("convention-plugins")
//includeBuild("convention-plugins")
59 changes: 58 additions & 1 deletion taskcontroller/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,33 @@
/*
* Copyright (c) 2004-2024 The mzmine Development Team
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/

plugins {
id("io.github.mzmine.java-library-conv")
id("io.github.mzmine.javafx-conv")
id("maven-publish")
alias(libs.plugins.semver)
}

repositories {
Expand All @@ -13,4 +40,34 @@ dependencies {
implementation("io.mzio:memory-management:1.0.0")
implementation(project(":utils"))
implementation(libs.guava)
}
}

semver {
properties = "../mzmine-community/src/main/resources/mzmineversion.properties"
}

afterEvaluate {
// the repositories must be set in the afterEvaluate block, because the semver plugin will
// not be initialised otherwise. The version of this library is bound to the mzmine community version.
publishing {
publications {
register<MavenPublication>("publish-task-controller") {
from(components["java"])
pom {
group = "io.github.mzmine"
artifactId = "taskcontroller"
name = "mzmine-community-task-controller"
description = "mzmine-community task controller"
url = "https://github.com/mzmine/mzmine"
version = semver.version
developers {
developer {
id = "mzmine"
name = "mzmine"
}
}
}
}
}
}
}
Loading

0 comments on commit bfdee8b

Please sign in to comment.