forked from elarib/partial-sbt
-
Notifications
You must be signed in to change notification settings - Fork 1
87 lines (75 loc) · 2.36 KB
/
ci.yml
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
name: CI
on:
push:
branches: ['**', '!update/**', '!pr/**']
jobs:
scalafmt:
runs-on: ubuntu-latest
timeout-minutes: 5
container: scalameta/scalafmt:v3.8.1
steps:
- uses: actions/checkout@v3
- name: Scalafmt check
run: scalafmt -c .scalafmt.conf --check
tests:
name: Run tests
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- name: Setup M2 Credentials
shell: bash
run: |
mkdir ~/.m2 && echo ${{ secrets.M2_CREDENTIALS }} | base64 -d > ~/.m2/.credentials
- uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: '17'
- uses: coursier/cache-action@v6
- name: Run tests
run: |
export NEXUS_DEST=$(echo ${{secrets.NEXUS_DEST}} | base64 -d)
sbt "+Test/compile; +scripted"
publish:
name: Publish
runs-on: ubuntu-latest
timeout-minutes: 10
needs: [scalafmt, tests]
steps:
- uses: actions/checkout@v4
- name: Setup M2 Credentials
shell: bash
run: |
mkdir ~/.m2 && echo ${{ secrets.M2_CREDENTIALS }} | base64 -d > ~/.m2/.credentials
- uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: '17'
- uses: coursier/cache-action@v6
- name: Set the $branch
shell: bash
run: |
branch="$(echo -n ${{ github.event.ref }} | sed 's#refs/heads/##g; s#/#-#g' | tr '[:upper:]' '[:lower:]')"
echo "branch=\"${branch}\"" >> $GITHUB_ENV
- name: Set the $version
shell: bash
run: |
if [[ ${{env.branch}} == "master" ]]; then
version="$(date +'%Y.%m.%d')-${{github.run_number}}"
else
version="$(date +'%Y.%m.%d')-${branch}-${{github.run_number}}"
fi
version=$(echo $version | sed 's/"//g')
echo "version=$version"
echo "version=$version" >> $GITHUB_ENV
- name: Set the version for SBT
shell: bash
run: |
echo "ThisBuild / version := \"${{env.version}}\"" > version.sbt
- name: Publish
run: |
export NEXUS_DEST=$(echo ${{secrets.NEXUS_DEST}} | base64 -d)
sbt --warn "compile; publish"
- name: Label vcs
run: |
git tag $version && git push origin $version