-
-
Notifications
You must be signed in to change notification settings - Fork 44
74 lines (71 loc) · 2.7 KB
/
build.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
name: Build
on:
push:
pull_request_target:
types: [labeled]
jobs:
build:
name: Build and Test
runs-on: ubuntu-latest
#This check is case insensitive
if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')"
outputs:
artifactVersion: ${{ steps.setversion.outputs.version }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: 17
- uses: actions/cache@v1
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Ensure to use tagged version
run: mvn versions:set --file ./pom.xml -DnewVersion=${GITHUB_REF##*/} # use shell parameter expansion to strip of 'refs/tags'
if: startsWith(github.ref, 'refs/tags/')
- name: Output project version
id: setversion
run: |
BUILD_VERSION=$(mvn help:evaluate "-Dexpression=project.version" -q -DforceStdout)
echo "::set-output name=version::${BUILD_VERSION}"
- name: Build and Test
run: mvn -B install
- name: Upload artifact cryptomator-cli-${{ steps.setversion.outputs.version }}.jar
uses: actions/upload-artifact@v2
with:
name: cryptomator-cli-${{ steps.setversion.outputs.version }}.jar
path: target/cryptomator-cli-*.jar
release:
name: Draft a Release on GitHub Releases and uploads the build artifacts to it
runs-on: ubuntu-latest
needs: build
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Download cryptomator-cli.jar
uses: actions/[email protected]
with:
name: cryptomator-cli-${{ needs.build.outputs.artifactVersion }}.jar
path: .
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
body: |
:construction: Work in Progress
draft: true
prerelease: false
- name: Upload cryptomator-cli-${{ needs.build.outputs.artifactVersion }}.jar to GitHub Releases
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: cryptomator-cli-${{ needs.build.outputs.artifactVersion }}.jar
asset_name: cryptomator-cli-${{ needs.build.outputs.artifactVersion }}.jar
asset_content_type: application/jar