Skip to content

Commit dea5593

Browse files
authored
Add workflow for regenerating dist (#182)
1 parent 294d1bc commit dea5593

File tree

2 files changed

+116
-0
lines changed

2 files changed

+116
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/usr/bin/env kotlin
2+
@file:Repository("https://repo1.maven.org/maven2/")
3+
@file:DependsOn("io.github.typesafegithub:github-workflows-kt:1.15.0")
4+
5+
@file:Repository("https://github-workflows-kt-bindings.colman.com.br/binding/")
6+
@file:DependsOn("actions:checkout:v4")
7+
@file:DependsOn("gradle:actions__setup-gradle:v3")
8+
9+
import io.github.typesafegithub.workflows.actions.actions.Checkout
10+
import io.github.typesafegithub.workflows.actions.gradle.ActionsSetupGradle
11+
import io.github.typesafegithub.workflows.domain.RunnerType
12+
import io.github.typesafegithub.workflows.domain.triggers.WorkflowDispatch
13+
import io.github.typesafegithub.workflows.dsl.workflow
14+
import io.github.typesafegithub.workflows.yaml.writeToFile
15+
16+
workflow(
17+
name = "Update dist",
18+
on = listOf(
19+
WorkflowDispatch(),
20+
),
21+
sourceFile = __FILE__.toPath(),
22+
) {
23+
job(
24+
id = "build",
25+
runsOn = RunnerType.UbuntuLatest,
26+
) {
27+
uses(action = Checkout())
28+
uses(action = ActionsSetupGradle())
29+
run(command = "./gradlew build")
30+
31+
run(
32+
name = "Regenerate the contents of dist directory",
33+
command = """
34+
set -euxo pipefail
35+
36+
rm -rf dist
37+
unzip -qq build/distributions/github-actions-typing.zip -d dist
38+
rm -rf dist/github-actions-typing/bin
39+
""".trimIndent()
40+
)
41+
42+
run(
43+
name = "Configure git",
44+
command = """
45+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
46+
git config user.name "github-actions[bot]"
47+
""".trimIndent()
48+
)
49+
50+
run(
51+
name = "Commit changes",
52+
command = """
53+
git add .
54+
git commit -m "Update dist"
55+
""".trimIndent()
56+
)
57+
58+
run(
59+
name = "Push commit",
60+
command = "git push",
61+
)
62+
}
63+
}.writeToFile()

.github/workflows/update-dist.yaml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# This file was generated using Kotlin DSL (.github/workflows/update-dist.main.kts).
2+
# If you want to modify the workflow, please change the Kotlin file and regenerate this YAML file.
3+
# Generated with https://github.com/typesafegithub/github-workflows-kt
4+
5+
name: 'Update dist'
6+
on:
7+
workflow_dispatch: {}
8+
jobs:
9+
check_yaml_consistency:
10+
name: 'Check YAML consistency'
11+
runs-on: 'ubuntu-latest'
12+
steps:
13+
- id: 'step-0'
14+
name: 'Check out'
15+
uses: 'actions/checkout@v4'
16+
- id: 'step-1'
17+
name: 'Execute script'
18+
run: 'rm ''.github/workflows/update-dist.yaml'' && ''.github/workflows/update-dist.main.kts'''
19+
- id: 'step-2'
20+
name: 'Consistency check'
21+
run: 'git diff --exit-code ''.github/workflows/update-dist.yaml'''
22+
build:
23+
runs-on: 'ubuntu-latest'
24+
needs:
25+
- 'check_yaml_consistency'
26+
steps:
27+
- id: 'step-0'
28+
uses: 'actions/checkout@v4'
29+
- id: 'step-1'
30+
uses: 'gradle/actions/setup-gradle@v3'
31+
- id: 'step-2'
32+
run: './gradlew build'
33+
- id: 'step-3'
34+
name: 'Regenerate the contents of dist directory'
35+
run: |-
36+
set -euxo pipefail
37+
38+
rm -rf dist
39+
unzip -qq build/distributions/github-actions-typing.zip -d dist
40+
rm -rf dist/github-actions-typing/bin
41+
- id: 'step-4'
42+
name: 'Configure git'
43+
run: |-
44+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
45+
git config user.name "github-actions[bot]"
46+
- id: 'step-5'
47+
name: 'Commit changes'
48+
run: |-
49+
git add .
50+
git commit -m "Update dist"
51+
- id: 'step-6'
52+
name: 'Push commit'
53+
run: 'git push'

0 commit comments

Comments
 (0)