Skip to content

Commit

Permalink
Merge pull request #5 from SupersonicAds/feature/antontroshin/SON-203…
Browse files Browse the repository at this point in the history
…3/migrateToSonatypeAndGithubActions

Move to Github Actions and Sonatype
  • Loading branch information
Anton Troshin authored Apr 27, 2021
2 parents ea598fc + d8ec5eb commit 45631a8
Show file tree
Hide file tree
Showing 9 changed files with 196 additions and 57 deletions.
114 changes: 114 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# 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: Continuous Integration

on:
pull_request:
branches: ['*']
push:
branches: ['*']
tags: [v*]

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
build:
name: Build and Test
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.12.12]
java: [[email protected]]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Setup Java and Scala
uses: olafurpg/setup-scala@v10
with:
java-version: ${{ matrix.java }}

- name: Cache sbt
uses: actions/cache@v2
with:
path: |
~/.sbt
~/.ivy2/cache
~/.coursier/cache/v1
~/.cache/coursier/v1
~/AppData/Local/Coursier/Cache/v1
~/Library/Caches/Coursier/v1
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

- name: Check that workflows are up to date
run: sbt ++${{ matrix.scala }} githubWorkflowCheck

- run: sbt ++${{ matrix.scala }} test scripted

- name: Compress target directories
run: tar cf targets.tar target project/target

- name: Upload target directories
uses: actions/upload-artifact@v2
with:
name: target-${{ matrix.os }}-${{ matrix.scala }}-${{ matrix.java }}
path: targets.tar

publish:
name: Publish Artifacts
needs: [build]
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v'))
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.12.12]
java: [[email protected]]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Setup Java and Scala
uses: olafurpg/setup-scala@v10
with:
java-version: ${{ matrix.java }}

- name: Cache sbt
uses: actions/cache@v2
with:
path: |
~/.sbt
~/.ivy2/cache
~/.coursier/cache/v1
~/.cache/coursier/v1
~/AppData/Local/Coursier/Cache/v1
~/Library/Caches/Coursier/v1
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

- name: Download target directories (2.12.12)
uses: actions/download-artifact@v2
with:
name: target-${{ matrix.os }}-2.12.12-${{ matrix.java }}

- name: Inflate target directories (2.12.12)
run: |
tar xf targets.tar
rm targets.tar
- env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
PGP_SECRET: ${{ secrets.PGP_SECRET }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
run: sbt ++${{ matrix.scala }} ci-release
59 changes: 59 additions & 0 deletions .github/workflows/clean.yml
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ lib_managed/
src_managed/
project/boot/
project/plugins/project/
.bloop
/.bsp
.metals
metals.sbt

# Scala-IDE specific
.scala_dependencies
Expand Down
35 changes: 0 additions & 35 deletions .travis.yml

This file was deleted.

5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# sonic-dependency-tree

[![Build Status](https://travis-ci.org/SupersonicAds/sonic-dependency-tree.svg?branch=master)](https://travis-ci.org/SupersonicAds/sonic-dependency-tree)
[![Build Status](https://github.com/SupersonicAds/sonic-dependency-tree/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/SupersonicAds/sonic-dependency-tree/actions?query=branch%3Amaster)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.supersonic/sonic-dependency-tree_2.12/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.supersonic/sonic-dependency-tree_2.12)

SBT plugin for retrieving Scala modules and libraries dependencies and outputs it as JSON. As an identifier for current dependencies, we use Git commit.
In addition, there's an option to upload the current commit project's dependencies to Amazon S3.
Expand All @@ -15,8 +16,6 @@ It helps to keep track of module dependencies and library version used in each m
Add the plugin as SBT dependency to your `project/plugins.sbt`

```
resolvers += Resolver.bintrayRepo("ironsonic", "sbt-plugins")
addSbtPlugin("com.supersonic" % "sonic-dependency-tree" % "0.0.2")
```

Expand Down
28 changes: 13 additions & 15 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
enablePlugins(ScriptedPlugin)
enablePlugins(BuildInfoPlugin)

organization := "com.supersonic"
name := "sonic-dependency-tree"
scalacOptions ++= List(
"-encoding", "UTF-8",
Expand All @@ -15,15 +13,7 @@ scalacOptions ++= List(
"-Xlint",
"-Ypartial-unification")

buildInfoKeys := List[BuildInfoKey](
name,
version,
scalaVersion,
sbtVersion,
"gitCommit" -> git.gitHeadCommit.value.getOrElse(""),
"gitDescribedVersion" -> git.gitDescribedVersion.value.getOrElse(""))

buildInfoPackage := organization.value
sonatypeCredentialHost := Sonatype.sonatype01

makePomConfiguration := makePomConfiguration.value.withConfigurations(Configurations.defaultMavenConfigurations)

Expand All @@ -34,15 +24,23 @@ scriptedLaunchOpts += ("-Dplugin.version=" + version.value)
scriptedBufferLog := false

inThisBuild(List(
organization := "com.supersonic",
licenses := List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")),
homepage := Some(url("https://github.com/SupersonicAds/sonic-dependency-tree")),
developers := List(Developer("SupersonicAds", "SupersonicAds", "SupersonicAds", url("https://github.com/SupersonicAds"))),
scmInfo := Some(ScmInfo(url("https://github.com/SupersonicAds/sonic-dependency-tree"), "scm:git:[email protected]:SupersonicAds/sonic-dependency-tree.git")),

pgpPublicRing := file("./travis/local.pubring.asc"),
pgpSecretRing := file("./travis/local.secring.asc"),
releaseEarlyEnableSyncToMaven := false,
releaseEarlyWith := BintrayPublisher))
githubWorkflowPublishTargetBranches := Seq(RefPredicate.StartsWith(Ref.Tag("v"))),
githubWorkflowTargetTags ++= Seq("v*"),
githubWorkflowBuild := Seq(WorkflowStep.Sbt(List("test", "scripted"))),
githubWorkflowPublish := Seq(
WorkflowStep.Sbt(
List("ci-release"),
env = Map(
"PGP_PASSPHRASE" -> "${{ secrets.PGP_PASSPHRASE }}",
"PGP_SECRET" -> "${{ secrets.PGP_SECRET }}",
"SONATYPE_PASSWORD" -> "${{ secrets.SONATYPE_PASSWORD }}",
"SONATYPE_USERNAME" -> "${{ secrets.SONATYPE_USERNAME }}")))))

libraryDependencies ++= Seq(
"com.typesafe.play" %% "play-json" % "2.8.0",
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version = 1.3.4
sbt.version = 1.4.9
6 changes: 3 additions & 3 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
libraryDependencies += "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value

addSbtPlugin("ch.epfl.scala" % "sbt-release-early" % "2.1.1")

addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "0.9.3")

addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.7.0")
addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.7")

addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.10.1")
Binary file removed travis/secrets.tar.enc
Binary file not shown.

0 comments on commit 45631a8

Please sign in to comment.