Skip to content

Commit 8bcf512

Browse files
committed
init
0 parents  commit 8bcf512

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1961
-0
lines changed

.dockerignore

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
### Gradle template
2+
.gradle
3+
**/build/
4+
!src/**/build/
5+
6+
# Ignore Gradle GUI config
7+
gradle-app.setting
8+
9+
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
10+
!gradle-wrapper.jar
11+
12+
# Avoid ignore Gradle wrappper properties
13+
!gradle-wrapper.properties
14+
15+
# Cache of project
16+
.gradletasknamecache
17+
18+
# Eclipse Gradle plugin generated files
19+
# Eclipse Core
20+
.project
21+
# JDT-specific (Eclipse Java Development Tools)
22+
.classpath
23+

.github/semantic.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Always validate the PR title AND all the commits
2+
titleAndCommits: true
3+
# Require at least one commit to be valid
4+
# this is only relevant when using commitsOnly: true or titleAndCommits: true,
5+
# which validate all commits by default
6+
anyCommit: true
7+
# Allow use of Merge commits (eg on github: "Merge branch 'master' into feature/ride-unicorns")
8+
# this is only relevant when using commitsOnly: true (or titleAndCommits: true)
9+
allowMergeCommits: false
10+
# Allow use of Revert commits (eg on github: "Revert "feat: ride unicorns"")
11+
# this is only relevant when using commitsOnly: true (or titleAndCommits: true)
12+
allowRevertCommits: false

.github/workflows/build.yml

+132
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
name: Build
2+
3+
on: [push, pull_request]
4+
5+
permissions:
6+
contents: write
7+
packages: write
8+
9+
jobs:
10+
backend:
11+
name: Backend
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Setup Java
16+
uses: actions/setup-java@v4
17+
with:
18+
distribution: 'temurin'
19+
java-version: 21
20+
- name: Setup Gradle
21+
uses: gradle/actions/setup-gradle@v3
22+
- name: Build
23+
run: gradle build
24+
- name: Artifact
25+
uses: actions/upload-artifact@v3
26+
with:
27+
name: rm-monitor
28+
path: ./build/libs
29+
30+
release:
31+
name: Release
32+
runs-on: ubuntu-latest
33+
if: github.event_name == 'push'
34+
needs: [ backend ]
35+
outputs:
36+
new_version: ${{ steps.should_push.outputs.new_version }}
37+
steps:
38+
- name: Checkout
39+
uses: actions/checkout@v4
40+
with:
41+
fetch-depth: 0
42+
43+
- name: Set up Node.js
44+
uses: actions/setup-node@v4
45+
with:
46+
node-version: '20'
47+
48+
- name: Fetch Previous version
49+
id: get-previous-tag
50+
uses: actions-ecosystem/[email protected]
51+
52+
- name: mkdir
53+
run: |
54+
mkdir dist
55+
56+
- name: Download Artifact
57+
uses: actions/download-artifact@v3
58+
with:
59+
name: rm-monitor
60+
path: ./dist
61+
62+
- name: Release
63+
env:
64+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
65+
run: yarn global add semantic-release @semantic-release/changelog && semantic-release
66+
67+
- name: Fetch Current version
68+
id: get-current-tag
69+
uses: actions-ecosystem/[email protected]
70+
71+
- name: Output New Version
72+
id: should_push
73+
run: |
74+
old_version=${{steps.get-previous-tag.outputs.tag}}
75+
new_version=${{steps.get-current-tag.outputs.tag }}
76+
77+
if [ "$old_version" != "$new_version" ]; then
78+
echo "new_version=$new_version" >> $GITHUB_OUTPUT
79+
else
80+
echo "new_version=" >> $GITHUB_OUTPUT
81+
fi
82+
83+
docker:
84+
runs-on: ubuntu-latest
85+
needs: [ release ]
86+
if: github.event_name == 'push' && needs.release.outputs.new_version != ''
87+
steps:
88+
- name: Checkout
89+
uses: actions/checkout@v4
90+
91+
- name: Set up Docker Buildx
92+
uses: docker/setup-buildx-action@v3
93+
94+
- name: Login to Docker Hub
95+
if: github.event_name != 'pull_request'
96+
uses: docker/login-action@v3
97+
with:
98+
username: ${{ secrets.DOCKERHUB_USERNAME }}
99+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
100+
101+
- name: Login to GHCR
102+
if: github.event_name != 'pull_request'
103+
uses: docker/login-action@v3
104+
with:
105+
registry: ghcr.io
106+
username: ${{ github.repository_owner }}
107+
password: ${{ secrets.GITHUB_TOKEN }}
108+
109+
- name: Docker Push
110+
uses: docker/build-push-action@v5
111+
if: github.event_name == 'push'
112+
with:
113+
context: .
114+
push: true
115+
platforms: linux/amd64
116+
tags: |
117+
scutrobot/rm-monitor:latest
118+
scutrobot/rm-monitor:${{ needs.release.outputs.new_version }}
119+
ghcr.io/scutrobotlab/rm-monitor:latest
120+
ghcr.io/scutrobotlab/rm-monitor:${{ needs.release.outputs.new_version }}
121+
build-args: |
122+
VERSION=${{ needs.release.outputs.new_version }}
123+
labels: |
124+
org.opencontainers.image.source=https://github.com/scutrobot/rm-monitor
125+
org.opencontainers.image.revision=${{ github.sha }}
126+
org.opencontainers.image.created=${{ github.event.head_commit.timestamp }}
127+
org.opencontainers.image.version=${{ needs.release.outputs.new_version }}
128+
org.opencontainers.image.title=rm-monitor ${{ needs.release.outputs.new_version }}
129+
org.opencontainers.image.description="robomaster monitor"
130+
org.opencontainers.image.licenses=AGPL-3.0
131+
cache-from: type=gha
132+
cache-to: type=gha,mode=max

.gitignore

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
HELP.md
2+
.gradle
3+
build/
4+
!gradle/wrapper/gradle-wrapper.jar
5+
!**/src/main/**/build/
6+
!**/src/test/**/build/
7+
8+
### STS ###
9+
.apt_generated
10+
.classpath
11+
.factorypath
12+
.project
13+
.settings
14+
.springBeans
15+
.sts4-cache
16+
bin/
17+
!**/src/main/**/bin/
18+
!**/src/test/**/bin/
19+
20+
### IntelliJ IDEA ###
21+
.idea
22+
*.iws
23+
*.iml
24+
*.ipr
25+
out/
26+
!**/src/main/**/out/
27+
!**/src/test/**/out/
28+
29+
### NetBeans ###
30+
/nbproject/private/
31+
/nbbuild/
32+
/dist/
33+
/nbdist/
34+
/.nb-gradle/
35+
36+
### VS Code ###
37+
.vscode/
38+
39+
gradlew
40+
gradle
41+
gradlew.bat
42+
build
43+
src/main/resources/application.yml

.releaserc.json

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"debug": true,
3+
"branches": [
4+
"+([0-9])?(.{+([0-9]),x}).x",
5+
"master",
6+
"next",
7+
"next-major",
8+
{
9+
"name": "beta",
10+
"prerelease": true
11+
},
12+
{
13+
"name": "alpha",
14+
"prerelease": true
15+
}
16+
],
17+
"plugins": [
18+
"@semantic-release/commit-analyzer",
19+
"@semantic-release/release-notes-generator",
20+
"@semantic-release/changelog",
21+
["@semantic-release/github", {
22+
"assets": [
23+
{"path": "dist/app.jar", "name": "rm-monitor-${nextRelease.version}.jar"}
24+
]
25+
}]
26+
]
27+
}

Dockerfile

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM gradle:8.6.0-jdk21-alpine as build
2+
WORKDIR /app
3+
COPY . .
4+
RUN gradle build
5+
WORKDIR /app/build/libs
6+
RUN java -Djarmode=layertools -jar app.jar extract
7+
8+
FROM amazoncorretto:21-alpine
9+
ENV TZ=Asia/Shanghai
10+
WORKDIR /app
11+
COPY --from=build /app/build/libs/dependencies/ ./
12+
COPY --from=build /app/build/libs/spring-boot-loader/ ./
13+
COPY --from=build /app/build/libs/snapshot-dependencies/ ./
14+
COPY --from=build /app/build/libs/application/ ./
15+
16+
ENTRYPOINT ["java", "org.springframework.boot.loader.launch.JarLauncher"]

README.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# RoboMaster 赛事监控系统
2+
3+
## Features
4+
- 监控RoboMaster赛事事件
5+
- 向飞书发送卡片推送
6+
- 发送Webhook
7+
8+
## Usage
9+
### 使用Docker
10+
11+
12+
13+
## 优秀用例

build.gradle

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
2+
3+
plugins {
4+
id 'org.springframework.boot' version '3.2.5'
5+
id 'io.spring.dependency-management' version '1.1.4'
6+
id 'org.jetbrains.kotlin.jvm' version '1.9.23'
7+
id 'org.jetbrains.kotlin.plugin.spring' version '1.9.23'
8+
}
9+
10+
group = 'cn.scutbot'
11+
version = System.getenv('VERSION') ?: '0.0.1-SNAPSHOT'
12+
13+
java {
14+
sourceCompatibility = '21'
15+
}
16+
17+
configurations {
18+
compileOnly {
19+
extendsFrom annotationProcessor
20+
}
21+
}
22+
23+
repositories {
24+
mavenCentral()
25+
maven {
26+
name = 'central'
27+
url('https://repo1.maven.org/maven2/')
28+
}
29+
}
30+
31+
dependencies {
32+
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
33+
implementation 'org.springframework.boot:spring-boot-starter-web'
34+
implementation 'com.fasterxml.jackson.module:jackson-module-kotlin'
35+
implementation 'org.jetbrains.kotlin:kotlin-reflect'
36+
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
37+
testImplementation 'org.springframework.boot:spring-boot-starter-test'
38+
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
39+
40+
implementation 'com.jayway.jsonpath:json-path:2.8.0'
41+
implementation 'com.larksuite.oapi:oapi-sdk:2.2.6'
42+
}
43+
44+
tasks.withType(KotlinCompile) {
45+
kotlinOptions {
46+
freeCompilerArgs += '-Xjsr305=strict'
47+
jvmTarget = '21'
48+
}
49+
}
50+
51+
tasks.named('test') {
52+
useJUnitPlatform()
53+
}
54+
55+
bootJar {
56+
archiveFileName = 'app.jar'
57+
exclude("**/application.yml")
58+
test {
59+
// enabled = false
60+
}
61+
}

0 commit comments

Comments
 (0)