Skip to content

Commit 84af095

Browse files
committed
github actions
1 parent 8b79def commit 84af095

File tree

4 files changed

+229
-2
lines changed

4 files changed

+229
-2
lines changed

.github/workflows/ci.yml

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
# This file was automatically generated by sbt-github-actions using the
2+
# githubWorkflowGenerate task. You should add and commit this file to
3+
# your git repository. It goes without saying that you shouldn't edit
4+
# this file by hand! Instead, if you wish to make changes, you should
5+
# change your sbt build configuration to revise the workflow description
6+
# to meet your needs, then regenerate this file.
7+
8+
name: Continuous Integration
9+
10+
on:
11+
pull_request:
12+
branches: ['**']
13+
push:
14+
branches: ['**']
15+
tags: [v*]
16+
17+
env:
18+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19+
20+
jobs:
21+
build:
22+
name: Build and Test
23+
strategy:
24+
matrix:
25+
os: [ubuntu-latest]
26+
scala: [2.11.12, 2.12.14, 2.13.6, 3.0.1]
27+
28+
runs-on: ${{ matrix.os }}
29+
steps:
30+
- name: Checkout current branch (full)
31+
uses: actions/checkout@v2
32+
with:
33+
fetch-depth: 0
34+
35+
- name: Setup Java and Scala
36+
uses: olafurpg/setup-scala@v13
37+
with:
38+
java-version: ${{ matrix.java }}
39+
40+
- name: Cache sbt
41+
uses: actions/cache@v2
42+
with:
43+
path: |
44+
~/.sbt
45+
~/.ivy2/cache
46+
~/.coursier/cache/v1
47+
~/.cache/coursier/v1
48+
~/AppData/Local/Coursier/Cache/v1
49+
~/Library/Caches/Coursier/v1
50+
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
51+
52+
- name: Check that workflows are up to date
53+
run: sbt ++${{ matrix.scala }} githubWorkflowCheck
54+
55+
- name: Build project
56+
run: sbt ++${{ matrix.scala }} test
57+
58+
- name: Compress target directories
59+
run: tar cf targets.tar target project/target
60+
61+
- name: Upload target directories
62+
uses: actions/upload-artifact@v2
63+
with:
64+
name: target-${{ matrix.os }}-${{ matrix.scala }}-${{ matrix.java }}
65+
path: targets.tar
66+
67+
publish:
68+
name: Publish Artifacts
69+
needs: [build]
70+
if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/1.5' || startsWith(github.ref, 'refs/tags/v'))
71+
strategy:
72+
matrix:
73+
os: [ubuntu-latest]
74+
scala: [2.13.6]
75+
76+
runs-on: ${{ matrix.os }}
77+
steps:
78+
- name: Checkout current branch (full)
79+
uses: actions/checkout@v2
80+
with:
81+
fetch-depth: 0
82+
83+
- name: Setup Java and Scala
84+
uses: olafurpg/setup-scala@v13
85+
with:
86+
java-version: ${{ matrix.java }}
87+
88+
- name: Cache sbt
89+
uses: actions/cache@v2
90+
with:
91+
path: |
92+
~/.sbt
93+
~/.ivy2/cache
94+
~/.coursier/cache/v1
95+
~/.cache/coursier/v1
96+
~/AppData/Local/Coursier/Cache/v1
97+
~/Library/Caches/Coursier/v1
98+
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
99+
100+
- name: Download target directories (2.11.12)
101+
uses: actions/download-artifact@v2
102+
with:
103+
name: target-${{ matrix.os }}-2.11.12-${{ matrix.java }}
104+
105+
- name: Inflate target directories (2.11.12)
106+
run: |
107+
tar xf targets.tar
108+
rm targets.tar
109+
110+
- name: Download target directories (2.12.14)
111+
uses: actions/download-artifact@v2
112+
with:
113+
name: target-${{ matrix.os }}-2.12.14-${{ matrix.java }}
114+
115+
- name: Inflate target directories (2.12.14)
116+
run: |
117+
tar xf targets.tar
118+
rm targets.tar
119+
120+
- name: Download target directories (2.13.6)
121+
uses: actions/download-artifact@v2
122+
with:
123+
name: target-${{ matrix.os }}-2.13.6-${{ matrix.java }}
124+
125+
- name: Inflate target directories (2.13.6)
126+
run: |
127+
tar xf targets.tar
128+
rm targets.tar
129+
130+
- name: Download target directories (3.0.1)
131+
uses: actions/download-artifact@v2
132+
with:
133+
name: target-${{ matrix.os }}-3.0.1-${{ matrix.java }}
134+
135+
- name: Inflate target directories (3.0.1)
136+
run: |
137+
tar xf targets.tar
138+
rm targets.tar
139+
140+
- env:
141+
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
142+
PGP_SECRET: ${{ secrets.PGP_SECRET }}
143+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
144+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
145+
run: sbt ++${{ matrix.scala }} ci-release

.github/workflows/clean.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# This file was automatically generated by sbt-github-actions using the
2+
# githubWorkflowGenerate task. You should add and commit this file to
3+
# your git repository. It goes without saying that you shouldn't edit
4+
# this file by hand! Instead, if you wish to make changes, you should
5+
# change your sbt build configuration to revise the workflow description
6+
# to meet your needs, then regenerate this file.
7+
8+
name: Clean
9+
10+
on: push
11+
12+
jobs:
13+
delete-artifacts:
14+
name: Delete Artifacts
15+
runs-on: ubuntu-latest
16+
env:
17+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
steps:
19+
- name: Delete artifacts
20+
run: |
21+
# Customize those three lines with your repository and credentials:
22+
REPO=${GITHUB_API_URL}/repos/${{ github.repository }}
23+
24+
# A shortcut to call GitHub API.
25+
ghapi() { curl --silent --location --user _:$GITHUB_TOKEN "$@"; }
26+
27+
# A temporary file which receives HTTP response headers.
28+
TMPFILE=/tmp/tmp.$$
29+
30+
# An associative array, key: artifact name, value: number of artifacts of that name.
31+
declare -A ARTCOUNT
32+
33+
# Process all artifacts on this repository, loop on returned "pages".
34+
URL=$REPO/actions/artifacts
35+
while [[ -n "$URL" ]]; do
36+
37+
# Get current page, get response headers in a temporary file.
38+
JSON=$(ghapi --dump-header $TMPFILE "$URL")
39+
40+
# Get URL of next page. Will be empty if we are at the last page.
41+
URL=$(grep '^Link:' "$TMPFILE" | tr ',' '\n' | grep 'rel="next"' | head -1 | sed -e 's/.*<//' -e 's/>.*//')
42+
rm -f $TMPFILE
43+
44+
# Number of artifacts on this page:
45+
COUNT=$(( $(jq <<<$JSON -r '.artifacts | length') ))
46+
47+
# Loop on all artifacts on this page.
48+
for ((i=0; $i < $COUNT; i++)); do
49+
50+
# Get name of artifact and count instances of this name.
51+
name=$(jq <<<$JSON -r ".artifacts[$i].name?")
52+
ARTCOUNT[$name]=$(( $(( ${ARTCOUNT[$name]} )) + 1))
53+
54+
id=$(jq <<<$JSON -r ".artifacts[$i].id?")
55+
size=$(( $(jq <<<$JSON -r ".artifacts[$i].size_in_bytes?") ))
56+
printf "Deleting '%s' #%d, %'d bytes\n" $name ${ARTCOUNT[$name]} $size
57+
ghapi -X DELETE $REPO/actions/artifacts/$id
58+
done
59+
done

build.sbt

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import Keys._
55

66
organization := "com.github.swagger-akka-http"
77

8-
scalaVersion := "2.13.6"
8+
ThisBuild / scalaVersion := "2.13.6"
99

10-
crossScalaVersions := Seq("2.11.12", "2.12.14", scalaVersion.value, "3.0.1")
10+
ThisBuild / crossScalaVersions := Seq("2.11.12", "2.12.14", "2.13.6", "3.0.1")
1111

1212
ThisBuild / organizationHomepage := Some(url("https://github.com/swagger-akka-http/swagger-scala-module"))
1313

@@ -100,3 +100,22 @@ pomExtra := {
100100
</developers>
101101
)
102102
}
103+
104+
ThisBuild / githubWorkflowTargetTags ++= Seq("v*")
105+
ThisBuild / githubWorkflowPublishTargetBranches := Seq(
106+
RefPredicate.Equals(Ref.Branch("develop")),
107+
RefPredicate.Equals(Ref.Branch("1.5")),
108+
RefPredicate.StartsWith(Ref.Tag("v"))
109+
)
110+
111+
ThisBuild / githubWorkflowPublish := Seq(
112+
WorkflowStep.Sbt(
113+
List("ci-release"),
114+
env = Map(
115+
"PGP_PASSPHRASE" -> "${{ secrets.PGP_PASSPHRASE }}",
116+
"PGP_SECRET" -> "${{ secrets.PGP_SECRET }}",
117+
"SONATYPE_PASSWORD" -> "${{ secrets.SONATYPE_PASSWORD }}",
118+
"SONATYPE_USERNAME" -> "${{ secrets.SONATYPE_USERNAME }}"
119+
)
120+
)
121+
)

project/plugins.sbt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@ addSbtPlugin("com.github.sbt" % "sbt-release" % "1.1.0")
33
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2")
44

55
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.8.2")
6+
7+
addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.13.0")
8+
9+
addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.7")

0 commit comments

Comments
 (0)