-
-
Notifications
You must be signed in to change notification settings - Fork 0
90 lines (78 loc) · 2.67 KB
/
maven-publish.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
88
89
90
name: Build project and create GitHub Release
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Fetch all history for all tags and branches
- name: Set up JDK 16
uses: actions/setup-java@v2
with:
distribution: adopt
java-version: 16
- name: Set up Maven
uses: stCarolas/setup-maven@v4.2
with:
maven-version: 3.8.1
- name: Get version from pom.xml
id: version
run: echo "VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV
- name: Check if tag exists
id: tag_exists
run: |
if git rev-parse "v${{ env.VERSION }}" >/dev/null 2>&1; then
echo "TAG_EXISTS=true" >> $GITHUB_ENV
else
echo "TAG_EXISTS=false" >> $GITHUB_ENV
fi
- name: Exit if tag exists
if: env.TAG_EXISTS == 'true'
run: echo "Tag v${{ env.VERSION }} already exists. Skipping build and release."
- name: Fetch commit messages
if: env.TAG_EXISTS == 'false'
id: fetch_commits
run: |
git fetch --tags
LAST_TAG=$(git describe --tags --abbrev=0 $(git rev-list --tags --max-count=1))
COMMIT_MESSAGES=$(git log $LAST_TAG..HEAD --pretty=format:"- %s")
echo "COMMIT_MESSAGES<<EOF" >> $GITHUB_ENV
echo "Full Changelog:" >> $GITHUB_ENV
echo "" >> $GITHUB_ENV
echo "$COMMIT_MESSAGES" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Build project
if: env.TAG_EXISTS == 'false'
run: mvn package -B
- name: List files in target directory
if: env.TAG_EXISTS == 'false'
run: ls -al ./target/
- name: Create Release
if: env.TAG_EXISTS == 'false'
id: create_release
uses: actions/create-release@v1
with:
tag_name: v${{ env.VERSION }}
release_name: Release ${{ env.VERSION }}
body: ${{ env.COMMIT_MESSAGES }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
- name: Upload Release Asset
if: env.TAG_EXISTS == 'false'
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./target/UltimateBingo-${{ env.VERSION }}.jar
asset_name: UltimateBingo-${{ env.VERSION }}.jar
asset_content_type: application/java-archive
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}