Skip to content

Commit

Permalink
release v9 (#287)
Browse files Browse the repository at this point in the history
#286

---------

Co-authored-by: Dr. Ernie Prabhakar <19791+drernie@users.noreply.github.com>
  • Loading branch information
drernie and drernie authored Dec 24, 2024
1 parent b8fce6e commit 764840e
Show file tree
Hide file tree
Showing 18 changed files with 268 additions and 335 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Changelog

## [0.9.0] TBD
## [0.9.0] 2024-12-23

- Only supports Nextflow 24.10 and later (uses Groovy 4)
- Shift to quiltcore 0.1.6 convenience methods
- Shift metadata and configuration to `quilt` scope of nextflow.config
- Moved test workflows into `wf` folder
- Write the output URI when publishing
Expand Down
16 changes: 3 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ NF_DIR ?= ../nextflow
NF_GIT ?= $(NF_DIR)/nextflow
NF_BIN ?= ./launch.sh
PID ?= $$$$
PIPELINE ?= sarek
QUERY ?= ?Name=$(USER)&Owner=Kevin+Moore&Date=2023-03-07&Type=CRISPR&Notebook+URL=http%3A%2F%2Fexample.com
VERSION ?= $(shell grep 'Plugin-Version' plugins/$(PROJECT)/src/resources/META-INF/MANIFEST.MF | awk '{ print $$2 }')
NXF_VER ?= $(shell cat VERSION)
Expand Down Expand Up @@ -108,16 +107,6 @@ path-input: compile
tower-test: $(NF_BIN)
$(NF_BIN) run "https://github.com/quiltdata/nf-quilt" -name local_einstein -with-tower -r main -latest --pub "$(TEST_URI)"

# use `make $(PIPELINE) WRITE_BUCKET=my-s3-bucket` to publish `--outdir` to a Quilt package

$(PIPELINE): $(NF_BIN) install
echo "Ensure you have docker running"
$(NF_BIN) pull nf-core/$(PIPELINE)
$(NF_BIN) run nf-core/$(PIPELINE) -profile test,docker -plugins $(PROJECT)@$(VERSION) --outdir "$(PIPE_OUT)"

fetchngs: $(NF_GIT)
NXF_VER=$(NXF_VER) $(NF_BIN) run quiltdata/fetchngs -r master -profile test,docker --input wf/ids.csv --outdir "s3://$(WRITE_BUCKET)/nf-quilt/fetchngs"

nf-git-ver: $(NF_GIT)
NXF_VER=$(NXF_VER) $(NF_GIT) -v

Expand All @@ -139,12 +128,13 @@ install: compile
./gradlew copyPluginZip
rm -rf ${HOME}/.nextflow/plugins/$(PROJECT)-${VERSION}
cp -r build/plugins/$(PROJECT)-${VERSION} ${HOME}/.nextflow/plugins/

#
# Upload JAR artifacts to Maven Central
#

publish:
echo "Ensure you have set 'github_organization=<owner>' in gradle.properties"
ls gradle.properties # create locally or globally if it does not exist
echo "Ensure you have set 'github_organization=<owner>' in ~/.gradle/gradle.properties"
ls $(HOME)/.gradle/gradle.properties # create locally or globally if it does not exist
./gradlew :plugins:$(PROJECT):upload
./gradlew :plugins:publishIndex
4 changes: 2 additions & 2 deletions README-DEV.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ and publish the plugin.

Otherwise, follow these steps:

1. Create a file named `gradle.properties` in the project root containing the
following attributes (this file should not be committed to Git):
1. Create a file named `gradle.properties` in the user's home (NOT project)
directory containing the following attributes:

- `github_organization`: the GitHub organisation where the plugin repository
is hosted.
Expand Down
112 changes: 62 additions & 50 deletions plugins/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@ import java.time.format.DateTimeFormatter
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* of any kind, either express or implied.
* See the License for specific language governing permissions and limitations.
*/

plugins {
Expand All @@ -28,14 +26,19 @@ plugins {
id 'io.nextflow.nf-build-plugin' version '1.0.1'
}

ext.github_organization = project.findProperty('github_organization') ?: 'nextflow-io'
ext.github_username = project.findProperty('github_username') ?: 'pditommaso'
ext.github_access_token = project.findProperty('github_access_token') ?: System.getenv('GITHUB_TOKEN')
ext.github_commit_email = project.findProperty('github_commit_email') ?: 'paolo.ditommaso@gmail.com'
ext.github_index_url = "https://github.com/${github_organization}/plugins/main/plugins.json" as GStringImpl
/* Project Constants */
ext {
github_organization = project.findProperty('github_organization') ?: 'nextflow-io'
github_username = project.findProperty('github_username') ?: 'pditommaso'
github_access_token = project.findProperty('github_access_token') ?: System.getenv('GITHUB_TOKEN')
github_commit_email = project.findProperty('github_commit_email') ?: 'paolo.ditommaso@gmail.com'
github_index_url = "https://github.com/${github_organization}/plugins/main/plugins.json" as GStringImpl
}

// Disable default JAR generation
jar.enabled = false

/* Utility Functions */
static String computeSha512(File file) {
if (!file.exists()) {
throw new GradleException("Missing file: $file -- cannot compute SHA-512")
Expand All @@ -49,7 +52,9 @@ static String now() {

List<String> allPlugins() {
def plugins = []
new File(rootProject.rootDir, 'plugins') .eachDir { if (it.name.startsWith('nf-')) plugins.add(it.name) }
new File(rootProject.rootDir, 'plugins').eachDir {
if (it.name.startsWith('nf-')) plugins.add(it.name)
}
return plugins
}

Expand All @@ -59,14 +64,15 @@ String metaFromManifest(String meta, File file) {
def m = regex.matcher(str)
if (m.find()) {
def ver = m.group(1)
println "Set plugin '${file.parentFile.parentFile.parentFile.parentFile.name}' version=${ver}"
println "Set plugin '${file.parentFile.parentFile.parentFile.parentFile.name}' version=$ver"
return ver
}
throw new GradleException("Cannot find '$meta' for plugin: $file")
}

def timestamp = now()

/* Configure Subprojects */
subprojects {
apply plugin: 'java'
apply plugin: 'groovy'
Expand All @@ -83,9 +89,14 @@ subprojects {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}

/*
* Creates plugin zip and json meta file in plugin `build/libs` directory
*/
/* Plugin Variables */
String pluginVersion = project.version
String archiveName = "${project.name}-${pluginVersion}"
File zipFile = layout.buildDirectory.file("libs/${archiveName}.zip").get().asFile
File jsonFile = layout.buildDirectory.file("libs/${archiveName}-meta.json").get().asFile
File pluginsDir = layout.buildDirectory.dir("plugins").get().asFile

/* Task to Create Plugin Zip and Metadata */
tasks.register('makeZip', Jar) {
into('classes') { with jar }
into('lib') { from configurations.runtimeClasspath }
Expand All @@ -94,56 +105,56 @@ subprojects {
preserveFileTimestamps = false
reproducibleFileOrder = true

String downloadUrl = "https://github.com/${github_organization}/${project.name}/releases/download/${pluginVersion}/${archiveName}.zip"
doLast {
// create the meta file
final zip = new File("$buildDir/libs/${project.name}-${project.version}.zip")
final json = new File("$buildDir/libs/${project.name}-${project.version}-meta.json")
json.text = """\
// Generate the metadata file
jsonFile.text = """\
{
"version": "${project.version}",
"date": "${timestamp}",
"url": "https://github.com/${github_organization}/${project.name}/releases/download/${project.version}/${project.name}-${project.version}.zip",
"requires": "${metaFromManifest('Plugin-Requires', file('src/resources/META-INF/MANIFEST.MF'))}",
"sha512sum": "${computeSha512(zip)}"
"version": "${pluginVersion}",
"date": "${timestamp}",
"url": "${downloadUrl}",
"requires": "${metaFromManifest('Plugin-Requires', file('src/resources/META-INF/MANIFEST.MF'))}",
"sha512sum": "${computeSha512(zipFile)}"
}
"""
}
outputs.file("$buildDir/libs/${project.name}-${project.version}.zip")
outputs.file(zipFile)
}

/*
* Copy the plugin dependencies in the subproject `build/target/libs` directory
*/
/* Task to Copy Plugin Dependencies */
tasks.register('copyPluginLibs', Sync) {
from configurations.runtimeClasspath
into 'build/target/libs'
duplicatesStrategy = 'exclude'
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}

/*
* Copy the plugin in the project root build/plugins directory
*/
/* Task to Copy Plugin ZIP to Plugins Directory */
tasks.register('copyPluginZip', Copy) {
dependsOn project.tasks.findByName('makeZip')
from makeZip
into "$rootProject.buildDir/plugins"
outputs.file("$rootProject.buildDir/plugins/${project.name}-${project.version}.zip")
dependsOn project.tasks.named('makeZip')
from { tasks.named('makeZip').get().outputs.files.singleFile }
into pluginsDir.absolutePath
outputs.file(zipFile)

def destDirPath = new File(pluginsDir, archiveName).absolutePath
doLast {
if (!zipFile.exists()) {
throw new GradleException("File ${zipFile} does not exist! Cannot unzip.")
}
ant.unzip(
src: "$rootProject.buildDir/plugins/${project.name}-${project.version}.zip",
dest: "$rootProject.buildDir/plugins/${project.name}-${project.version}"
src: zipFile.absolutePath,
dest: destDirPath
)
}
}

/*
* "install" the plugin the project root build/plugins directory
*/
project.parent.tasks.getByName('assemble').dependsOn << copyPluginZip

task uploadPlugin(type: GithubUploader, dependsOn: makeZip) {
assets = providers.provider { ["$buildDir/libs/${project.name }-${project.version }.zip",
"$buildDir/libs/${project.name}-${project.version}-meta.json" ]} as Provider<? extends Iterable<? extends String>>
/* "Install" the Plugin */
def providerList = [zipFile.absolutePath, jsonFile.absolutePath]
project.parent.tasks.named('assemble').configure {
dependsOn(copyPluginZip)
}
tasks.register('uploadPlugin', GithubUploader) {
dependsOn tasks.named('makeZip') // Lazy dependency
assets = providers.provider { providerList } as Provider<? extends Iterable<? extends String>>
release = providers.provider { project.version } as Provider<? extends String>
repo = providers.provider { project.name }
owner = github_organization
Expand All @@ -153,13 +164,14 @@ subprojects {
}
}

tasks.register('upload') { dependsOn[subprojects.uploadPlugin] }
/* Upload Task */
tasks.register('upload') {
dependsOn subprojects.uploadPlugin
}

classes.dependsOn subprojects.copyPluginLibs

/*
* Merge and publish the plugins index file
*/
/* Publish Plugins Index File */
tasks.register('publishIndex', GithubRepositoryPublisher) {
indexUrl = github_index_url
repos = allPlugins()
Expand Down
Loading

0 comments on commit 764840e

Please sign in to comment.