Merge pull request #7 from MaverickMartyn/dependabot/nuget/multi-129c… #36
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Publish | |
on: | |
push: | |
branches: [ main ] | |
tags: | |
- v2.** | |
pull_request: | |
branches: [ main ] | |
jobs: | |
build: | |
runs-on: windows-latest | |
steps: | |
- name: Checkout the code | |
uses: actions/checkout@v4 | |
- name: Add msbuild to PATH | |
uses: actions/setup-node@v4 | |
- name: Add nuget to PATH | |
uses: nuget/setup-nuget@v2 | |
- name: Add msbuild to PATH | |
uses: microsoft/setup-msbuild@v2 | |
- name: Extract version from tag | |
id: tag | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
result-encoding: string | |
script: | | |
const versionRegex = new RegExp("\/?refs\/tags\/v(?<version>.*)"); | |
var matches = versionRegex.exec(context.payload.ref); | |
if (!!matches && !!matches.groups && !!matches.groups.version) | |
return matches.groups.version; | |
var reqRes = await github.request('GET /repos/MaverickMartyn/SqlTools/tags', { owner: 'MaverickMartyn', repo: 'SqlTools', headers: {'X-GitHub-Api-Version': '2022-11-28'}}); | |
var latestTag = reqRes.data.filter((t) => /v[0-9]+.[0-9]+.[0-9]+/.test(t.name)).sort((t1, t2) => t1.name.localeCompare(t2.name)).reverse()[0]; | |
if (!!latestTag) | |
return latestTag.name.replace("v", ""); | |
return "1.0.0"; | |
- name: Echo version | |
run: echo ${{ steps.tag.outputs.result }} | |
- name: Update version numbers | |
run: | | |
(Get-Content -Path SqlTools\source.extension.vsixmanifest) | | |
ForEach-Object {$_ -Replace '2.2.7', '${{ steps.tag.outputs.result }}'} | | |
Set-Content -Path SqlTools\source.extension.vsixmanifest | |
(Get-Content -Path SqlTools\Properties\AssemblyInfo.cs) | | |
ForEach-Object {$_ -Replace '2.2.7', '${{ steps.tag.outputs.result }}'} | | |
Set-Content -Path SqlTools\Properties\AssemblyInfo.cs | |
- name: Restore | |
run: nuget restore | |
- name: Build | |
run: msbuild /p:configuration=Release /p:DeployExtension=false /p:ZipPackageCompressionLevel=normal | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: SqlTools.vsix | |
path: SqlTools\bin\Release\SqlTools.vsix | |
publish: | |
runs-on: windows-latest | |
needs: build | |
if: startsWith(github.ref, 'refs/tags/v') | |
steps: | |
- name: Checkout the code | |
uses: actions/checkout@v4 | |
- name: Convert resource URLs to absolute. | |
run: | | |
(Get-Content -Path README.md) | | |
ForEach-Object {$_ -Replace 'SqlTools/Resources', 'https://github.com/MaverickMartyn/sqltools/raw/main/SqlTools/Resources'} | | |
Set-Content -Path README.md | |
- name: Download VSIX artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: SqlTools.vsix | |
- name: Publish extension to Marketplace (only on release builds) | |
uses: cezarypiatek/[email protected] | |
with: | |
extension-file: SqlTools.vsix | |
publish-manifest-file: publishManifest.json | |
personal-access-code: ${{ secrets.VS_PUBLISHER_ACCESS_TOKEN }} |