Skip to content

Commit 0bc4fc6

Browse files
authored
Merge pull request #265 from bolo-blog/dev/gakkiyomi
chore: ci
2 parents 9568c32 + 2a1dbb9 commit 0bc4fc6

14 files changed

Lines changed: 545 additions & 230 deletions

File tree

.github/workflows/dev-builder.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# This is a basic workflow to help you get started with Actions
2+
3+
name: Bolo-Build-Amd64
4+
5+
on:
6+
push:
7+
branches: [master]
8+
pull_request:
9+
branches: [master]
10+
# Allows you to run this workflow manually from the Actions tab
11+
workflow_dispatch:
12+
inputs:
13+
logLevel:
14+
description: 'Log level'
15+
required: true
16+
default: 'warning'
17+
tags:
18+
description: 'Test scenario tags'
19+
20+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
21+
jobs:
22+
bolo-buildx:
23+
if: github.event_name == 'push' || (github.event_name == 'pull_request' && startsWith(github.head_ref, 'dev/'))
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v2
28+
- name: Get current date
29+
id: date
30+
run: echo "today=$(date +'%Y%m%d%H%M%S')" >> "$GITHUB_OUTPUT"
31+
32+
- name: Install xmllint
33+
run: sudo apt-get update && sudo apt-get install -y libxml2-utils
34+
35+
- name: Get current version
36+
id: version
37+
run: |
38+
version=$(xmllint --xpath "/*[local-name()='project']/*[local-name()='version']/text()" pom.xml)
39+
IFS='.' read -r major minor patch <<< "$version"
40+
patch=$((patch + 1))
41+
new_version="${major}.${minor}.${patch}"
42+
echo "new_version=$new_version" >> "$GITHUB_OUTPUT"
43+
44+
- name: Prepare tag
45+
id: prep
46+
run: |
47+
DATE=${{ steps.date.outputs.today }}
48+
VERSION=${{ steps.version.outputs.new_version }}
49+
IMAGE="tangcuyu/bolo-solo"
50+
TAG="${VERSION}.dev${DATE}"
51+
echo "image=${IMAGE}" >> "$GITHUB_OUTPUT"
52+
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
53+
54+
- name: Set up QEMU
55+
uses: docker/setup-qemu-action@v1
56+
with:
57+
platforms: all
58+
- name: Set up Docker Buildx
59+
id: buildx
60+
uses: docker/setup-buildx-action@v1
61+
- name: Available platforms
62+
run: echo ${{ steps.buildx.outputs.platforms }}
63+
- name: Cache Docker layers
64+
uses: actions/cache@v3
65+
with:
66+
path: /tmp/.buildx-cache
67+
key: ${{ runner.os }}-buildx-${{ github.sha }}
68+
restore-keys: |
69+
${{ runner.os }}-buildx-
70+
- name: Login to DockerHub
71+
uses: docker/login-action@v1
72+
with:
73+
username: ${{ secrets.DOCKERHUB_USERNAME }}
74+
password: ${{ secrets.DOCKERHUB_TOKEN }}
75+
- name: Build and push
76+
uses: docker/build-push-action@v2
77+
with:
78+
context: .
79+
file: ./Dockerfile
80+
platforms: linux/amd64,linux/arm64/v8
81+
push: true
82+
cache-from: type=local,src=/tmp/.buildx-cache
83+
cache-to: type=local,dest=/tmp/.buildx-cache-new
84+
tags: |
85+
${{ steps.prep.outputs.image }}:${{ steps.prep.outputs.tag }}
86+
87+
- name: Move cache
88+
run: |
89+
rm -rf /tmp/.buildx-cache
90+
mv /tmp/.buildx-cache-new /tmp/.buildx-cache

.github/workflows/docker-image-builder.yml renamed to .github/workflows/release-builder.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
name: Bolo-Build-Amd64
44

55
on:
6-
push:
7-
branches: [master]
8-
pull_request:
9-
branches: [master]
106
release:
117
types:
128
- published
@@ -33,11 +29,8 @@ jobs:
3329
- name: Prepare
3430
id: prep
3531
run: |
36-
TAG=$(echo $GITHUB_REF | cut -d / -f 3)
3732
IMAGE="tangcuyu/bolo-solo"
3833
echo ::set-output name=image::${IMAGE}
39-
echo ::set-output name=tag::${TAG}
40-
echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
4134
- name: Set up QEMU
4235
uses: docker/setup-qemu-action@v1
4336
with:
@@ -65,10 +58,11 @@ jobs:
6558
context: .
6659
file: ./Dockerfile
6760
platforms: linux/amd64,linux/arm64/v8
68-
push: ${{ github.event_name != 'pull_request' }}
61+
push: true
6962
cache-from: type=local,src=/tmp/.buildx-cache
7063
cache-to: type=local,dest=/tmp/.buildx-cache-new
7164
tags: |
65+
${{ steps.prep.outputs.image }}:${{ github.event.release.tag_name }}
7266
${{ steps.prep.outputs.image }}:latest
7367
7468
- name: Move cache

pom.xml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@
1717
<artifactId>bolo</artifactId>
1818
<packaging>war</packaging>
1919
<name>Bolo</name>
20-
<version>v2.6-stable</version>
20+
<version>v2.6.1-stable</version>
2121
<description>
2222
本地化、稳定精致的 Java 博客系统 - 菠萝博客。
2323
</description>
2424
<inceptionYear>2019</inceptionYear>
2525

2626
<organization>
27-
<name>adlered</name>
28-
<url>https://github.com/adlered</url>
27+
<name>bolo-blog</name>
28+
<url>https://github.com/bolo-blog</url>
2929
</organization>
3030

3131
<licenses>
@@ -73,15 +73,24 @@
7373
<role>Commiter</role>
7474
</roles>
7575
</developer>
76+
<developer>
77+
<id>gakkiyomi@gakkiyomi.blog</id>
78+
<name>Gakkiyomi Fang</name>
79+
<email>gakkiyomi@gmail.com</email>
80+
<url>https://gakkiyomi.blog</url>
81+
<roles>
82+
<role>Commiter</role>
83+
</roles>
84+
</developer>
7685
</developers>
7786

7887
<issueManagement>
7988
<system>GitHub Issues</system>
80-
<url>https://github.com/adlered/bolo-solo/issues</url>
89+
<url>https://github.com/bolo-blog/bolo-solo/issues</url>
8190
</issueManagement>
8291

8392
<scm>
84-
<url>https://github.com/adlered/bolo-solo</url>
93+
<url>https://github.com/bolo-blog/bolo-solo</url>
8594
</scm>
8695

8796
<properties>

src/main/java/org/b3log/solo/SoloServletListener.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public final class SoloServletListener extends AbstractServletListener {
104104
public static final String STABLE_EN = "Stable";
105105
public static final String BETA_CN = "内测版";
106106
public static final String BETA_EN = "Beta";
107-
public static final String BOLO_VERSION_SOURCE = "2.6";
107+
public static final String BOLO_VERSION_SOURCE = "2.6.1";
108108
public static final String BOLO_VERSION = "v" + BOLO_VERSION_SOURCE + " " + STABLE_CN;
109109
public static final String BOLO_VERSION_EN = "v" + BOLO_VERSION_SOURCE + " " + STABLE_EN;
110110
// public static final String BOLO_VERSION = "v" + BOLO_VERSION_SOURCE + " " +
@@ -173,7 +173,7 @@ public void contextInitialized(final ServletContextEvent servletContextEvent) {
173173
"█ ██╔══██╗██╔═══██╗██║ ██╔═══██╗ █ Welcome to Bolo :) █\n" +
174174
"█ ██████╔╝██║ ██║██║ ██║ ██║ █ █\n" +
175175
"█ ██╔══██╗██║ ██║██║ ██║ ██║ █ github.com/adlered/bolo-solo █\n" +
176-
"█ ██████╔╝╚██████╔╝███████╗╚██████╔╝ █ Current Version: " + BOLO_VERSION_EN + " \n" +
176+
"█ ██████╔╝╚██████╔╝███████╗╚██████╔╝ █ CurrentVersion: " + BOLO_VERSION_EN + "█\n" +
177177
"█ ╚═════╝ ╚═════╝ ╚══════╝ ╚═════╝ █ █\n" +
178178
"█ █ █\n" +
179179
"████✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩████\n" +

src/main/java/org/b3log/solo/bolo/prop/BackupService.java

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@
1717
*/
1818
package org.b3log.solo.bolo.prop;
1919

20+
import static pers.adlered.blog_platform_export_tool.Launcher.run;
21+
22+
import java.io.File;
23+
import java.nio.charset.StandardCharsets;
24+
import java.util.List;
25+
26+
import javax.servlet.ServletContext;
27+
import javax.servlet.http.HttpServletResponse;
28+
2029
import org.apache.commons.fileupload.FileItem;
2130
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
2231
import org.apache.commons.fileupload.servlet.ServletFileUpload;
@@ -32,24 +41,24 @@
3241
import org.b3log.solo.SoloServletListener;
3342
import org.b3log.solo.bolo.tool.DeleteFolder;
3443
import org.b3log.solo.model.Article;
44+
import org.b3log.solo.model.Option;
3545
import org.b3log.solo.repository.UserRepository;
36-
import org.b3log.solo.service.*;
46+
import org.b3log.solo.service.ArticleMgmtService;
47+
import org.b3log.solo.service.ExportService;
48+
import org.b3log.solo.service.ImportService;
49+
import org.b3log.solo.service.InitService;
50+
import org.b3log.solo.service.OptionQueryService;
3751
import org.b3log.solo.util.Solos;
3852
import org.json.JSONObject;
3953
import org.zeroturnaround.zip.ZipUtil;
40-
import pers.adlered.blog_platform_export_tool.module.TranslateResult;
4154

42-
import javax.servlet.ServletContext;
43-
import javax.servlet.http.HttpServletResponse;
44-
import java.io.File;
45-
import java.nio.charset.StandardCharsets;
46-
import java.util.List;
47-
48-
import static pers.adlered.blog_platform_export_tool.Launcher.run;
55+
import pers.adlered.blog_platform_export_tool.module.TranslateResult;
4956

5057
/**
5158
* <h3>bolo-solo</h3>
52-
* <p>备份服务</p>
59+
* <p>
60+
* 备份服务
61+
* </p>
5362
*
5463
* @author : https://github.com/adlered
5564
* @date : 2020-01-05 13:39
@@ -119,7 +128,7 @@ public void syncGitHubRepos(final RequestContext context) {
119128
}
120129
}
121130

122-
@RequestProcessing(value = "/prop/backup/github/do/upload", method = {HttpMethod.GET})
131+
@RequestProcessing(value = "/prop/backup/github/do/upload", method = { HttpMethod.GET })
123132
public void uploadBackupToGithub(final RequestContext context) {
124133
if (!Solos.isAdminLoggedIn(context)) {
125134
context.sendError(HttpServletResponse.SC_UNAUTHORIZED);
@@ -128,8 +137,15 @@ public void uploadBackupToGithub(final RequestContext context) {
128137
}
129138

130139
try {
131-
exportService.exportGitHub();
132-
140+
boolean enableAutoFlushGitHubProfile;
141+
try {
142+
enableAutoFlushGitHubProfile = optionQueryService
143+
.getOptionById(Option.ID_C_ENABLE_AUTO_FLUSH_BLOG_TO_GITHUB_PROFILE)
144+
.optBoolean(Option.OPTION_VALUE);
145+
} catch (Exception e) {
146+
enableAutoFlushGitHubProfile = false;
147+
}
148+
exportService.exportGitHub(enableAutoFlushGitHubProfile);
133149
context.renderJSON().renderCode(200);
134150
context.renderJSON().renderMsg("Exported backup to GitHub manual successfully.");
135151

@@ -141,7 +157,7 @@ public void uploadBackupToGithub(final RequestContext context) {
141157
}
142158
}
143159

144-
@RequestProcessing(value = "/prop/backup/hacpai/do/upload", method = {HttpMethod.GET})
160+
@RequestProcessing(value = "/prop/backup/hacpai/do/upload", method = { HttpMethod.GET })
145161
public void uploadBackupToHacpai(final RequestContext context) {
146162
if (!Solos.isAdminLoggedIn(context)) {
147163
context.sendError(HttpServletResponse.SC_UNAUTHORIZED);
@@ -163,7 +179,7 @@ public void uploadBackupToHacpai(final RequestContext context) {
163179
}
164180
}
165181

166-
@RequestProcessing(value = "/import/cnblogs", method = {HttpMethod.POST})
182+
@RequestProcessing(value = "/import/cnblogs", method = { HttpMethod.POST })
167183
public void importFromCnblogs(final RequestContext context) {
168184
if (!Solos.isAdminLoggedIn(context)) {
169185
context.sendError(HttpServletResponse.SC_UNAUTHORIZED);
@@ -198,7 +214,8 @@ public void importFromCnblogs(final RequestContext context) {
198214
article.put(Article.ARTICLE_ABSTRACT, "");
199215
article.put(Article.ARTICLE_CONTENT, content);
200216
article.put(Article.ARTICLE_TAGS_REF, "待分类");
201-
final String permalink = "/articles/" + DateFormatUtils.format(i.getDate(), "yyyy/MM/dd") + "/" + article.optString(Keys.OBJECT_ID) + ".html";
217+
final String permalink = "/articles/" + DateFormatUtils.format(i.getDate(), "yyyy/MM/dd") + "/"
218+
+ article.optString(Keys.OBJECT_ID) + ".html";
202219
article.put(Article.ARTICLE_PERMALINK, permalink);
203220
article.put(Article.ARTICLE_STATUS, Article.ARTICLE_STATUS_C_PUBLISHED);
204221
article.put(Article.ARTICLE_SIGN_ID, "1");
@@ -242,7 +259,7 @@ public void importFromCnblogs(final RequestContext context) {
242259
return;
243260
}
244261

245-
@RequestProcessing(value = "/import/markdown", method = {HttpMethod.POST})
262+
@RequestProcessing(value = "/import/markdown", method = { HttpMethod.POST })
246263
public void importFromMarkdown(final RequestContext context) {
247264
if (!Solos.isAdminLoggedIn(context)) {
248265
context.sendError(HttpServletResponse.SC_UNAUTHORIZED);

0 commit comments

Comments
 (0)