我有以下命令,我想用一个命令通过“makefile”执行,我该怎么做?
1. git tag -a v0.0.1 -m "new release"
2. git push origin v0.0.1
现在,我已经创建了一些用于启动的内容
git:
git add .
git commit -m "$m"
git push origin master
现在我有两个问题,如何解决版本问题,例如,这里是v0.0.1,但对于每个新版本,我都需要对其进行升级,比如第一个版本是v0.0.1,下一个版本应该是v0.0.2,是否可以通过某种方式自动完成(可能有一些计数器...)?如果不能,可能将其作为参数添加到一个命令中
- git标签-av0.0.1-m“新版本”
- git推送原点v0.0.1
更新
有一个答案看起来很好与以下
git describe --tags --abbrev=0 | awk -F. '{$NF+=1; OFS="."; print $0}'
但是我应该怎么把它和结合起来呢?
- git标签-av0.0.1-m“新版本”
- git推送原点v0.0.1
更新2
当我按照Kevin回答中的建议尝试以下操作时,我遇到错误:
.电话:git
版本= git describe --tags --abbrev=0 | awk -F. '{$NF+=1; OFS="."; print $0}'
git:
git add .
git commit -m "$m"
git push origin master
git tag -a $(VERSION) -m "new release"
git push origin $(VERSION)
错误为:fatal: tag 'ERSION' already exists
似乎凸块不起作用,它以某种方式从版本中删除了v
我做了另一个检查,删除了repo,并从零开始手动为第一个版本0.0.1
现在我没有改变一个文件,并运行脚本,版本现在应该是0.0.2
,如果它成功,但没有我得到错误fatal: tag 'v0.0.1' already exists
,这解释了凸块不工作,任何想法的原因?
我猜是和这段代码'{$NF+=1;OFS=".";打印$0}'
2条答案
按热度按时间gdx19jrr1#
使用最后一个推送的标记,您可以自动递增版本号:
请记住,您将其存储在变量中,并将其用于
tag
和push
:解释:
git describe-显示提交中可访问的最近标记
--tags-允许匹配轻量(无注解)标记。
--abbrev=0-将抑制长格式,仅显示最近的标记。
awk -F.-使用.“”作为分隔符的处理模式
makefile:
7vhp5slm2#
根据KevinSandow的回答,在下面找到一个更详细的shell脚本
最新版本:https://gist.github.com/acucchieri/69bc649abde55315fe74bb68be82e0c8