How to deploy artifact to github releases using TeamCity
Asked Answered
S

1

5

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.

Sixty answered 7/5, 2017 at 11:42 Comment(0)
S
9

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.

Sixty answered 7/5, 2017 at 18:16 Comment(1)
Step 1 should read "Install .. on the TeamCity agent machine" as the build is executed on the agent.Peewee

© 2022 - 2024 — McMap. All rights reserved.