Skip to content

Commit 3350890

Browse files
authored
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.
1 parent 57b9102 commit 3350890

File tree

5 files changed

+43
-5
lines changed

5 files changed

+43
-5
lines changed

.github/workflows/bindings-server.main.kts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,19 @@ workflow(
9292
""".trimIndent(),
9393
)
9494

95+
run(
96+
name = "Clean Maven Local to fetch required POMs again",
97+
command = "rm -rf ~/.m2/repository/"
98+
)
99+
100+
run(
101+
name = "Execute the script using bindings but without dependency on library",
102+
command = """
103+
mv .github/workflows/test-served-bindings-depend-on-library.main.do-not-compile.kts .github/workflows/test-served-bindings-depend-on-library.main.kts
104+
.github/workflows/test-served-bindings-depend-on-library.main.kts
105+
""".trimIndent(),
106+
)
107+
95108
run(
96109
name = "Fetch maven-metadata.xml for top-level action - with /binding",
97110
command = "curl --fail http://localhost:8080/binding/actions/checkout/maven-metadata.xml | grep '<version>v4</version>'",

.github/workflows/bindings-server.yaml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,23 @@ jobs:
5353
mv .github/workflows/test-script-consuming-jit-bindings.main.do-not-compile.kts .github/workflows/test-script-consuming-jit-bindings.main.kts
5454
.github/workflows/test-script-consuming-jit-bindings.main.kts
5555
- id: 'step-6'
56+
name: 'Clean Maven Local to fetch required POMs again'
57+
run: 'rm -rf ~/.m2/repository/'
58+
- id: 'step-7'
59+
name: 'Execute the script using bindings but without dependency on library'
60+
run: |-
61+
mv .github/workflows/test-served-bindings-depend-on-library.main.do-not-compile.kts .github/workflows/test-served-bindings-depend-on-library.main.kts
62+
.github/workflows/test-served-bindings-depend-on-library.main.kts
63+
- id: 'step-8'
5664
name: 'Fetch maven-metadata.xml for top-level action - with /binding'
5765
run: 'curl --fail http://localhost:8080/binding/actions/checkout/maven-metadata.xml | grep ''<version>v4</version>'''
58-
- id: 'step-7'
66+
- id: 'step-9'
5967
name: 'Fetch maven-metadata.xml for nested action - with /binding'
6068
run: 'curl --fail http://localhost:8080/binding/actions/cache__save/maven-metadata.xml | grep ''<version>v4</version>'''
61-
- id: 'step-8'
69+
- id: 'step-10'
6270
name: 'Fetch maven-metadata.xml for top-level action'
6371
run: 'curl --fail http://localhost:8080/actions/checkout/maven-metadata.xml | grep ''<version>v4</version>'''
64-
- id: 'step-9'
72+
- id: 'step-11'
6573
name: 'Fetch maven-metadata.xml for nested action'
6674
run: 'curl --fail http://localhost:8080/actions/cache__save/maven-metadata.xml | grep ''<version>v4</version>'''
6775
deploy:
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env kotlin
2+
@file:Repository("https://repo.maven.apache.org/maven2/")
3+
@file:Repository("http://localhost:8080")
4+
@file:DependsOn("actions:checkout:v4")
5+
6+
import io.github.typesafegithub.workflows.actions.actions.Checkout
7+
8+
Checkout()

MAINTENANCE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This file describes various maintenance tasks, relevant for project maintainers
44

55
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.
66

7-
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 <version>`.
7+
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 <version>`.
88
1. Once CI is green for the newly merged commits, create and push an annotated tag:
99
```
1010
COMMIT_TITLE=`git log -1 --pretty=%B`

maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/PomBuilding.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package io.github.typesafegithub.workflows.mavenbinding
22

3+
internal const val LATEST_RELASED_LIBRARY_VERSION = "2.1.0"
4+
35
internal fun buildPomFile(
46
owner: String,
57
name: String,
@@ -20,6 +22,13 @@ internal fun buildPomFile(
2022
<developerConnection>scm:git:ssh://github.com:$owner/$name.git</developerConnection>
2123
<url>https://github.com/$owner/$name.git</url>
2224
</scm>
23-
<dependencies></dependencies>
25+
<dependencies>
26+
<dependency>
27+
<groupId>io.github.typesafegithub</groupId>
28+
<artifactId>github-workflows-kt</artifactId>
29+
<version>$LATEST_RELASED_LIBRARY_VERSION</version>
30+
<scope>compile</scope>
31+
</dependency>
32+
</dependencies>
2433
</project>
2534
""".trimIndent()

0 commit comments

Comments
 (0)