How to deploy to nuget/myget when a GH tag is created

Pure Krome's Avatar

Pure Krome

14 Jul, 2016 09:25 AM

Hi Feodor.

I'm trying to have a single yml file that does all my builds / tests / deploys based on this convo.

What i'm trying to do is this:

  • if branch == master AND is-a-tag
    1) set build version to be the TAG {APPVEYOR_REPO_TAG_NAME}
    2) publish to private myget feed #1 <-- our internal release builds
  • else
    1) set build version to be {build}
    2) publish to private myget feed #2 <-- our internal pre-release builds

So all our commits will always be pushing nugets to our pre-release feed.

When we are ready to push a package to our release feed, we TAG a commit as valid semver (eg. 1.1.0) and push that tag up (or tag directly in GH's UI) which then kicks off a pull build/test and this time, deploy to our release feed #1 with the tag name being the nuget-package version {APPVEYOR_REPO_TAG_NAME}.

Is this possible?

I read about conditional deploys in the docs but I'm not sure about the setting-build-version-to-be-our-the-tag

Of course, if the tag is not semver .. the the world blows up .... so i'll assume we tag correctly :)

  1. Support Staff 1 Posted by Feodor Fitsner on 15 Jul, 2016 04:43 AM

    Feodor Fitsner's Avatar

    You would need to do a little PowerShell to get the desired result.

    To set build version from a build you can use this API: http://www.appveyor.com/docs/build-worker-api#update-build-details

    To switch between deployments you may introduce additional environment variables and then depend on them, kind of (pseudo code):

    if branch == master AND is-a-tag {
       set deploy_feed_1=true
    } else {
       set deploy_feed_2=true
    }
    
    deploy:
    - provider: NuGet
      ...
      on:
        deploy_feed_1: true
    - provider: NuGet
      ...
      on:
        deploy_feed_2: true
    
  2. 2 Posted by Pure Krome on 15 Jul, 2016 05:59 AM

    Pure Krome's Avatar

    Gotcha!

    So this is what I'm trying...

    # Override the 'version' if this is a GH-tag-commit.
    init:
      - ps: if ( ($env:APPVEYOR_REPO_BRANCH -eq 'master') -and ($env:APPVEYOR_REPO_TAG -eq $TRUE) ) { $env:APPVEYOR_BUILD_VERSION = $env:APPVEYOR_REPO_TAG_NAME }
    

    Before anything really happens, lets override the {version} if
    - branch = master
    - tag = true

    Now i'm getting this...

       Core.Tests  Total: 16, Errors: 0, Failed: 0, Skipped: 0, Time: 0.235s
    Skip "NuGet" deployment as no branches matched (build branch is "dev", deploy on branches "master")
    Deploying using NuGet provider
    No packages were pushed.
    Updating build cache
    All cache items are up to date.
    Build success
    

    It's not deploying .. even though I've said: Deploy for branch dev.

    here's my sections:

    build:
      parallel: true
      verbosity: minimal
      publish_nuget: true
      publish_nuget_symbols: false
      include_nuget_references: false


    deploy: - provider: NuGet server: <snipped> api_key: secure: <snipped> skip_symbols: true artifact: /.*.nupkg/ on: branch: dev - provider: NuGet server: <snipped> api_key: secure: <snipped> skip_symbols: true artifact: /.*.nupkg/ on: branch: master appveyor_repo_tag: true

    It's like it's ignoring the first deploy section?

  3. 3 Posted by Pure Krome on 15 Jul, 2016 06:02 AM

    Pure Krome's Avatar

    Ignore my post...

    I understand the message now.

    Deploy master + tag => It skipped this because we're in a dev branch - TICK.
    Deploy dev => It failed because it failed to find the nuspecs. Nothing to deploy, then!

    What are the rules again for finding nuspecs(s) please?

  4. 4 Posted by Pure Krome on 22 Aug, 2016 04:20 AM

    Pure Krome's Avatar

    Answer -

    1. 1x nuspec
    2. nuspec needs to site side-by-side the .csproj file.
    3. nuspec needs to have the same name as the project file (that .csproj file).

    eg.
    - MyProject.csproj
    - MyProject.nuspec

  5. Pure Krome closed this discussion on 22 Aug, 2016 04:20 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac