Skip to content

Commit

Permalink
fix(server): add dependency on library in action binding JAR (#1504)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
krzema12 committed Jun 18, 2024
1 parent 57b9102 commit 3350890
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 5 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/bindings-server.main.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<version>v4</version>'",
Expand Down
14 changes: 11 additions & 3 deletions .github/workflows/bindings-server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ''<version>v4</version>'''
- 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 ''<version>v4</version>'''
- 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 ''<version>v4</version>'''
- 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 ''<version>v4</version>'''
deploy:
Expand Down
Original file line number Diff line number Diff line change
@@ -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()
2 changes: 1 addition & 1 deletion MAINTENANCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <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 <version>`.
1. Once CI is green for the newly merged commits, create and push an annotated tag:
```
COMMIT_TITLE=`git log -1 --pretty=%B`
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -20,6 +22,13 @@ internal fun buildPomFile(
<developerConnection>scm:git:ssh://github.com:$owner/$name.git</developerConnection>
<url>https://github.com/$owner/$name.git</url>
</scm>
<dependencies></dependencies>
<dependencies>
<dependency>
<groupId>io.github.typesafegithub</groupId>
<artifactId>github-workflows-kt</artifactId>
<version>$LATEST_RELASED_LIBRARY_VERSION</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
""".trimIndent()

0 comments on commit 3350890

Please sign in to comment.