-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #62 from armanbilge/topic/gha
Bring in sbt-gh-actions
- Loading branch information
Showing
31 changed files
with
1,568 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.14.2") | ||
addSbtPlugin("io.crashbox" % "sbt-gpg" % "0.2.1") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.14.2") | ||
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.0.1") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
libraryDependencies += "org.yaml" % "snakeyaml" % "1.29" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# This file was automatically generated by sbt-github-actions using the | ||
# githubWorkflowGenerate task. You should add and commit this file to | ||
# your git repository. It goes without saying that you shouldn't edit | ||
# this file by hand! Instead, if you wish to make changes, you should | ||
# change your sbt build configuration to revise the workflow description | ||
# to meet your needs, then regenerate this file. | ||
|
||
name: Clean | ||
|
||
on: push | ||
|
||
jobs: | ||
delete-artifacts: | ||
name: Delete Artifacts | ||
runs-on: ubuntu-latest | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
steps: | ||
- name: Delete artifacts | ||
run: | | ||
# Customize those three lines with your repository and credentials: | ||
REPO=${GITHUB_API_URL}/repos/${{ github.repository }} | ||
# A shortcut to call GitHub API. | ||
ghapi() { curl --silent --location --user _:$GITHUB_TOKEN "$@"; } | ||
# A temporary file which receives HTTP response headers. | ||
TMPFILE=/tmp/tmp.$$ | ||
# An associative array, key: artifact name, value: number of artifacts of that name. | ||
declare -A ARTCOUNT | ||
# Process all artifacts on this repository, loop on returned "pages". | ||
URL=$REPO/actions/artifacts | ||
while [[ -n "$URL" ]]; do | ||
# Get current page, get response headers in a temporary file. | ||
JSON=$(ghapi --dump-header $TMPFILE "$URL") | ||
# Get URL of next page. Will be empty if we are at the last page. | ||
URL=$(grep '^Link:' "$TMPFILE" | tr ',' '\n' | grep 'rel="next"' | head -1 | sed -e 's/.*<//' -e 's/>.*//') | ||
rm -f $TMPFILE | ||
# Number of artifacts on this page: | ||
COUNT=$(( $(jq <<<$JSON -r '.artifacts | length') )) | ||
# Loop on all artifacts on this page. | ||
for ((i=0; $i < $COUNT; i++)); do | ||
# Get name of artifact and count instances of this name. | ||
name=$(jq <<<$JSON -r ".artifacts[$i].name?") | ||
ARTCOUNT[$name]=$(( $(( ${ARTCOUNT[$name]} )) + 1)) | ||
id=$(jq <<<$JSON -r ".artifacts[$i].id?") | ||
size=$(( $(jq <<<$JSON -r ".artifacts[$i].size_in_bytes?") )) | ||
printf "Deleting '%s' #%d, %'d bytes\n" $name ${ARTCOUNT[$name]} $size | ||
ghapi -X DELETE $REPO/actions/artifacts/$id | ||
done | ||
done |
102 changes: 102 additions & 0 deletions
102
github-actions/src/main/scala/org/typelevel/sbt/gha/GenerativeKeys.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/* | ||
* Copyright 2022 Typelevel | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.typelevel.sbt.gha | ||
|
||
import sbt._ | ||
|
||
trait GenerativeKeys { | ||
|
||
lazy val githubWorkflowGenerate = taskKey[Unit]( | ||
"Generates (and overwrites if extant) a ci.yml and clean.yml actions description according to configuration") | ||
lazy val githubWorkflowCheck = taskKey[Unit]( | ||
"Checks to see if the ci.yml and clean.yml files are equivalent to what would be generated and errors if otherwise") | ||
|
||
lazy val githubWorkflowGeneratedCI = settingKey[Seq[WorkflowJob]]( | ||
"The sequence of jobs which will make up the generated ci workflow (ci.yml)") | ||
lazy val githubWorkflowGeneratedUploadSteps = settingKey[Seq[WorkflowStep]]( | ||
"The sequence of steps used to upload intermediate build artifacts for an adjacent job") | ||
lazy val githubWorkflowGeneratedDownloadSteps = settingKey[Seq[WorkflowStep]]( | ||
"The sequence of steps used to download intermediate build artifacts published by an adjacent job") | ||
lazy val githubWorkflowGeneratedCacheSteps = settingKey[Seq[WorkflowStep]]( | ||
"The sequence of steps used to configure caching for ivy, sbt, and coursier") | ||
|
||
lazy val githubWorkflowSbtCommand = | ||
settingKey[String]("The command which invokes sbt (default: sbt)") | ||
lazy val githubWorkflowUseSbtThinClient = settingKey[Boolean]( | ||
"Whether to use sbt's native thin client, default is false since this can cause issues (see https://github.com/sbt/sbt/issues/6468)") | ||
lazy val githubWorkflowIncludeClean = | ||
settingKey[Boolean]("Whether to include the clean.yml file (default: true)") | ||
|
||
lazy val githubWorkflowBuildMatrixFailFast = settingKey[Option[Boolean]]( | ||
"Whether or not to enable the fail-fast strategy (default: None/Enabled)") | ||
lazy val githubWorkflowBuildMatrixAdditions = settingKey[Map[String, List[String]]]( | ||
"A map of additional matrix dimensions for the build job. Each list should be non-empty. (default: {})") | ||
lazy val githubWorkflowBuildMatrixInclusions = | ||
settingKey[Seq[MatrixInclude]]("A list of matrix inclusions (default: [])") | ||
lazy val githubWorkflowBuildMatrixExclusions = | ||
settingKey[Seq[MatrixExclude]]("A list of matrix exclusions (default: [])") | ||
lazy val githubWorkflowBuildRunsOnExtraLabels = settingKey[Seq[String]]( | ||
"A list of additional labels to append to each run of the matrix executions") | ||
|
||
lazy val githubWorkflowBuildPreamble = settingKey[Seq[WorkflowStep]]( | ||
"A list of steps to insert after base setup but before compiling and testing (default: [])") | ||
lazy val githubWorkflowBuildPostamble = settingKey[Seq[WorkflowStep]]( | ||
"A list of steps to insert after comping and testing but before the end of the build job (default: [])") | ||
lazy val githubWorkflowBuild = settingKey[Seq[WorkflowStep]]( | ||
"A sequence of workflow steps which compile and test the project (default: [Sbt(List(\"test\"))])") | ||
|
||
lazy val githubWorkflowPublishPreamble = settingKey[Seq[WorkflowStep]]( | ||
"A list of steps to insert after base setup but before publishing (default: [])") | ||
lazy val githubWorkflowPublishPostamble = settingKey[Seq[WorkflowStep]]( | ||
"A list of steps to insert after publication but before the end of the publish job (default: [])") | ||
lazy val githubWorkflowPublish = settingKey[Seq[WorkflowStep]]( | ||
"A sequence workflow steps which publishes the project (default: [Sbt(List(\"+publish\"))])") | ||
lazy val githubWorkflowPublishTargetBranches = settingKey[Seq[RefPredicate]]( | ||
"A set of branch predicates which will be applied to determine whether the current branch gets a publication stage; if empty, publish will be skipped entirely (default: [== main])") | ||
lazy val githubWorkflowPublishCond = settingKey[Option[String]]( | ||
"A set of conditionals to apply to the publish job to further restrict its run (default: [])") | ||
|
||
lazy val githubWorkflowJavaVersions = settingKey[Seq[JavaSpec]]( | ||
"A list of Java versions to be used for the build job. The publish job will use the *first* of these versions. (default: [temurin@11])") | ||
lazy val githubWorkflowScalaVersions = settingKey[Seq[String]]( | ||
"A list of Scala versions on which to build the project (default: crossScalaVersions.value)") | ||
lazy val githubWorkflowOSes = | ||
settingKey[Seq[String]]("A list of OS names (default: [ubuntu-latest])") | ||
|
||
lazy val githubWorkflowDependencyPatterns = settingKey[Seq[String]]( | ||
"A list of file globes within the project which affect dependency information (default: [**/*.sbt, project/build.properties])") | ||
lazy val githubWorkflowTargetBranches = settingKey[Seq[String]]( | ||
"A list of branch patterns on which to trigger push and PR builds (default: [*])") | ||
lazy val githubWorkflowTargetTags = settingKey[Seq[String]]( | ||
"A list of tag patterns on which to trigger push builds (default: [])") | ||
lazy val githubWorkflowTargetPaths = settingKey[Paths]( | ||
"Paths which will match modified files for `push` and `pull_request` event types to trigger the workflow. May be `Paths.None`, `Paths.Include(patterns)`, or `Paths.Ignore(patterns)`. `Paths.Include` may include negative patterns. Defaults to `Paths.None`.") | ||
lazy val githubWorkflowPREventTypes = settingKey[Seq[PREventType]]( | ||
"A list of pull request event types which will be used to trigger builds (default: [opened, synchronize, reopened])") | ||
|
||
lazy val githubWorkflowArtifactUpload = settingKey[Boolean]( | ||
"Controls whether or not to upload target directories in the event that multiple jobs are running sequentially. Can be set on a per-project basis (default: true)") | ||
lazy val githubWorkflowJobSetup = settingKey[Seq[WorkflowStep]]( | ||
"The automatically-generated checkout, setup, and cache steps which are common to all jobs which touch the build (default: autogenerated)") | ||
|
||
lazy val githubWorkflowEnv = settingKey[Map[String, String]]( | ||
s"A map of static environment variable assignments global to the workflow (default: { GITHUB_TOKEN: $${{ secrets.GITHUB_TOKEN }} })") | ||
lazy val githubWorkflowAddedJobs = settingKey[Seq[WorkflowJob]]( | ||
"A list of additional jobs to add to the CI workflow (default: [])") | ||
} | ||
|
||
object GenerativeKeys extends GenerativeKeys |
Oops, something went wrong.