Skip to content

Commit 042db40

Browse files
authored
Merge pull request #2 from grouzen/ga-workflows
Add ci, clean, release yamls
2 parents cce3352 + a8913b0 commit 042db40

File tree

3 files changed

+148
-0
lines changed

3 files changed

+148
-0
lines changed

.github/workflows/ci.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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+
16+
env:
17+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
19+
jobs:
20+
build:
21+
name: Build and Test
22+
strategy:
23+
matrix:
24+
os: [ubuntu-latest]
25+
scala: [2.12.18, 2.13.12, 3.3.1]
26+
java: [temurin@8, temurin@11, temurin@17]
27+
runs-on: ${{ matrix.os }}
28+
steps:
29+
- name: Checkout current branch (full)
30+
uses: actions/checkout@v4
31+
with:
32+
fetch-depth: 0
33+
34+
- name: Setup Java (temurin@8)
35+
if: matrix.java == 'temurin@8'
36+
uses: actions/setup-java@v3
37+
with:
38+
distribution: temurin
39+
java-version: 8
40+
cache: sbt
41+
42+
- name: Setup Java (temurin@11)
43+
if: matrix.java == 'temurin@11'
44+
uses: actions/setup-java@v3
45+
with:
46+
distribution: temurin
47+
java-version: 11
48+
cache: sbt
49+
50+
- name: Setup Java (temurin@17)
51+
if: matrix.java == 'temurin@17'
52+
uses: actions/setup-java@v3
53+
with:
54+
distribution: temurin
55+
java-version: 17
56+
cache: sbt
57+
58+
- name: Lint Scala code
59+
run: sbt '++ ${{ matrix.scala }}' 'scalafix --check' scalafmtCheckAll
60+
61+
- name: Check that workflows are up to date
62+
run: sbt '++ ${{ matrix.scala }}' githubWorkflowCheck
63+
64+
- name: Build project
65+
run: sbt '++ ${{ matrix.scala }}' test

.github/workflows/clean.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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+
shell: bash {0}
21+
run: |
22+
# Customize those three lines with your repository and credentials:
23+
REPO=${GITHUB_API_URL}/repos/${{ github.repository }}
24+
25+
# A shortcut to call GitHub API.
26+
ghapi() { curl --silent --location --user _:$GITHUB_TOKEN "$@"; }
27+
28+
# A temporary file which receives HTTP response headers.
29+
TMPFILE=$(mktemp)
30+
31+
# An associative array, key: artifact name, value: number of artifacts of that name.
32+
declare -A ARTCOUNT
33+
34+
# Process all artifacts on this repository, loop on returned "pages".
35+
URL=$REPO/actions/artifacts
36+
while [[ -n "$URL" ]]; do
37+
38+
# Get current page, get response headers in a temporary file.
39+
JSON=$(ghapi --dump-header $TMPFILE "$URL")
40+
41+
# Get URL of next page. Will be empty if we are at the last page.
42+
URL=$(grep '^Link:' "$TMPFILE" | tr ',' '\n' | grep 'rel="next"' | head -1 | sed -e 's/.*<//' -e 's/>.*//')
43+
rm -f $TMPFILE
44+
45+
# Number of artifacts on this page:
46+
COUNT=$(( $(jq <<<$JSON -r '.artifacts | length') ))
47+
48+
# Loop on all artifacts on this page.
49+
for ((i=0; $i < $COUNT; i++)); do
50+
51+
# Get name of artifact and count instances of this name.
52+
name=$(jq <<<$JSON -r ".artifacts[$i].name?")
53+
ARTCOUNT[$name]=$(( $(( ${ARTCOUNT[$name]} )) + 1))
54+
55+
id=$(jq <<<$JSON -r ".artifacts[$i].id?")
56+
size=$(( $(jq <<<$JSON -r ".artifacts[$i].size_in_bytes?") ))
57+
printf "Deleting '%s' #%d, %'d bytes\n" $name ${ARTCOUNT[$name]} $size
58+
ghapi -X DELETE $REPO/actions/artifacts/$id
59+
done
60+
done

.github/workflows/release.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Release
2+
on:
3+
push:
4+
branches: [master, main]
5+
tags: ["*"]
6+
jobs:
7+
publish:
8+
runs-on: ubuntu-20.04
9+
steps:
10+
- uses: actions/checkout@v4
11+
with:
12+
fetch-depth: 0
13+
- uses: actions/setup-java@v4
14+
with:
15+
distribution: temurin
16+
java-version: 8
17+
cache: sbt
18+
- run: sbt ci-release
19+
env:
20+
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
21+
PGP_SECRET: ${{ secrets.PGP_SECRET }}
22+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
23+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}

0 commit comments

Comments
 (0)