mirror of
https://gitee.com/goploy/goploy.git
synced 2024-11-30 03:07:59 +08:00
A 1.10.0
This commit is contained in:
parent
8ed4a09adc
commit
a9c8c3d929
8
build.sh
8
build.sh
@ -3,11 +3,11 @@
|
||||
echo "Change version number? [Version number/N]";
|
||||
read x
|
||||
|
||||
if [[ $x =~ ^[1-9].[0-9].[0-9]$ ]]
|
||||
if [[ $x =~ ^[1-9].[0-9]+.[0-9]+$ ]]
|
||||
then
|
||||
sed -i -e "s/const appVersion = \"[0-9].[0-9].[0-9]\"/const appVersion = \"$x\"/g" main.go
|
||||
sed -i -e "s/'[0-9].[0-9].[0-9]'/'$x'/g" model/sql/goploy.sql
|
||||
sed -i -e "s/GOPLOY_VER=v[0-9].[0-9].[0-9]/GOPLOY_VER=v$x/g" docker/Dockerfile
|
||||
sed -i -e "s/const appVersion = \"[0-9].[0-9]\+.[0-9]\+\"/const appVersion = \"$x\"/g" main.go
|
||||
sed -i -e "s/'[0-9].[0-9]\+.[0-9]\+'/'$x'/g" model/sql/goploy.sql
|
||||
sed -i -e "s/GOPLOY_VER=v[0-9].[0-9]\+.[0-9]\+/GOPLOY_VER=v$x/g" docker/Dockerfile
|
||||
fi
|
||||
|
||||
echo "Build web? [Y/N]";
|
||||
|
@ -23,7 +23,6 @@ import (
|
||||
"github.com/zhenorzz/goploy/service"
|
||||
"github.com/zhenorzz/goploy/service/cmd"
|
||||
"github.com/zhenorzz/goploy/task"
|
||||
"github.com/zhenorzz/goploy/utils"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
@ -466,13 +465,15 @@ func (Deploy) Rebuild(gp *core.Goploy) core.Response {
|
||||
needToPublish = true
|
||||
}
|
||||
if needToPublish == false {
|
||||
if len(project.AfterDeployScript) != 0 {
|
||||
scriptName := path.Join(core.GetProjectPath(project.ID), "goploy-after-deploy."+utils.GetScriptExt(project.AfterDeployScriptMode))
|
||||
ioutil.WriteFile(scriptName, []byte(service.ReplaceProjectVars(project.AfterDeployScript, project)), 0755)
|
||||
}
|
||||
ch := make(chan bool, len(projectServers))
|
||||
for _, projectServer := range projectServers {
|
||||
go func(projectServer model.ProjectServer) {
|
||||
scriptName := fmt.Sprintf("GAD%d", projectServer.ServerID)
|
||||
if len(project.AfterDeployScript) != 0 {
|
||||
scriptContent := service.ReplaceProjectVars(project.AfterDeployScript, project)
|
||||
scriptContent = service.ReplaceProjectServerVars(scriptContent, projectServer)
|
||||
ioutil.WriteFile(path.Join(core.GetProjectPath(project.ID), scriptName), []byte(service.ReplaceProjectVars(project.AfterDeployScript, project)), 0755)
|
||||
}
|
||||
client, err := projectServer.ToSSHConfig().Dial()
|
||||
if err != nil {
|
||||
core.Log(core.ERROR, "projectID:"+strconv.FormatInt(project.ID, 10)+" dial err: "+err.Error())
|
||||
@ -505,7 +506,7 @@ func (Deploy) Rebuild(gp *core.Goploy) core.Response {
|
||||
afterDeployCommands = append(afterDeployCommands, cmdEntity.Symlink(destDir, project.Path))
|
||||
afterDeployCommands = append(afterDeployCommands, cmdEntity.ChangeDirTime(destDir))
|
||||
if len(project.AfterDeployScript) != 0 {
|
||||
afterDeployScriptPath := path.Join(project.Path, "goploy-after-deploy."+utils.GetScriptExt(project.AfterDeployScriptMode))
|
||||
afterDeployScriptPath := path.Join(project.Path, scriptName)
|
||||
afterDeployCommands = append(afterDeployCommands, cmdEntity.Script(project.AfterDeployScriptMode, afterDeployScriptPath))
|
||||
afterDeployCommands = append(afterDeployCommands, cmdEntity.Remove(afterDeployScriptPath))
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
# Import sql manually https://github.com/zhenorzz/goploy/blob/master/model/sql/goploy.sql
|
||||
FROM alpine
|
||||
LABEL maintainer="zhenorzz@gmail.com"
|
||||
ARG GOPLOY_VER=v1.9.1
|
||||
ARG GOPLOY_VER=v1.10.0
|
||||
ENV GOPLOY_VER=${GOPLOY_VER}
|
||||
|
||||
ENV MYSQL_PORT=3306
|
||||
|
2
main.go
2
main.go
@ -42,7 +42,7 @@ var (
|
||||
s string
|
||||
)
|
||||
|
||||
const appVersion = "1.9.1"
|
||||
const appVersion = "1.10.0"
|
||||
|
||||
func init() {
|
||||
flag.StringVar(&core.AssetDir, "asset-dir", "", "default: ./")
|
||||
|
@ -1,3 +1,17 @@
|
||||
CREATE TABLE IF NOT EXISTS `server_process` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`server_id` int(10) unsigned NOT NULL DEFAULT '0',
|
||||
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`start` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`stop` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`restart` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`insert_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
KEY `idx_server` (`server_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
INSERT IGNORE INTO `permission`(`id`, `pid`, `name`, `sort`, `description`) VALUES (70, 23, 'ShowServerProcessPage', 0, '');
|
||||
INSERT IGNORE INTO `permission`(`id`, `pid`, `name`, `sort`, `description`) VALUES (71, 23, 'AddServerProcess', 0, '');
|
||||
INSERT IGNORE INTO `permission`(`id`, `pid`, `name`, `sort`, `description`) VALUES (72, 23, 'EditServerProcess', 0, '');
|
||||
|
@ -216,6 +216,20 @@ CREATE TABLE IF NOT EXISTS `cron` (
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `server_process` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`server_id` int(10) unsigned NOT NULL DEFAULT '0',
|
||||
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`start` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`stop` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`restart` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`insert_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
KEY `idx_server` (`server_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `cron_log` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`cron_id` int(10) unsigned NOT NULL DEFAULT '0',
|
||||
@ -348,7 +362,7 @@ CREATE TABLE IF NOT EXISTS `terminal_log` (
|
||||
INSERT IGNORE INTO `user`(`id`, `account`, `password`, `name`, `contact`, `state`, `super_manager`) VALUES (1, 'admin', '$2a$10$89ZJ2xeJj35GOw11Qiucr.phaEZP4.kBX6aKTs7oWFp1xcGBBgijm', '超管', '', 1, 1);
|
||||
INSERT IGNORE INTO `namespace`(`id`, `name`) VALUES (1, 'goploy');
|
||||
INSERT IGNORE INTO `namespace_user`(`id`, `namespace_id`, `user_id`, `role_id`) VALUES (1, 1, 1, 0);
|
||||
INSERT IGNORE INTO `system_config` (`id`, `key`, `value`) VALUES (1, 'version', '1.9.1');
|
||||
INSERT IGNORE INTO `system_config` (`id`, `key`, `value`) VALUES (1, 'version', '1.10.0');
|
||||
INSERT IGNORE INTO `role`(`id`, `name`, `description`) VALUES (1, 'manager', '');
|
||||
INSERT IGNORE INTO `role`(`id`, `name`, `description`) VALUES (2, 'member', '');
|
||||
INSERT IGNORE INTO `permission`(`id`, `pid`, `name`, `sort`, `description`) VALUES (1, 0, 'Log', 0, '');
|
||||
|
@ -225,9 +225,11 @@ func (gsync Gsync) remoteSync(msgChIn chan<- syncMessage) {
|
||||
Type: model.Deploy,
|
||||
}
|
||||
// write after deploy script for rsync
|
||||
scriptName := fmt.Sprintf("GAD%d", projectServer.ServerID)
|
||||
if len(project.AfterDeployScript) != 0 {
|
||||
scriptName := path.Join(core.GetProjectPath(project.ID), "goploy-after-deploy."+utils.GetScriptExt(project.AfterDeployScriptMode))
|
||||
_ = ioutil.WriteFile(scriptName, []byte(ReplaceProjectVars(ReplaceCommitVars(project.AfterDeployScript, gsync.CommitInfo), project)), 0755)
|
||||
scriptContent := ReplaceProjectVars(project.AfterDeployScript, project)
|
||||
scriptContent = ReplaceProjectServerVars(scriptContent, projectServer)
|
||||
_ = ioutil.WriteFile(path.Join(core.GetProjectPath(project.ID), scriptName), []byte(scriptContent), 0755)
|
||||
}
|
||||
|
||||
transmitterEntity := transmitter.New(project, projectServer)
|
||||
@ -266,7 +268,7 @@ func (gsync Gsync) remoteSync(msgChIn chan<- syncMessage) {
|
||||
}
|
||||
|
||||
if len(project.AfterDeployScript) != 0 {
|
||||
afterDeployScriptPath := path.Join(project.Path, "goploy-after-deploy."+utils.GetScriptExt(project.AfterDeployScriptMode))
|
||||
afterDeployScriptPath := path.Join(project.Path, scriptName)
|
||||
afterDeployCommands = append(afterDeployCommands, cmdEntity.Script(project.AfterDeployScriptMode, afterDeployScriptPath))
|
||||
afterDeployCommands = append(afterDeployCommands, cmdEntity.Remove(afterDeployScriptPath))
|
||||
}
|
||||
@ -569,10 +571,36 @@ func ReplaceCommitVars(script string, commitInfo repository.CommitInfo) string {
|
||||
|
||||
func ReplaceProjectVars(script string, project model.Project) string {
|
||||
scriptVars := map[string]string{
|
||||
"${PROJECT_ID}": strconv.FormatInt(project.ID, 10),
|
||||
"${PROJECT_PATH}": project.Path,
|
||||
"${PROJECT_SYMLINK_PATH}": path.Join(project.SymlinkPath, project.LastPublishToken),
|
||||
"${PROJECT_NAME}": project.Name,
|
||||
"${PROJECT_BRANCH}": project.Branch,
|
||||
"${REPOSITORY_TYPE}": project.RepoType,
|
||||
"${REPOSITORY_URL}": project.URL,
|
||||
"${REPOSITORY_PATH}": core.GetProjectPath(project.ID),
|
||||
"${PUBLISH_TOKEN}": project.LastPublishToken,
|
||||
}
|
||||
for key, value := range scriptVars {
|
||||
script = strings.Replace(script, key, value, -1)
|
||||
}
|
||||
return script
|
||||
}
|
||||
|
||||
func ReplaceProjectServerVars(script string, server model.ProjectServer) string {
|
||||
scriptVars := map[string]string{
|
||||
"${SERVER_ID}": strconv.FormatInt(server.ServerID, 10),
|
||||
"${SERVER_NAME}": server.ServerName,
|
||||
"${SERVER_IP}": server.ServerIP,
|
||||
"${SERVER_PORT}": strconv.Itoa(server.ServerPort),
|
||||
"${SERVER_OWNER}": server.ServerOwner,
|
||||
"${SERVER_PASSWORD}": server.ServerPassword,
|
||||
"${SERVER_PATH}": server.ServerPath,
|
||||
"${SERVER_JUMP_IP}": server.ServerJumpIP,
|
||||
"${SERVER_JUMP_PORT}": strconv.Itoa(server.ServerJumpPort),
|
||||
"${SERVER_JUMP_OWNER}": server.ServerJumpOwner,
|
||||
"${SERVER_JUMP_PASSWORD}": server.ServerJumpPassword,
|
||||
"${SERVER_JUMP_PATH}": server.ServerJumpPath,
|
||||
}
|
||||
for key, value := range scriptVars {
|
||||
script = strings.Replace(script, key, value, -1)
|
||||
|
@ -5,6 +5,7 @@
|
||||
package transmitter
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/zhenorzz/goploy/core"
|
||||
"github.com/zhenorzz/goploy/model"
|
||||
"github.com/zhenorzz/goploy/utils"
|
||||
@ -37,7 +38,7 @@ func (rt rsyncTransmitter) args() []string {
|
||||
rsyncOption, _ := utils.ParseCommandLine(project.TransferOption)
|
||||
rsyncOption = append([]string{
|
||||
"--include",
|
||||
"goploy-after-deploy." + utils.GetScriptExt(project.AfterDeployScriptMode),
|
||||
fmt.Sprintf("GAD%d", projectServer.ServerID),
|
||||
}, rsyncOption...)
|
||||
rsyncOption = append(rsyncOption, "-e", projectServer.ToSSHOption())
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
package transmitter
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/pkg/sftp"
|
||||
"github.com/zhenorzz/goploy/core"
|
||||
"github.com/zhenorzz/goploy/model"
|
||||
@ -94,7 +95,7 @@ func (st sftpTransmitter) Exec() (string, error) {
|
||||
}
|
||||
nextItem = ""
|
||||
}
|
||||
includes = append(includes, "goploy-after-deploy."+utils.GetScriptExt(project.AfterDeployScriptMode))
|
||||
includes = append(includes, fmt.Sprintf("GAD%d", st.ProjectServer.ServerID))
|
||||
|
||||
srcPath := core.GetProjectPath(project.ID) + "/"
|
||||
destPath := project.Path
|
||||
|
Loading…
Reference in New Issue
Block a user