简单的自动发布脚本

背景: 没有基础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

}

相关推荐
Hy行者勇哥6 小时前
用Cursor智能编写Ansible/Terraform脚本,打通CI/CD链路
ci/cd·ansible·terraform
想你依然心痛1 天前
AtomCode 在 DevOps 场景中的实战:CI/CD 流水线脚本自动生成
运维·ci/cd·docker·devops·自动化部署·github actions
IT二叔2 天前
Java项目部署-03-teamcity-cicd-docker镜像流水线方式部署
java·ci/cd·持续部署
想你依然心痛2 天前
持续集成在嵌入式开发中的实践:GitLab CI与交叉编译——自动化构建、固件生成
ci/cd·自动化·gitlab
江畔柳前堤3 天前
第14章:Docker 与 CI/CD
运维·ci/cd·docker·容器·eureka·github
Bigger8 天前
从零搭建 AI 代码审查服务:一份前端也能看懂的 Python 学习笔记
前端·ci/cd·ai编程
宋均浩13 天前
# Docker 镜像瘦身实战:从 1.2G 到 80MB 的五个优化步骤
ci/cd·docker
宋均浩18 天前
# GitHub Actions 实战:从零搭建 CI/CD 流水线的 5 个核心配置
ci/cd
霸道流氓气质20 天前
GitLab CI/CD 完全指南
linux·ci/cd·gitlab
sbjdhjd20 天前
从零搭建企业级 CI/CD(下):Jenkins+GitLab+Harbor 全链路实战指南
git·servlet·ci/cd·云原生·云计算·gitlab·jenkins