forked from bundabrg/GeyserLogin
-
-
Notifications
You must be signed in to change notification settings - Fork 0
151 lines (126 loc) · 4.82 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created
# For more information see: https://github.com/actions/setup-java#apache-maven-with-a-settings-path
name: build
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 16
uses: actions/setup-java@v1
with:
java-version: 16
server-id: bundabrg-repo
settings-path: ${{ github.workspace }} # location for the settings.xml file
server-username: MAVEN_USERNAME # env variable for username in deploy
server-password: MAVEN_TOKEN # env variable for token in deploy
- name: Cache dependencies
uses: actions/cache@v1
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Updating Version for Release
if: startsWith(github.ref,'refs/tags/v')
run: |
# Remove v from front
TAG="${GITHUB_REF##*/}"
MAVEN_VERSION="${TAG/v/}"
# Set Maven Version
mvn -B versions:set -DnewVersion=${MAVEN_VERSION}
# Set Extension Version
sed -i "/version = .*/ s/version = \"[^\"]*\"/version = \"${MAVEN_VERSION}\"/" src/main/java/au/com/grieve/geyserlogin/GeyserLoginExtension.java
- name: Update Version for Developmental Build
if: "!startsWith(github.ref,'refs/tags/v')"
run: |
sed -i "/version = .*/ s/-dev/-b${GITHUB_RUN_NUMBER}/" src/main/java/au/com/grieve/geyserlogin/GeyserLoginExtension.java
- name: Build with Maven
run: |
mkdir -p build/output
mvn -B package --file pom.xml && \
cp target/GeyserLogin-*.jar build/output/
- name: Publish to Maven Repo
if: (github.ref == 'refs/heads/master' || startsWith(github.ref,'refs/tags/v'))
run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml
env:
GITHUB_TOKEN: ${{ github.token }}
MAVEN_USERNAME: github-publisher
MAVEN_TOKEN: ${{ secrets.MAVEN_TOKEN }}
- name: Upload Artifact
uses: actions/upload-artifact@v1
with:
name: binary
path: build/output
documentation:
if: startsWith(github.ref,'refs/tags/v')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v1
with:
python-version: '3.6'
architecture: 'x64'
- name: Cache dependencies
uses: actions/cache@v1
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install -r ./requirements.txt
- run: mkdocs build
- name: Deploy to Github Pages
uses: peaceiris/actions-gh-pages@v3
with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
publish_dir: ./build/docs
- name: Upload Artifact
uses: actions/upload-artifact@v1
with:
name: documentation
path: build/docs
# If a tag is pushed starting with 'v' then we create a new release and attach the binary and documentation
release:
if: startsWith(github.ref,'refs/tags/v')
needs: [build, documentation]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: git fetch --prune --unshallow
- name: Download Binary Artifact
uses: actions/download-artifact@v1
with:
name: binary
path: build/binary
- name: Download Documentation Artifact
uses: actions/download-artifact@v1
with:
name: documentation
path: build/docs
- name: Create Release
# The since last release string will retrieve all commits since the last tag, else if none is found
# it will return from the start of history, then pretty it up to show single line logs for each entry
run: |
set -x
assets=()
for asset in ./build/binary/*.jar; do
assets+=("-a" "$asset")
done
tag_name="${GITHUB_REF##*/}"
hub release create \
"${assets[@]}" \
-F - \
"$tag_name" << EOF
Release $tag_name
[Online Documentation](https://bundabrg.github.io/GeyserLogin)
Since Last Release:
$(git log $(git describe --tags --abbrev=0 HEAD^ 2> /dev/null || git rev-list --max-parents=0 HEAD)..HEAD --graph --pretty=format:'%h %d %s [%an]' | head -n 300)
EOF
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}