-
Notifications
You must be signed in to change notification settings - Fork 3
81 lines (72 loc) · 2.31 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
75
76
77
78
79
80
81
name: Build protocol
on:
push:
branches: [ master ]
paths-ignore:
- '**.md'
- '**.svg'
pull_request:
branches: [ master ]
paths-ignore:
- '**.md'
- '**.svg'
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
steps:
- uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
cache: gradle
- name: Export Properties
id: properties
shell: bash
run: |
PROPERTIES="$(./gradlew properties --console=plain -q)"
VERSION="$(echo "$PROPERTIES" | grep "^version:" | cut -f2- -d ' ')"
echo "::set-output name=version::$VERSION"
echo "SPP_PROTOCOL_VERSION=$VERSION" >> $GITHUB_ENV
echo "SPP_RELEASE_VERSION=${VERSION/-SNAPSHOT/}" >> $GITHUB_ENV
- name: Build with Gradle
run: ./gradlew build
- name: Remove Old Release Drafts
if: github.ref == 'refs/heads/master'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
curl -H "Authorization: Bearer $GITHUB_TOKEN" https://api.github.com/repos/$GITHUB_REPOSITORY/releases \
| tr '\r\n' ' ' \
| jq '.[] | select(.draft == true) | .id' \
| xargs -I '{}' \
curl -X DELETE -H "Authorization: Bearer $GITHUB_TOKEN" https://api.github.com/repos/$GITHUB_REPOSITORY/releases/{}
- name: Create Release Draft
if: github.ref == 'refs/heads/master'
id: createDraft
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.SPP_RELEASE_VERSION }}
release_name: v${{ env.SPP_RELEASE_VERSION }}
draft: true
- name: Remove Old Snapshot Packages
if: github.ref == 'refs/heads/master'
uses: smartsquaregmbh/[email protected]
with:
keep: 0
version-pattern: "^\\d+\\.\\d+\\.\\d+-SNAPSHOT$"
names: |
plus.sourceplus.protocol
- name: Publish New Snapshot Packages
if: github.ref == 'refs/heads/master'
run: ./gradlew publish
env:
GH_PUBLISH_USERNAME: $GITHUB_ACTOR
GH_PUBLISH_TOKEN: ${{ secrets.GITHUB_TOKEN }}