forked from Kage0x3B/KageCore
-
Notifications
You must be signed in to change notification settings - Fork 0
171 lines (146 loc) · 6.88 KB
/
Copy pathCI_CD.yml
File metadata and controls
171 lines (146 loc) · 6.88 KB
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
name: CI/CD
on:
push:
branches:
- master
- develop
jobs:
Deploy:
runs-on: ubuntu-latest
steps:
- uses: deepakputhraya/action-branch-name@master
with:
regex: '([a-z])+\/([a-z])+' # Regex the branch should match. This example enforces grouping
allowed_prefixes: 'feature,bug,fix' # All branches should start with the given prefix
ignore: master,develop # Ignore exactly matching branch names from convention
min_length: 5 # Min length of the branch name
max_length: 100 # Max length of the branch name
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Git Semantic Version
if: ${{ github.ref == 'refs/heads/develop' }}
id: versioning_dev
# You may pin to the exact commit or the version.
# uses: PaulHatch/semantic-version@3d2ea28b25c9a892b07cd24b5675300b701fcef5
uses: PaulHatch/semantic-version@v4.0.3
with:
# The prefix to use to identify tags
tag_prefix: "v"
# A string which, if present in a git commit, indicates that a change represents a major (breaking) change. Wrap with '/' to match using a regular expression.
major_pattern: "BREAKING CHANGE:"
# A string which, if present in a git commit, indicates that a change represents a minor (feature) change. Wrap with '/' to match using a regular expression.
minor_pattern: "feat:"
# Pattern to use when formatting output version
format: "v${major}.${minor}.${patch}-rc${increment}"
search_commit_body: true
- name: Git Semantic Version
if: ${{ github.ref == 'refs/heads/master' }}
id: versioning_prod
# You may pin to the exact commit or the version.
# uses: PaulHatch/semantic-version@3d2ea28b25c9a892b07cd24b5675300b701fcef5
uses: PaulHatch/semantic-version@v4.0.3
with:
# The prefix to use to identify tags
tag_prefix: "v"
# A string which, if present in a git commit, indicates that a change represents a major (breaking) change. Wrap with '/' to match using a regular expression.
major_pattern: "BREAKING CHANGE:"
# A string which, if present in a git commit, indicates that a change represents a minor (feature) change. Wrap with '/' to match using a regular expression.
minor_pattern: "feat:"
# Pattern to use when formatting output version
format: "v${major}.${minor}.${patch}"
search_commit_body: true
- name: Configuration for master branch
if: ${{ github.ref == 'refs/heads/master' }}
# Side note, I can run any Linux command here, not just 'echo'
run: |
echo "VERSION=1.0.0-SNAPSHOT" >> $GITHUB_ENV
echo "SSH_HOST=${{ secrets.PROD_SSH_HOST }}" >> $GITHUB_ENV
echo "SSH_USER=${{ secrets.PROD_SSH_USER }}" >> $GITHUB_ENV
echo "PRERELEASE=false" >> $GITHUB_ENV
echo "DISCORD=production" >> $GITHUB_ENV
echo "CHANGELOG_CONFIG=workflow_configs/changelog_configuration_prod.json" >> $GITHUB_ENV
- name: Configuration for develop branch
if: ${{ github.ref == 'refs/heads/develop' }}
run: |
echo "VERSION=1.0.0-SNAPSHOT" >> $GITHUB_ENV
echo "SSH_HOST=${{ secrets.DEV_SSH_HOST }}" >> $GITHUB_ENV
echo "SSH_USER=${{ secrets.DEV_SSH_USER }}" >> $GITHUB_ENV
echo "PRERELEASE=true" >> $GITHUB_ENV
echo "DISCORD=development" >> $GITHUB_ENV
echo "CHANGELOG_CONFIG=workflow_configs/changelog_configuration_prod.json" >> $GITHUB_ENV
- name: Make gradlew executeable
run: chmod +x gradlew
- name: Set up JDK 14
uses: actions/setup-java@v2
with:
java-version: '14'
distribution: 'adopt-hotspot'
- name: Jar
uses: gradle/gradle-build-action@v2
with:
arguments: jar -PprojVersion=${{ env.VERSION }}
- name: Test
uses: gradle/gradle-build-action@v2
with:
arguments: test
- name: Install SSH Key
if: ${{ github.ref == 'refs/heads/master' }}
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.PROD_SSH_PRIVATE_KEY }}
known_hosts: 'just-a-placeholder-so-we-dont-get-errors'
- name: Install SSH Key
if: ${{ github.ref == 'refs/heads/develop' }}
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.DEV_SSH_PRIVATE_KEY }}
known_hosts: 'just-a-placeholder-so-we-dont-get-errors'
- name: Adding Known Hosts
run: ssh-keyscan -H ${{ env.SSH_HOST }} >> ~/.ssh/known_hosts
- name: Rsync new version of files
run: rsync build/libs/KageCore*.jar ${{ env.SSH_USER }}:~/KageCoreUpdates/
- name: SSH into dev and Update plugins
run: ssh ${{ env.SSH_USER }} < scripts/updateKageCore
- name: Nexus Repo Publish Core
uses: sonatype-nexus-community/nexus-repo-github-action@master
with:
serverUrl: https://repo.syscy.de/
username: syscy-githubAction-ci
password: ${{ secrets.NEXUS_PASSWORD }}
format: maven2
repository: maven-snapshots
coordinates: groupId=de.syscy artifactId=kagecore version=${{ env.VERSION }}
assets: extension=jar
filename: build/libs/KageCore-${{ env.VERSION }}.jar
- name: "Build Changelog"
id: build_changelog
uses: mikepenz/release-changelog-builder-action@v2.9.0
with:
configuration: ${{ env.CHANGELOG_CONFIG }}
# Defines the owner of the repository to create the changelog for
owner: RaidRun
# Defines the token to use to execute the git API requests with, uses `env.GITHUB_TOKEN` by default
token: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release
# You may pin to the exact commit or the version.
# uses: ncipollo/release-action@40bb172bd05f266cf9ba4ff965cb61e9ee5f6d01
uses: ncipollo/release-action@v1.9.0
with:
# An optional name for the release. If this is omitted the tag will be used.
name: ${{ env.VERSION }}
prerelease: ${{env.PRERELEASE}}
generateReleaseNotes: false
body: ${{steps.build_changelog.outputs.changelog}}
tag: ${{ env.VERSION }}
# The Github token.
token: ${{ secrets.GITHUB_TOKEN }}
artifacts: "build/libs/KageCore-${{ env.VERSION }}.jar"
allowUpdates: true
- name: Discord notification
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/action-discord@master
with:
args: 'The project {{ EVENT_PAYLOAD.repository.full_name }} has been deployed to ${{ env.DISCORD }}.'