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.
After research i finally found the answer.
- 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)
- Generate new security access token on github.
- Create artifact after build. To do it go to your build configuration and set ArtifactPaths to MyProjectName\bin\Debug => DependentArtifact.zip
- Create second build configuration (Not build step) with "Deploy" Name.
- 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
- 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
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.
© 2022 - 2024 — McMap. All rights reserved.