From c6603c1e25ba4fe6183c468442fe5f6bd52b50aa Mon Sep 17 00:00:00 2001 From: elchananarb Date: Sun, 14 Jul 2024 19:18:02 +0300 Subject: [PATCH 1/5] Salesforce | 00207398 | [VS] Incorrect version in Visual Studio Marketplace --- .github/workflows/release.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a77c9f7..1843875 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -74,7 +74,9 @@ jobs: uses: timheuer/vsix-version-stamp@9d38292e99e54046455bb68c6a2b5113d269a7d0 #v2 with: manifest-file: ast-visual-studio-extension\source.extension.vsixmanifest - + version-type: custom + version: ${{ env.RELEASE_VERSION }} + - name: Restore NuGet packages run: msbuild -t:restore From e9e8c262ce6aaba0ff07bbea501b4d002c4f940f Mon Sep 17 00:00:00 2001 From: elchananarb Date: Mon, 15 Jul 2024 17:29:33 +0300 Subject: [PATCH 2/5] add new yml to check version --- .github/actions/action.yaml | 84 +++++++++++++++++++ .github/workflows/test-vsix-version-stamp.yml | 24 ++++++ 2 files changed, 108 insertions(+) create mode 100644 .github/actions/action.yaml create mode 100644 .github/workflows/test-vsix-version-stamp.yml diff --git a/.github/actions/action.yaml b/.github/actions/action.yaml new file mode 100644 index 0000000..ec4ccbd --- /dev/null +++ b/.github/actions/action.yaml @@ -0,0 +1,84 @@ +name: 'Set VSIX Version' +description: 'Increments the VSIX build version or sets it to a specified version.' +branding: + icon: copy + color: purple +inputs: + version-type: + description: 'Version type - build or revision' + required: true + default: 'build' + manifest-file: + description: 'Path to VSIX manifest' + required: true + build-number: + description: 'Build number to use' + required: true + default: ${{ github.run_number }} + vsix-token-source-file: + description: 'Path to source.extension.vs' + required: false + default: '' + version-number: + description: If provided, will be used directly as the version of the VSIX, and no incrementing will happen. + required: false + default: '' +outputs: + version-number: + description: 'The resulting version number' + value: ${{ steps.version_increment.outputs.version }} +runs: + using: "composite" + steps: + - name: Set VSIX version + id: version_increment + shell: pwsh + env: + # Intermediary environment variable needed for security, see: + # https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable + VERSION_NUMBER: ${{ inputs.version-number }} + run: | + [xml]$vsixXml = Get-Content ${{ inputs.manifest-file }} + + $ns = New-Object System.Xml.XmlNamespaceManager $vsixXml.NameTable + $ns.AddNamespace("ns", $vsixXml.DocumentElement.NamespaceURI) | Out-Null + + $attrVersion = "" + + if ($vsixXml.SelectSingleNode("//ns:Identity", $ns)){ # VS2012 format + $attrVersion = $vsixXml.SelectSingleNode("//ns:Identity", $ns).Attributes["Version"] + } + elseif ($vsixXml.SelectSingleNode("//ns:Version", $ns)){ # VS2010 format + $attrVersion = $vsixXml.SelectSingleNode("//ns:Version", $ns) + } + + if ([string]::IsNullOrEmpty($Env:VERSION_NUMBER)){ + [Version]$version = $attrVersion.Value + + if (!$attrVersion.Value){ + $version = $attrVersion.InnerText + } + + if ("${{ inputs.version-type }}" -eq "build"){ + $version = New-Object Version ([int]$version.Major),([int]$version.Minor),${{ inputs.build-number }} + } + elseif ("${{ inputs.version-type }}" -eq "revision"){ + $version = New-Object Version ([int]$version.Major),([int]$version.Minor),([System.Math]::Max([int]$version.Build, 0)),${{ inputs.build-number }} + } + } + else{ + [Version]$version = New-Object Version $Env:VERSION_NUMBER + } + + $attrVersion.InnerText = $version + + $vsixXml.Save("${{ inputs.manifest-file }}") | Out-Null + + "version=$version" >> $Env:GITHUB_OUTPUT + - name: VSIX token replacement + if: inputs.vsix-token-source-file != '' && inputs.vsix-token-source-file != null + shell: pwsh + run: | + $filePath = "${{ inputs.vsix-token-source-file }}" + $replacement = 'Version = "${{ steps.version_increment.outputs.version }}"' + $content = [string]::join([ diff --git a/.github/workflows/test-vsix-version-stamp.yml b/.github/workflows/test-vsix-version-stamp.yml new file mode 100644 index 0000000..730a4f5 --- /dev/null +++ b/.github/workflows/test-vsix-version-stamp.yml @@ -0,0 +1,24 @@ +name: Test VSIX Version Stamp + +on: + workflow_dispatch: + +jobs: + test-version: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Run VSIX Version Stamp + id: vsix_version + uses: ./.github/actions/vsix-version-stamp + with: + version-type: 'build' + manifest-file: 'ast-visual-studio-extension/source.extension.vsixmanifest' + build-number: ${{ github.run_number }} + version-number: '' # אם תרצה להשתמש במספר גרסה מסויים + + - name: Output version number + run: echo "Version number is ${{ steps.vsix_version.outputs.version-number }}" From e8afdcab384fc25a9d71393cc2a838f6e6afac66 Mon Sep 17 00:00:00 2001 From: elchananarb Date: Mon, 15 Jul 2024 17:41:41 +0300 Subject: [PATCH 3/5] add new yml to check version --- .github/actions/action.yaml | 4 +++- .github/workflows/test-vsix-version-stamp.yml | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/actions/action.yaml b/.github/actions/action.yaml index ec4ccbd..507835f 100644 --- a/.github/actions/action.yaml +++ b/.github/actions/action.yaml @@ -81,4 +81,6 @@ runs: run: | $filePath = "${{ inputs.vsix-token-source-file }}" $replacement = 'Version = "${{ steps.version_increment.outputs.version }}"' - $content = [string]::join([ + $content = [string]::join([environment]::newline, (get-content $filePath)) + $regex = New-Object System.Text.RegularExpressions.Regex 'Version = "([0-9\\.]+)"' + $regex.Replace($content, $replacement) | Out-File $FilePath diff --git a/.github/workflows/test-vsix-version-stamp.yml b/.github/workflows/test-vsix-version-stamp.yml index 730a4f5..108cb8b 100644 --- a/.github/workflows/test-vsix-version-stamp.yml +++ b/.github/workflows/test-vsix-version-stamp.yml @@ -18,7 +18,7 @@ jobs: version-type: 'build' manifest-file: 'ast-visual-studio-extension/source.extension.vsixmanifest' build-number: ${{ github.run_number }} - version-number: '' # אם תרצה להשתמש במספר גרסה מסויים + version-number: '' - name: Output version number run: echo "Version number is ${{ steps.vsix_version.outputs.version-number }}" From 590ca3e99bfeb682d6ac069ccb01773f15e3cb5e Mon Sep 17 00:00:00 2001 From: elchananarb Date: Tue, 16 Jul 2024 08:50:53 +0300 Subject: [PATCH 4/5] check env.RELEASE_VERSION --- .github/actions/action.yaml | 86 ------------------- .github/workflows/release.yml | 1 + .github/workflows/test-vsix-version-stamp.yml | 24 ------ 3 files changed, 1 insertion(+), 110 deletions(-) delete mode 100644 .github/actions/action.yaml delete mode 100644 .github/workflows/test-vsix-version-stamp.yml diff --git a/.github/actions/action.yaml b/.github/actions/action.yaml deleted file mode 100644 index 507835f..0000000 --- a/.github/actions/action.yaml +++ /dev/null @@ -1,86 +0,0 @@ -name: 'Set VSIX Version' -description: 'Increments the VSIX build version or sets it to a specified version.' -branding: - icon: copy - color: purple -inputs: - version-type: - description: 'Version type - build or revision' - required: true - default: 'build' - manifest-file: - description: 'Path to VSIX manifest' - required: true - build-number: - description: 'Build number to use' - required: true - default: ${{ github.run_number }} - vsix-token-source-file: - description: 'Path to source.extension.vs' - required: false - default: '' - version-number: - description: If provided, will be used directly as the version of the VSIX, and no incrementing will happen. - required: false - default: '' -outputs: - version-number: - description: 'The resulting version number' - value: ${{ steps.version_increment.outputs.version }} -runs: - using: "composite" - steps: - - name: Set VSIX version - id: version_increment - shell: pwsh - env: - # Intermediary environment variable needed for security, see: - # https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable - VERSION_NUMBER: ${{ inputs.version-number }} - run: | - [xml]$vsixXml = Get-Content ${{ inputs.manifest-file }} - - $ns = New-Object System.Xml.XmlNamespaceManager $vsixXml.NameTable - $ns.AddNamespace("ns", $vsixXml.DocumentElement.NamespaceURI) | Out-Null - - $attrVersion = "" - - if ($vsixXml.SelectSingleNode("//ns:Identity", $ns)){ # VS2012 format - $attrVersion = $vsixXml.SelectSingleNode("//ns:Identity", $ns).Attributes["Version"] - } - elseif ($vsixXml.SelectSingleNode("//ns:Version", $ns)){ # VS2010 format - $attrVersion = $vsixXml.SelectSingleNode("//ns:Version", $ns) - } - - if ([string]::IsNullOrEmpty($Env:VERSION_NUMBER)){ - [Version]$version = $attrVersion.Value - - if (!$attrVersion.Value){ - $version = $attrVersion.InnerText - } - - if ("${{ inputs.version-type }}" -eq "build"){ - $version = New-Object Version ([int]$version.Major),([int]$version.Minor),${{ inputs.build-number }} - } - elseif ("${{ inputs.version-type }}" -eq "revision"){ - $version = New-Object Version ([int]$version.Major),([int]$version.Minor),([System.Math]::Max([int]$version.Build, 0)),${{ inputs.build-number }} - } - } - else{ - [Version]$version = New-Object Version $Env:VERSION_NUMBER - } - - $attrVersion.InnerText = $version - - $vsixXml.Save("${{ inputs.manifest-file }}") | Out-Null - - "version=$version" >> $Env:GITHUB_OUTPUT - - name: VSIX token replacement - if: inputs.vsix-token-source-file != '' && inputs.vsix-token-source-file != null - shell: pwsh - run: | - $filePath = "${{ inputs.vsix-token-source-file }}" - $replacement = 'Version = "${{ steps.version_increment.outputs.version }}"' - $content = [string]::join([environment]::newline, (get-content $filePath)) - $regex = New-Object System.Text.RegularExpressions.Regex 'Version = "([0-9\\.]+)"' - $regex.Replace($content, $replacement) | Out-File $FilePath diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1843875..baa4038 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -63,6 +63,7 @@ jobs: echo ${{ inputs.tag }} tag=${{ inputs.tag }} echo "RELEASE_VERSION=${{ inputs.tag }}" >> $GITHUB_ENV + echo ${{ env.RELEASE_VERSION }} message='${{ inputs.tag }}' git config user.name "${GITHUB_ACTOR}" git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" diff --git a/.github/workflows/test-vsix-version-stamp.yml b/.github/workflows/test-vsix-version-stamp.yml deleted file mode 100644 index 108cb8b..0000000 --- a/.github/workflows/test-vsix-version-stamp.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: Test VSIX Version Stamp - -on: - workflow_dispatch: - -jobs: - test-version: - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Run VSIX Version Stamp - id: vsix_version - uses: ./.github/actions/vsix-version-stamp - with: - version-type: 'build' - manifest-file: 'ast-visual-studio-extension/source.extension.vsixmanifest' - build-number: ${{ github.run_number }} - version-number: '' - - - name: Output version number - run: echo "Version number is ${{ steps.vsix_version.outputs.version-number }}" From eea3cc4e25303ae2118aca8a1496801ab24c9ed9 Mon Sep 17 00:00:00 2001 From: elchananarb Date: Tue, 16 Jul 2024 09:13:09 +0300 Subject: [PATCH 5/5] change to commit tag --- .github/workflows/release.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index baa4038..c982635 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -63,7 +63,6 @@ jobs: echo ${{ inputs.tag }} tag=${{ inputs.tag }} echo "RELEASE_VERSION=${{ inputs.tag }}" >> $GITHUB_ENV - echo ${{ env.RELEASE_VERSION }} message='${{ inputs.tag }}' git config user.name "${GITHUB_ACTOR}" git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" @@ -75,8 +74,7 @@ jobs: uses: timheuer/vsix-version-stamp@9d38292e99e54046455bb68c6a2b5113d269a7d0 #v2 with: manifest-file: ast-visual-studio-extension\source.extension.vsixmanifest - version-type: custom - version: ${{ env.RELEASE_VERSION }} + version-number: ${{ inputs.tag }} - name: Restore NuGet packages run: msbuild -t:restore