Giter VIP home page Giter VIP logo

Comments (3)

ryx avatar ryx commented on July 19, 2024

I came up with a (kind of) working solution, maybe it is of help to someone else. I'd also really appreciate any comments or feedback on this, since I have been using Azure CI for not much more than 3 hours now ;) ...

This approach uses a conditional task execution which only triggers the npm publish task when the source branch is a new release (create via github). This still has some disadvantages (e.g. manual versioning), but works for a simple publishing workflow when using the github UI for creating releases.

# Build and publish a node.js-based library from a github repository. Only
# publish anything to npm if the tests succeeded (so the build was ok)
# and the build is spawned from a new release in github.

pool:
  vmImage: 'Ubuntu 16.04'

steps:
  - task: NodeTool@0
    inputs:
      versionSpec: '8.x'
    displayName: 'Install Node.js'

  - script: |
      npm install
      npm run test
    displayName: 'Npm install and test'

  - task: Npm@1
    # only execute this task when the sourceBranch is a new release
    condition: startsWith(variables['build.sourceBranch'], 'refs/tags/')
    inputs:
      command: publish
      publishEndpoint: npmjs.com
    displayName: 'Publishing to npmjs.com'

from azure-pipelines-yaml.

wichert avatar wichert commented on July 19, 2024

I suspect the preferred approach is to use a different pipeline YAML file for releases, and give that a trigger that only looks for tags. You can combine that with a template to prevent duplication. For example I use these three files:

templates/test.yml

  jobs:
  - job: test
    displayName: Run tests

    pool:
      vmImage: 'Ubuntu 16.04'

    steps:
      - task: NodeTool@0
        inputs:
          versionSpec: '10.x'

      - task: Npm@1
        displayName: 'npm install'
        inputs:
          command: install

      - task: Npm@1
        displayName: 'npm test'
        inputs:
          command: custom
          customCommand: 'test'

test.yml

jobs:
  - template: templates/test.yml

release.yml

trigger:
  branches:
    exclude:
      - "*"
  tags:
    include:
      - v*

jobs:
  - template: templates/test.yml


  - job: docker
    displayName: Docker image
    dependsOn:
      - test

    pool:
      vmImage: 'Ubuntu 16.04'

    steps:
      - task: Docker@2
        displayName: Login to ACR
        inputs:
          command: login
          containerRegistry: azr-crypho

      - task: Docker@2
        displayName: Build and Push
        inputs:
          command: buildAndPush
          repository: crypho/nexmock
          tags: |
            $(Build.BuildId)
            $(Build.SourceBranch)

from azure-pipelines-yaml.

stale avatar stale commented on July 19, 2024

In order to consolidate to fewer feedback channels, we've moved suggestions and issue reporting to Developer Community. Sorry for any confusion resulting from this move.

from azure-pipelines-yaml.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.