Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to deploy artifact to github releases using TeamCity

I configured TeamCity to pull and build my github repo. Than it creates .zip artifact with files that are in "bin/Debug" folder. After that I want it to create a new tag with build number and push it to github releases, but don't have any idea how to do it.

like image 767
Rostyslav Kurdiumov Avatar asked May 07 '17 11:05

Rostyslav Kurdiumov


People also ask

Can you deploy with TeamCity?

TeamCity provides the Deployment type of build configuration. Build configurations which perform deploying to some environment can be marked with this type: these are usually build configurations that have snapshot or artifact dependencies on the builds whose results they deploy.


1 Answers

After research i finally found the answer.

  1. Install github-release on the TeamCity build agent server(s). To install github-release get the latest release and extract .exe file somewhere on drive (In my case C:\Program Files (x86)\github-release\bin\windows\amd64)
  2. Generate new security access token on github.
  3. Create artifact after build. To do it go to your build configuration and set ArtifactPaths to MyProjectName\bin\Debug => DependentArtifact.zip
  4. Create second build configuration (Not build step) with "Deploy" Name.
  5. Add new trigger to Deploy configuration. Triggers => Add new Trigger => Finish Build Trigger => Set build configuration to your first build name and enable "Trigger after successful build only " checkbox
  6. Add dependent artifact to Deploy build configuration: Dependencies => Add new artifactDependency. Set Depend On = to your first build configuration. Get artifacts from = Latest successful build. Artifact Rules = DependentArtifact.zip
  7. Add new build step to Deploy: Build Steps => Add build step => CommandLine and paste following script to custom script field:

    [PathToYourRepo] git tag Release-v0.%build.number%
    [PathToYourRepo] git push
    [PathToYourRepo] git push --tags

    [PathToGithubReleaseExe] release --security-token [YourSecurityToken] --user [YourGithubUserName] --repo [YourRepoName] --tag Release-v0.%build.number%

    [PathToGithubReleaseExe] upload --security-token [YourSecurityToken] --user [YourGithubUserName] --repo [YourRepoName] --tag Release-v0.%build.number% --name Release-v0.%build.number%.zip --file DependentArtifact.zip

And that's it! Maybe there is a simpler way to do it, but I haven't found it.

like image 117
Rostyslav Kurdiumov Avatar answered Nov 15 '22 04:11

Rostyslav Kurdiumov