Giter VIP home page Giter VIP logo

Comments (2)

Dave-Robertson92 avatar Dave-Robertson92 commented on June 18, 2024

@tdashworth been working on versioning for my own use/implementation of this and have a suggestion on a improvement for solution change detection (in GIT).

What do you think about the solution approach?

cc @ewingjm

from powerapps-project-template.

Dave-Robertson92 avatar Dave-Robertson92 commented on June 18, 2024

managed to get a solution working, some further tweaks to make (naming & simplicity):

Azure DevOps Config:
Pull request build policy on the default branch
image

  • run's anytime the source branch is updated
  • expires if the default branch is updated before complete (merged in) say the version number is incremented outside of the PR request on the default branch

(the PowerShell step/ for updating version number will be need removing from the Post PR build for further deployment if used)

Yaml update(add of env:systemtoken for Pushing) :

steps:
        - task: PowerShell@2
          displayName: 'Add build tag for each updated solution'
          inputs:
            targetType: 'filePath'
            errorActionPreference: 'stop'
            filePath: 'pipelines/scripts/Add-BuildTagForEachUpdatedSolution.ps1'
          env:
           SYSTEM_ACCESSTOKEN: $(System.AccessToken)

Script:

$targetbranch =  $env:SYSTEM_PULLREQUEST_TARGETBRANCH.replace('refs/heads/', '')
$resultArray = git diff --name-only  origin/$targetbranch 

[System.Collections.ArrayList]$changedSolutions = @()
$commit = 0

foreach ($_ in $resultArray) {
  if ($_.StartsWith("src/solutions")) {
    $solutionName = $_.Split("/")[2]

    if (!$changedSolutions.Contains($solutionName)) {
      $changedSolutions.Add($solutionName)
      Write-Host "##vso[build.addbuildtag]$solutionName" 
      $solutionxmlPath = 'src/solutions/' + $solutionName + '/Extract/Other/Solution.xml'
      $s = 'origin/' + $targetbranch + ':' + $solutionxmlPath
      [xml]$solutionxmltarget = git show $s
      [xml]$solutionxmlsource = Get-Content -Path  $solutionxmlPath
      $sourceVersion = [version]$solutionxmlsource.ImportExportXml.SolutionManifest.Version
      $tagetVersion = [version]$solutionxmltarget.ImportExportXml.SolutionManifest.Version
      if ($sourceVersion -le $tagetVersion)
      {
       $newVersion  =   [version]::New($tagetVersion.Major,$tagetVersion.Minor,$tagetVersion.Build,$tagetVersion.Revision+1)
       $solutionxmlsource.ImportExportXml.SolutionManifest.Version = [string]$newVersion
       $solutionxmlsource.Save($solutionxmlPath)
        $commit = 1
      }
    }
  }
}
$output = $changedSolutions -Join ','  
Write-Host "##vso[task.setvariable variable=solutionList]$output"
if ( $commit -eq 1 )
{
$un = git show -s --format="<%aN>" 
$ue = git show -s --format="<%aE>" 
git config --global user.email $ue
git config --global user.name $un
git checkout $env:SYSTEM_PULLREQUEST_SOURCEBRANCH.replace('refs/heads/', '')
git add .
git commit  --message "auto-version"
git config --global http.extraheader "AUTHORIZATION: bearer  $env:SYSTEM_ACCESSTOKEN"
git push  
}

from powerapps-project-template.

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.