File tree 5 files changed +49
-2
lines changed
kotlin/no/nav/bidrag/inntekt/util
test/kotlin/no/nav/bidrag/inntekt/util
5 files changed +49
-2
lines changed Original file line number Diff line number Diff line change 16
16
uses : navikt/bidrag-workflow/.github/workflows/maven_publish.yaml@main
17
17
with :
18
18
version : ${{env.VERSION}}
19
- secrets : inherit
19
+ secrets : inherit
20
+
21
+ commit-version-file :
22
+ name : Commit version
23
+ runs-on : ubuntu-latest
24
+ needs : build-and-release
25
+ permissions :
26
+ contents : write
27
+ steps :
28
+ - uses : actions/checkout@v4
29
+ with :
30
+ fetch-depth : 0
31
+ - name : Commit version
32
+ env :
33
+ versionfile_path : bidrag-inntekt/src/main/resources/versjon.txt
34
+ run : |
35
+ git config user.name "Automatisk versjon comitter"
36
+ git config user.email "[email protected] "
37
+ export GIT_COMMIT_HASH=$(git log -n 1 --pretty=format:'%h')
38
+ export APP_VERSION=(${{env.VERSION}}_$GIT_COMMIT_HASH)
39
+ echo $APP_VERSION > ${{env.versionfile_path}}
40
+ echo ⚙️ Opprettet versjonfil med versjon $APP_VERSION
41
+ git add ${{env.versionfile_path}}
42
+ git commit -m "Oppdater versjonfil til $APP_VERSION"
43
+ git push origin HEAD:main
Original file line number Diff line number Diff line change 19
19
uses : navikt/bidrag-workflow/.github/workflows/maven_release_drafter.yaml@main
20
20
secrets : inherit
21
21
with :
22
- publish : true
22
+ publish : true
Original file line number Diff line number Diff line change
1
+ package no.nav.bidrag.inntekt.util
2
+
3
+ class VersionProvider {
4
+ companion object {
5
+ val APP_VERSJON get() = hentFil(" /versjon.txt" ).readText().trim()
6
+ }
7
+ }
8
+ private fun hentFil (filsti : String ) = VersionProvider ::class .java.getResource(
9
+ filsti,
10
+ ) ? : throw RuntimeException (" Fant ingen fil på sti $filsti " )
Original file line number Diff line number Diff line change
1
+ 2024.01.23.3123213123_ORIGINAL_COMMIT_HASH
Original file line number Diff line number Diff line change
1
+ package no.nav.bidrag.inntekt.util
2
+
3
+ import io.kotest.matchers.shouldBe
4
+ import org.junit.jupiter.api.Test
5
+
6
+ class VersionProviderTest {
7
+
8
+ @Test
9
+ fun `Skal hente versjon fra fil` () {
10
+ VersionProvider .APP_VERSJON shouldBe " 2024.01.23.3123213123_ORIGINAL_COMMIT_HASH"
11
+ }
12
+ }
You can’t perform that action at this time.
0 commit comments