Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/refresh-catalog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Refresh Catalog

on:
workflow_dispatch:

permissions:
contents: write
pull-requests: write

jobs:
refresh-catalog:
name: Refresh central catalog copy
runs-on: ubuntu-latest

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

- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '21'
cache: gradle

- name: Refresh catalog
run: ./gradlew --no-daemon refreshCatalog

- name: Open pull request
uses: peter-evans/create-pull-request@v7
with:
branch: automation/refresh-central-catalog
delete-branch: true
commit-message: Refresh central Gradle version catalog
title: Refresh central Gradle version catalog
body: |
Updates the local Gradle version catalog from NostrGameEngine/libs.catalog.

If the downloaded catalog is identical to the current file, this workflow exits without opening a pull request.
2 changes: 2 additions & 0 deletions .github/workflows/snapshot-maven-central.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Snapshot (Maven Central)

on:
schedule:
- cron: '47 2 * * 0'
push:
workflow_dispatch:

Expand Down
18 changes: 18 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,21 @@ nexusPublishing {
}
}
}

tasks.register('refreshCatalog') {
group = 'build setup'
description = 'Downloads the central NostrGameEngine Gradle version catalog.'

def catalogUrl = providers.gradleProperty('centralCatalogUrl')
.orElse('https://raw.githubusercontent.com/NostrGameEngine/libs.catalog/main/libs.versions.toml')
def outputFile = layout.projectDirectory.file('gradle/libs.versions.toml')

outputs.file(outputFile)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Declaring outputs.file(outputFile) without any corresponding inputs causes Gradle's up-to-date check to skip this task if the gradle/libs.versions.toml file already exists. Since the purpose of this task is to refresh/download the latest catalog, it should always run. Replacing this with outputs.upToDateWhen { false } ensures the task is never skipped as up-to-date.

    outputs.upToDateWhen { false }


doLast {
def target = outputFile.asFile
target.parentFile.mkdirs()
target.text = new URI(catalogUrl.get()).toURL().getText('UTF-8')
println "Refreshed ${target}"
}
}
Loading
Loading