-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (73 loc) · 2.52 KB
/
release.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
# Release the project.
# To trigger, create a tag (not a release) with semantic
# versioning (the tag must start with a v).
#
# git tag -am "Version 0.2" v0.2
# git push && git push --tags
#
# This workflow will automatically:
# - build the project using Maven;
# - create a new draft release;
# - attach the built project to the release.
name: Publish new release
on:
push:
tags:
- 'v*'
env:
JAVA_VERSION: 8
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Java ${{ env.JAVA_VERSION }}
uses: actions/setup-java@v1
with:
java-version: ${{ env.JAVA_VERSION }}
- name: Cache all the things
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Extract project name
id: project-name
uses: actions/github-script@v3
with:
script: return context.repo.repo
result-encoding: string
- name: Build ${{ steps.project-name.outputs.result }}
id: maven-build
run: |
mvn -B clean install
# Maven shade keeps the unshaded JAR under target/original-vvv.jar
# We don't want to put this unshaded JAR in the release because it wouldn't
# work on a server.
JAR_PATH=$(ls ./target/*.jar | grep -vE "^./[^/]+/original-" | tail -n 1)
JAR_NAME=$(basename $JAR_PATH)
echo "::set-output name=jar_path::$JAR_PATH"
echo "::set-output name=jar_name::$JAR_NAME"
env:
GIT_REF_NAME: ${{ github.ref }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create new GitHub Release
id: create-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ steps.project-name.outputs.result }} ${{ github.ref }}
draft: true
prerelease: false
- name: Add ${{ steps.project-name.outputs.result }} JAR to GitHub Release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create-release.outputs.upload_url }}
asset_path: ${{ steps.maven-build.outputs.jar_path }}
asset_name: ${{ steps.maven-build.outputs.jar_name }}
asset_content_type: application/java-archive