-
Notifications
You must be signed in to change notification settings - Fork 7
/
ci.sbt
151 lines (148 loc) · 5.68 KB
/
ci.sbt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
import org.typelevel.sbt.gha.Permissions
ThisBuild / githubWorkflowOSes := Seq("ubuntu-latest")
ThisBuild / githubWorkflowJavaVersions := Seq(JavaSpec.graalvm("21"))
val releasePreparation = WorkflowJob(
id = "prepare-release",
name = "👷 Prepare release",
oses = List("ubuntu-latest"),
cond = Some(
"""github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/heads/main'))"""
),
needs = List("build"),
env = Map("DTC_HEADLESS" -> "true"),
permissions = Some(Permissions.Specify.defaultPermissive),
steps = List(
WorkflowStep.CheckoutFull,
WorkflowStep.Run(
name = Some("Get previous tag"),
id = Some("previousTag"),
cond = Some("""startsWith(github.ref, 'refs/tags/v')"""),
commands = List(
"""name=$(git --no-pager tag --sort=creatordate --merged ${{ github.ref_name }} | tail -2 | head -1)""",
"""ref_name="${{ github.ref_name }}"""",
"""prefix="prepare-"""",
"""next_version=${ref_name/#$prefix}""",
"""echo "previousTag=$name"""",
"""echo "previousTag=$name" >> $GITHUB_ENV""",
"""echo "nextTag=$next_version"""",
"""echo "nextTag=$next_version" >> $GITHUB_ENV"""
)
),
WorkflowStep.Use(
name = Some("Update CHANGELOG"),
id = Some("changelog"),
ref = UseRef.Public("requarks", "changelog-action", "v1"),
cond = Some("""startsWith(github.ref, 'refs/tags/v')"""),
params = Map(
"token" -> "${{ github.token }}",
"fromTag" -> "${{ github.ref_name }}",
"toTag" -> "${{ env.previousTag }}",
"writeToFile" -> "true"
)
),
WorkflowStep.Use(
name = Some("Commit CHANGELOG.md"),
ref = UseRef.Public("stefanzweifel", "git-auto-commit-action", "v5"),
cond = Some("""startsWith(github.ref, 'refs/tags/v')"""),
params = Map(
"commit_message" -> "docs: update CHANGELOG.md for ${{ env.nextTag }} [skip ci]",
"branch" -> "main",
"file_pattern" -> "CHANGELOG.md docToolchainConfig.groovy"
)
),
WorkflowStep.Use(
name = Some("Create version tag"),
ref = UseRef.Public("rickstaa", "action-create-tag", "v1"),
cond = Some("""startsWith(github.ref, 'refs/tags/v')"""),
params = Map(
"tag" -> "${{ github.ref_name }}",
"message" -> "Release ${{ github.ref_name }}",
"force_push_tag" -> "true" // force push the tag to move it to HEAD
)
),
WorkflowStep.Use(
name = Some("Create release"),
ref = UseRef.Public("ncipollo", "release-action", "v1.14.0"),
cond = Some("""startsWith(github.ref, 'refs/tags/v')"""),
params = Map(
"allowUpdates" -> "true",
"draft" -> "false",
"makeLatest" -> "true",
"name" -> "${{ github.ref_name }}",
"tag" -> "${{ github.ref_name }}",
"body" -> "${{ steps.changelog.outputs.changes }}",
"token" -> "${{ github.token }}"
)
)
)
)
val websitePublication = WorkflowJob(
id = "website",
name = "🌐 Publish website",
oses = List("ubuntu-latest"),
needs = List("publish"),
env = Map("DTC_HEADLESS" -> "true"),
permissions = Some(Permissions.Specify.defaultPermissive),
steps = List(
WorkflowStep.Checkout,
WorkflowStep.Run(
name = Some("Setup"),
commands = List("chmod +x dtcw")
)
) ++
WorkflowStep.SetupJava(List(JavaSpec.temurin("17"))) ++
List(
WorkflowStep.Run(
name = Some("Install docToolchain"),
commands = List("./dtcw local install doctoolchain")
),
WorkflowStep.Use(
name = Some("Cache sbt"),
ref = UseRef.Public("actions", "cache", "v4"),
params = Map(
"path" ->
""".ivy2
|.sbt""".stripMargin,
"key" -> s"sbt-$${{ hashFiles('build.sbt', 'plugins.sbt') }}",
"restore-keys" -> s"pillars-cache-$${{ hashFiles('build.sbt', 'plugins.sbt') }}"
)
),
WorkflowStep.Run(
name = Some("Get latest version"),
id = Some("version"),
commands = List(
"""PILLARS_VERSION="$(git ls-remote --tags $REPO | awk -F"/" '{print $3}' | grep '^v[0-9]*\.[0-9]*\.[0-9]*' | grep -v '\{\}' | sort --version-sort | tail -n1)"""",
"""echo "latest version is [$PILLARS_VERSION]"""",
"""echo "version=${PILLARS_VERSION#v}" >> "$GITHUB_OUTPUT""""
)
),
WorkflowStep.Run(
name = Some("Generate site"),
commands = List("""./dtcw local generateSite && sbt unidoc"""),
env = Map("PILLARS_VERSION" -> "${{ steps.version.outputs.version }}", "DTC_HEADLESS" -> "true")
),
WorkflowStep.Run(
name = Some("Copy to public"),
commands = List("cp -r target/microsite/output ./public")
),
WorkflowStep.Use(
name = Some("Deploy to GitHub Pages"),
ref = UseRef.Public("peaceiris", "actions-gh-pages", "v4"),
params = Map(
"github_token" -> s"$${{ github.token }}",
"publish_dir" -> "./public",
"cname" -> "pillars.dev",
"enable_jekyll" -> "false"
)
)
)
)
val checkNoUnusedDependency = WorkflowStep.Run(
name = Some("Check no unused dependency"),
commands = List(
"""sbt unusedCompileDependenciesTest"""
)
)
ThisBuild / githubWorkflowBuildPreamble := List(checkNoUnusedDependency)
ThisBuild / githubWorkflowGeneratedCI ++= List(releasePreparation, websitePublication)
ThisBuild / githubWorkflowPublishNeeds := List("prepare-release")