Skip to content

Commit 1b45c60

Browse files
committed
cicd
1 parent 95a4484 commit 1b45c60

File tree

3 files changed

+230
-0
lines changed

3 files changed

+230
-0
lines changed

.github/release-drafter.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
template: |
2+
## What’s Changed
3+
4+
$CHANGES
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
name: Build and Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: "Release version (e.g. 1.3.1)"
8+
required: true
9+
type: string
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
env:
15+
JAVA_VERSION: '8'
16+
NODE_VERSION: '23.2.0'
17+
PNPM_VERSION: '9.13.2'
18+
19+
steps:
20+
- name: Checkout Backend Code
21+
uses: actions/checkout@v3
22+
with:
23+
repository: Java-Chains/chains
24+
token: ${{ secrets.DEPENDENCY_REPO_TOKEN }}
25+
fetch-depth: 0 # Required to fetch all history for tag detection
26+
27+
- name: Set up Temurin JDK ${{ env.JAVA_VERSION }}
28+
uses: actions/setup-java@v4
29+
with:
30+
distribution: 'temurin'
31+
java-version: ${{ env.JAVA_VERSION }}
32+
cache: 'maven'
33+
34+
- name: Set up Maven
35+
uses: stCarolas/setup-maven@v5
36+
with:
37+
maven-version: 3.9.6
38+
39+
- name: Cache Maven dependencies
40+
uses: actions/cache@v3
41+
with:
42+
path: ~/.m2/repository
43+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
44+
restore-keys: |
45+
${{ runner.os }}-maven-
46+
47+
- name: Clone and Install Dev Jars
48+
run: |
49+
git clone https://${{ secrets.DEPENDENCY_REPO_TOKEN }}@github.com/Java-Chains/chains-dev-jars.git chains-dev-jars
50+
cd chains-dev-jars
51+
bash mvn_install.sh
52+
cd ..
53+
54+
- name: Build and Install java-echo-generator
55+
run: |
56+
git clone https://${{ secrets.DEPENDENCY_REPO_TOKEN }}@github.com/Java-Chains/java-echo-generator.git java-echo-generator
57+
cd java-echo-generator
58+
mvn clean install -DskipTests
59+
cd ..
60+
61+
- name: Build and Install java-memshell-generator
62+
run: |
63+
git clone https://${{ secrets.DEPENDENCY_REPO_TOKEN }}@github.com/Java-Chains/java-memshell-generator.git java-memshell-generator
64+
cd java-memshell-generator
65+
mvn clean install -DskipTests
66+
cd ..
67+
68+
# 前端
69+
- name: Set up Node.js ${{ env.NODE_VERSION }}
70+
uses: actions/setup-node@v3
71+
with:
72+
node-version: ${{ env.NODE_VERSION }}
73+
74+
- name: Setup pnpm
75+
uses: pnpm/action-setup@v2
76+
with:
77+
version: ${{ env.PNPM_VERSION }}
78+
79+
- name: Build Frontend
80+
run: |
81+
git clone https://${{ secrets.DEPENDENCY_REPO_TOKEN }}@github.com/Java-chains/java-chains-front.git java-chains-front
82+
cd java-chains-front
83+
pnpm install
84+
pnpm build:prod
85+
cd ..
86+
87+
- name: Copy Frontend Assets to Backend
88+
run: |
89+
mkdir -p web-chains/src/main/resources/static
90+
rm -rf web-chains/src/main/resources/static/*
91+
cp -r java-chains-front/dist/* web-chains/src/main/resources/static/
92+
93+
- name: Build Backend
94+
run: mvn clean package -DskipTests
95+
96+
- name: Create Release Directory
97+
run: mkdir release
98+
99+
- name: Copy Web-Chains JAR to Release
100+
run: cp web-chains-*.jar release/web-chains.jar
101+
102+
- name: Copy Chain-All JAR to Release
103+
run: cp chains-all-*.jar release/chains-all.jar
104+
105+
- name: Upload Release Artifact (for non-tag pushes)
106+
uses: actions/upload-artifact@v4
107+
with:
108+
name: release-${{ inputs.version }}
109+
path: release/
110+
111+
112+
release_draft:
113+
needs: build
114+
permissions: write-all
115+
runs-on: ubuntu-latest
116+
117+
steps:
118+
- name: Download Artifact
119+
uses: actions/download-artifact@v4
120+
with:
121+
name: release-${{ inputs.version }}
122+
path: release/
123+
124+
- name: Create Release
125+
id: create_release
126+
uses: actions/create-release@v1
127+
env:
128+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
129+
with:
130+
tag_name: ${{ inputs.version }}
131+
release_name: Release ${{ inputs.version }}
132+
draft: true
133+
134+
- name: Upload Web-Chains Release Asset
135+
id: upload-web-chains-release-asset
136+
uses: actions/upload-release-asset@v1
137+
env:
138+
GITHUB_TOKEN: ${{ secrets.DEPENDENCY_REPO_TOKEN }}
139+
with:
140+
upload_url: ${{ steps.create_release.outputs.upload_url }}
141+
asset_path: release/web-chains.jar
142+
asset_name: web-chains-${{ inputs.version }}.jar
143+
asset_content_type: application/java-archive
144+
145+
- name: Upload Chains-All Release Asset
146+
id: upload-chains-all-release-asset
147+
uses: actions/upload-release-asset@v1
148+
env:
149+
GITHUB_TOKEN: ${{ secrets.DEPENDENCY_REPO_TOKEN }}
150+
with:
151+
upload_url: ${{ steps.create_release.outputs.upload_url }}
152+
asset_path: release/chains-all.jar
153+
asset_name: chains-all-${{ inputs.version }}.jar
154+
asset_content_type: application/java-archive
155+
156+
- name: Clone chains-config And Create Distribution Archive
157+
run: |
158+
cd release
159+
git clone https://${{ secrets.DEPENDENCY_REPO_TOKEN }}@github.com/Java-Chains/chains-config.git chains-config
160+
tar -czvf web-chains-all.tar.gz web-chains.jar chains-config
161+
cd ..
162+
163+
- name: Upload Release Asset (Tarball)
164+
id: upload-release-asset-tar
165+
uses: actions/upload-release-asset@v1
166+
env:
167+
GITHUB_TOKEN: ${{ secrets.DEPENDENCY_REPO_TOKEN }}
168+
with:
169+
upload_url: ${{ steps.create_release.outputs.upload_url }}
170+
asset_path: release/web-chains-all.tar.gz
171+
asset_name: web-chains-${{ inputs.version }}-all.tar.gz
172+
asset_content_type: application/gzip

.github/workflows/release-docker.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Release to Docker
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: "Release version tag (e.g. 1.3.0)"
8+
required: true
9+
type: string
10+
11+
jobs:
12+
build-and-push:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout This Repository
16+
uses: actions/checkout@v4
17+
18+
- name: Download And Extract Release Artifact
19+
uses: robinraju/release-downloader@v1
20+
with:
21+
token: ${{ secrets.CHAINS_REPOSITORY_TOKEN }}
22+
repository: java-Chains/chains
23+
tag: ${{ inputs.version }}
24+
out-file-path: ./ # 下载到当前目录下
25+
fileName: web-chains-${{ inputs.version }}-all.tar.gz
26+
extract: true # 解压缩
27+
28+
- name: Show Files
29+
run: |
30+
pwd
31+
ls -lah
32+
33+
- name: Set up QEMU
34+
uses: docker/setup-qemu-action@v3
35+
36+
- name: Set up Docker Buildx
37+
uses: docker/setup-buildx-action@v3
38+
39+
- name: Log in to the Docker hub
40+
uses: docker/login-action@v3
41+
with:
42+
username: ${{ secrets.DOCKER_HUB_USERNAME }}
43+
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
44+
45+
- name: Build and push image to Docker Hub
46+
uses: docker/build-push-action@v6
47+
with:
48+
file: Dockerfile
49+
context: .
50+
platforms: linux/amd64,linux/arm64
51+
push: true
52+
tags: |
53+
javachains/webchains:${{ inputs.version }}
54+
javachains/webchains:latest

0 commit comments

Comments
 (0)