Skip to content

Commit 3310be2

Browse files
committed
New and better build script
1 parent ad5d36b commit 3310be2

File tree

3 files changed

+42
-33
lines changed

3 files changed

+42
-33
lines changed

.github/workflows/build.yml

+41-11
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
name: Build snapshot
1+
name: Build and deploy
22

33
on: [push]
44

55
jobs:
66
build:
7-
87
runs-on: ubuntu-latest
9-
108
strategy:
119
matrix:
1210
java: [ '1.8', '11' ]
@@ -21,17 +19,49 @@ jobs:
2119
- name: Build with Maven
2220
run: mvn -B package --no-transfer-progress --file pom.xml
2321

24-
deploy:
22+
makeversion:
23+
if: github.ref != 'refs/heads/main'
24+
needs: build
2525
runs-on: ubuntu-latest
26-
27-
name: deploy snapshot
26+
name: Create version
27+
outputs:
28+
version: ${{ steps.version.outputs.version }}
29+
steps:
30+
- name: Decide on build version
31+
id: version
32+
run: |
33+
if [[ $GITHUB_REF == *"tags"* ]]; then
34+
TAG=${GITHUB_REF#refs/tags/}
35+
else
36+
TAG=${GITHUB_REF#refs/heads/}-SNAPSHOT
37+
fi
38+
echo ::set-output name=version::${TAG//\//-}
39+
40+
deploy_snapshot:
41+
if: startsWith(github.ref, 'refs/heads/')
42+
needs: makeversion
43+
runs-on: ubuntu-latest
44+
45+
name: Deploy snapshot
2846
steps:
2947
- uses: actions/checkout@v1
30-
- name: Set release version
31-
run: echo ::set-env name=RELEASE_VERSION::$(echo ${GITHUB_REF:11}"-SNAPSHOT")
32-
- name: Build and deploy to Sonatype snapshot
33-
uses: digipost/[email protected]
48+
- uses: digipost/[email protected]
3449
with:
3550
sonatype_secrets: ${{ secrets.sonatype_secrets }}
36-
release_version: ${{ env.RELEASE_VERSION }}
51+
release_version: ${{ needs.makeversion.outputs.version }}
3752
perform_release: false
53+
54+
release:
55+
if: startsWith(github.ref, 'refs/tags/')
56+
runs-on: ubuntu-latest
57+
needs: makeversion
58+
name: Release to Sonatype
59+
steps:
60+
- name: Check out Git repository
61+
uses: actions/checkout@v1
62+
- name: Release to Central Repository
63+
uses: digipost/[email protected]
64+
with:
65+
sonatype_secrets: ${{ secrets.sonatype_secrets }}
66+
release_version: ${{ needs.makeversion.outputs.version }}
67+
perform_release: true

.github/workflows/release.yml

-21
This file was deleted.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Java client library for Digipost User Agreement API
22

33
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/no.digipost/digipost-useragreements-api-client-java/badge.svg)](https://maven-badges.herokuapp.com/maven-central/no.digipost/digipost-useragreements-api-client-java)
4-
![](https://github.com/digipost/digipost-useragreements-api-client-java/workflows/Build%20snapshot/badge.svg)
4+
![](https://github.com/digipost/digipost-useragreements-api-client-java/workflows/Build%20and%20deploy/badge.svg)
55
[![License](https://img.shields.io/badge/license-Apache%202-blue)](https://github.com/digipost/digipost-useragreements-api-client-java/blob/main/LICENCE)
66

77
Online documentation: https://digipost.github.io/digipost-useragreements-api-client-java

0 commit comments

Comments
 (0)