简单的自动发布脚本

背景: 没有基础CI/CD 建设,又不想大动干戈,所以想着写个脚本完成这个工作,windows中使用,如果是linux只需要修改检查和发送消息部分,发送消息部分可以使用cURL

获取本地和远程的commitId

$localCommitId = git rev-parse HEAD

$string = git ls-remote origin HEAD

remoteCommitId = string.Substring(0, 40)

echo $remoteCommitId

echo $localCommitId

#检查是否有新的提交

if (remoteCommitId -ceq localCommitId) {

exit;

}

else {

停止旧服务

Stop-Process -force -name *iValon.WES.API*

cd D:\

拉取代码

git pull

发布

dotnet publish -c Release -r win-x64 --self-contained true -o

关闭build-server

dotnet build-server shutdown

启动新进程

Start-Process .\i

发送企业微信消息

msg = '{ "msgtype": "markdown", "markdown": { "content": "\' + remoteCommitId + ':\u53d1\u5e03\u6210\u529f</font>" }}';

Invoke-WebRequest https://qyapi.weixin.qq.com -Method POST -Body $msg

}

相关推荐
11路没有终点12 小时前
CI/CD 面试 10 问
ci/cd
Sopaco14 小时前
CI/CD 中的知识管理:Terrain 如何实现自动文档更新
ci/cd
11路没有终点20 小时前
GitLab CI/CD 高级模式实战:include 模板库 / trigger 子流水线 / matrix 并行
ci/cd·gitlab
11路没有终点21 小时前
GitLab CE CI/CD 入门指引手册:从零搭建第一条流水线
ci/cd·gitlab
chens1231231 天前
自建三节点 K3s 集群搭建 Drone CI/CD 流水线
ci/cd
虎王物联3 天前
Docker BuildKit多阶段构建:IoT固件交叉编译流水线实战
运维·物联网·ci/cd·docker·容器·物联网嵌入式
LlmCraft|大模型工程实践3 天前
14. CI/CD 流水线中集成 Docker:GitHub Actions 自动构建部署
ci/cd·docker·github
秦渝兴4 天前
GitLab CI/CD 流水线实战
ci/cd·gitlab
gs801404 天前
告别 CI/CD 误伤与红条:Docker 镜像智能清理与优雅防冲突实战
ci/cd·docker·容器
leeyi4 天前
DDD 六条铁律:让 CI 替你骂人——go-arch-lint 门禁实战(第104篇)
ci/cd·agent·领域驱动设计