From 3350890487dfa18c2b51cea8ea4584285bd7404a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Krzemi=C5=84ski?= <3110813+krzema12@users.noreply.github.com> Date: Tue, 18 Jun 2024 10:24:01 +0200 Subject: [PATCH] fix(server): add dependency on library in action binding JAR (#1504) Thanks to this, one doesn't have to explicitly depend on the library if a given script uses only the binding. It saves one `@file:Repository` line from the user's script. --- .github/workflows/bindings-server.main.kts | 13 +++++++++++++ .github/workflows/bindings-server.yaml | 14 +++++++++++--- ...dings-depend-on-library.main.do-not-compile.kts | 8 ++++++++ MAINTENANCE.md | 2 +- .../workflows/mavenbinding/PomBuilding.kt | 11 ++++++++++- 5 files changed, 43 insertions(+), 5 deletions(-) create mode 100755 .github/workflows/test-served-bindings-depend-on-library.main.do-not-compile.kts diff --git a/.github/workflows/bindings-server.main.kts b/.github/workflows/bindings-server.main.kts index 511352c45..6a1cd3950 100755 --- a/.github/workflows/bindings-server.main.kts +++ b/.github/workflows/bindings-server.main.kts @@ -92,6 +92,19 @@ workflow( """.trimIndent(), ) + run( + name = "Clean Maven Local to fetch required POMs again", + command = "rm -rf ~/.m2/repository/" + ) + + run( + name = "Execute the script using bindings but without dependency on library", + command = """ + mv .github/workflows/test-served-bindings-depend-on-library.main.do-not-compile.kts .github/workflows/test-served-bindings-depend-on-library.main.kts + .github/workflows/test-served-bindings-depend-on-library.main.kts + """.trimIndent(), + ) + run( name = "Fetch maven-metadata.xml for top-level action - with /binding", command = "curl --fail http://localhost:8080/binding/actions/checkout/maven-metadata.xml | grep 'v4'", diff --git a/.github/workflows/bindings-server.yaml b/.github/workflows/bindings-server.yaml index 50cf28536..2d76489fc 100644 --- a/.github/workflows/bindings-server.yaml +++ b/.github/workflows/bindings-server.yaml @@ -53,15 +53,23 @@ jobs: mv .github/workflows/test-script-consuming-jit-bindings.main.do-not-compile.kts .github/workflows/test-script-consuming-jit-bindings.main.kts .github/workflows/test-script-consuming-jit-bindings.main.kts - id: 'step-6' + name: 'Clean Maven Local to fetch required POMs again' + run: 'rm -rf ~/.m2/repository/' + - id: 'step-7' + name: 'Execute the script using bindings but without dependency on library' + run: |- + mv .github/workflows/test-served-bindings-depend-on-library.main.do-not-compile.kts .github/workflows/test-served-bindings-depend-on-library.main.kts + .github/workflows/test-served-bindings-depend-on-library.main.kts + - id: 'step-8' name: 'Fetch maven-metadata.xml for top-level action - with /binding' run: 'curl --fail http://localhost:8080/binding/actions/checkout/maven-metadata.xml | grep ''v4''' - - id: 'step-7' + - id: 'step-9' name: 'Fetch maven-metadata.xml for nested action - with /binding' run: 'curl --fail http://localhost:8080/binding/actions/cache__save/maven-metadata.xml | grep ''v4''' - - id: 'step-8' + - id: 'step-10' name: 'Fetch maven-metadata.xml for top-level action' run: 'curl --fail http://localhost:8080/actions/checkout/maven-metadata.xml | grep ''v4''' - - id: 'step-9' + - id: 'step-11' name: 'Fetch maven-metadata.xml for nested action' run: 'curl --fail http://localhost:8080/actions/cache__save/maven-metadata.xml | grep ''v4''' deploy: diff --git a/.github/workflows/test-served-bindings-depend-on-library.main.do-not-compile.kts b/.github/workflows/test-served-bindings-depend-on-library.main.do-not-compile.kts new file mode 100755 index 000000000..4161a79d2 --- /dev/null +++ b/.github/workflows/test-served-bindings-depend-on-library.main.do-not-compile.kts @@ -0,0 +1,8 @@ +#!/usr/bin/env kotlin +@file:Repository("https://repo.maven.apache.org/maven2/") +@file:Repository("http://localhost:8080") +@file:DependsOn("actions:checkout:v4") + +import io.github.typesafegithub.workflows.actions.actions.Checkout + +Checkout() diff --git a/MAINTENANCE.md b/MAINTENANCE.md index ce9eda7b0..f387be847 100644 --- a/MAINTENANCE.md +++ b/MAINTENANCE.md @@ -4,7 +4,7 @@ This file describes various maintenance tasks, relevant for project maintainers It currently happens monthly, around the beginning of each month. We don't need to stick to this cadence strictly, the goal is to publish small frequent updates. -1. Remove `-SNAPSHOT` for version starting from [/github-workflows-kt/build.gradle.kts](https://github.com/typesafegithub/github-workflows-kt/blob/main/github-workflows-kt/build.gradle.kts). By building the whole project with `./gradlew build`, you will learn what other places need to be adjusted. Once done, create a commit using this pattern for commit message: `chore: prepare for releasing version `. +1. Remove `-SNAPSHOT` for version starting from [/github-workflows-kt/build.gradle.kts](https://github.com/typesafegithub/github-workflows-kt/blob/main/github-workflows-kt/build.gradle.kts). By building the whole project with `./gradlew build`, you will learn what other places need to be adjusted. There's one place that needs extra care: in PomBuilding.kt, there's `LATEST_RELASED_LIBRARY_VERSION` - set it to the version you're going to deploy in a minute. Once done, create a commit using this pattern for commit message: `chore: prepare for releasing version `. 1. Once CI is green for the newly merged commits, create and push an annotated tag: ``` COMMIT_TITLE=`git log -1 --pretty=%B` diff --git a/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/PomBuilding.kt b/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/PomBuilding.kt index 2c2fda9f3..f2dbc2dee 100644 --- a/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/PomBuilding.kt +++ b/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/PomBuilding.kt @@ -1,5 +1,7 @@ package io.github.typesafegithub.workflows.mavenbinding +internal const val LATEST_RELASED_LIBRARY_VERSION = "2.1.0" + internal fun buildPomFile( owner: String, name: String, @@ -20,6 +22,13 @@ internal fun buildPomFile( scm:git:ssh://github.com:$owner/$name.git https://github.com/$owner/$name.git - + + + io.github.typesafegithub + github-workflows-kt + $LATEST_RELASED_LIBRARY_VERSION + compile + + """.trimIndent()