【问题标题】:How to tag releases to Git using Capistrano v3如何使用 Capistrano v3 将发布标记到 Git
【发布时间】:2014-09-10 19:14:51
【问题描述】:

我正在使用 Capistrano v3,我正在尝试标记部署并将它们推送到 github。

到目前为止我有:

task :tag do 
    on roles (:app) do
      puts "\x1B[35m Tagging deployment... \x1B[0m"

      timestamp = Time.now.strftime("%Y_%m_%d_%H_%M_%S")
      tag_name = "#{fetch(:stage)}_#{timestamp}"
      puts "\x1B[35m tag name... \x1B[0m" + tag_name
      execute "cd #{repo_path} && git tag #{tag_name} && git push origin --tags"

      puts "\x1B[35m Done. Deployment tagged as #{fetch(:tag_name)} \x1B[0m"
    end
  end

问题是repo_path 是一个镜像仓库,我当然不能执行或使用--tags,因为它会引发错误。

关于如何完成这个非常简单的任务有什么想法吗?

【问题讨论】:

    标签: git ubuntu github tags capistrano3


    【解决方案1】:

    我找到了解决办法。

    我基本上做了以下事情:

    desc "Tag deployed release"
        task :tag do
        run_locally do
          timestamp = Time.now.strftime("%Y_%m_%d_%H_%M_%S")
          tag_name = "#{fetch(:stage)}_#{timestamp}"
          latest_revision = fetch(:current_revision)
          strategy.git "tag -f #{tag_name} #{latest_revision}"
          strategy.git "push -f --tags"
          info "[cap-deploy-tagger] Tagged #{latest_revision} with #{tag_name}"
        end
      end
    
    after :cleanup, 'deploy:tag'
    

    这很有意义。我在本地标记部署,而不是直接在服务器上进行:)

    【讨论】:

      猜你喜欢
      • 2023-04-04
      • 2014-09-27
      • 2018-04-24
      • 1970-01-01
      • 2011-03-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-25
      相关资源
      最近更新 更多