-
Notifications
You must be signed in to change notification settings - Fork 1
104 lines (90 loc) · 3.77 KB
/
create-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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
name: Create Release
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v2
with:
ref: 'main'
fetch-depth: '0'
- name: Get short commit hash
id: hash
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
- name: Get the semver
id: semver
run: echo -n "::set-output name=semver::" && grep "version = " build.gradle | cut -d "'" -f 2
- name: Check if semver changed
id: semver_change
run: git --no-pager log -G "version =" --pretty=format:"%h" ./build.gradle | grep `git rev-parse --short HEAD` &>/dev/null && echo "::set-output name=changed::true" || echo "::set-output name=changed::false"
- name: Log if semver changed
id: semver_change_test
run: git --no-pager log -G "version =" --pretty=format:"%h" ./build.gradle | grep `git rev-parse --short HEAD` &>/dev/null && echo "changed" || echo "not changed"
- name: Set up JDK 11
uses: actions/setup-java@v1
if: steps.semver_change.outputs.changed == 'true'
with:
java-version: 11
- name: Cache Gradle packages
uses: actions/cache@v2
if: steps.semver_change.outputs.changed == 'true'
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Build RPM
if: steps.semver_change.outputs.changed == 'true'
run: ./gradlew polaris-application:buildRpm
- name: Build JAR
if: steps.semver_change.outputs.changed == 'true'
run: ./gradlew polaris-application:shadowJar
- name: Create Sentry release
if: steps.semver_change.outputs.changed == 'true'
uses: getsentry/action-release@v1
with:
version: ${{ steps.semver.outputs.semver }}
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
- name: Create Release
if: steps.semver_change.outputs.changed == 'true'
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.semver.outputs.semver }}
release_name: Release ${{ steps.semver.outputs.semver }}
body: ${{ github.event.head_commit.message }}
draft: false
prerelease: false
- name: Upload Release Asset - RPM
if: steps.semver_change.outputs.changed == 'true'
id: upload-release-asset-rpm
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./polaris-application/build/distributions/polaris-${{ steps.semver.outputs.semver }}-${{ steps.hash.outputs.sha_short }}.x86_64.rpm
asset_name: polaris-${{ steps.semver.outputs.semver }}-${{ steps.hash.outputs.sha_short }}.x86_64.rpm
asset_content_type: application/octet-stream
- name: Upload Release Asset - JAR
if: steps.semver_change.outputs.changed == 'true'
id: upload-release-asset-jar
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./polaris-application/build/libs/polaris.jar
asset_name: polaris.jar
asset_content_type: application/java-archive