Release 2.1.0 #175
Workflow file for this run
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
on: | |
push: | |
branches: | |
- main | |
tags: | |
- v* | |
pull_request: | |
env: | |
Configuration: Release | |
TreatWarningsAsErrors: true | |
WarningsNotAsErrors: 1591,NU5128 | |
Deterministic: true | |
RunCodeAnalysis: false | |
jobs: | |
pre_build: | |
runs-on: ubuntu-20.04 | |
outputs: | |
version: ${{ steps.version.outputs.version }} | |
version3: ${{ steps.version.outputs.version3 }} | |
defaults: | |
run: | |
working-directory: src | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- run: dotnet tool install -g GitVersion.Tool --version 5.11.1 | |
- name: Resolve version | |
id: version | |
run: | | |
dotnet-gitversion > version.json | |
version="$(jq -r '.SemVer' version.json)" | |
version3="$(jq -r '.MajorMinorPatch' version.json)" | |
pr_version="$(jq -r '.MajorMinorPatch' version.json)-$(jq -r '.PreReleaseLabel' version.json).${{ github.run_number }}.${{ github.run_attempt }}" | |
if [ "${{ github.event_name }}" = "pull_request" ]; then version=$pr_version; fi | |
echo "Resolved version: $version" | |
echo "version=${version}" >> $GITHUB_OUTPUT | |
echo "Resolved version3: $version3" | |
echo "version3=${version3}" >> $GITHUB_OUTPUT | |
build_nuget: | |
needs: pre_build | |
runs-on: ubuntu-20.04 | |
env: | |
Configuration: Release | |
TreatWarningsAsErrors: true | |
WarningsNotAsErrors: 1591 | |
defaults: | |
run: | |
working-directory: src/Snippetica.VisualStudio | |
outputs: | |
Version: ${{ needs.pre_build.outputs.version }} | |
steps: | |
- uses: actions/checkout@v3 | |
- run: dotnet restore | |
- run: dotnet format --no-restore --verify-no-changes --severity info | |
- run: dotnet build --no-restore | |
- run: dotnet test --no-build | |
- run: dotnet pack --no-build | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: nuget_packages | |
path: src/Snippetica.VisualStudio/bin/Release/*.*nupkg | |
build_vs_extension: | |
needs: pre_build | |
runs-on: windows-latest | |
env: | |
Version: ${{ needs.pre_build.outputs.version }} | |
DeployExtension: false | |
defaults: | |
run: | |
working-directory: src/Snippetica.VisualStudio.Vsix | |
steps: | |
- uses: actions/checkout@v3 | |
- run: (Get-Content source.extension.vsixmanifest) -replace 'Version="1.0.0"', 'Version="${{ needs.pre_build.outputs.version3 }}"' | Set-Content source.extension.vsixmanifest | |
- run: dotnet restore | |
working-directory: src/Snippetica.CodeGeneration.SnippetGenerator | |
- run: dotnet build --no-restore | |
working-directory: src/Snippetica.CodeGeneration.SnippetGenerator | |
- run: "src/Snippetica.CodeGeneration.SnippetGenerator/bin/Release/net6.0/Snippetica.CodeGeneration.SnippetGenerator src src/Snippetica.CodeGeneration.Metadata/Data" | |
name: "Generate snippets" | |
working-directory: "." | |
- uses: microsoft/[email protected] | |
- run: msbuild -m | |
- uses: actions/upload-artifact@v3 | |
name: "Upload vsix file" | |
with: | |
name: vs_extension | |
path: src/Snippetica.VisualStudio.Vsix/bin/Release/*.vsix | |
- uses: actions/upload-artifact@v3 | |
name: "Upload manifest file" | |
with: | |
name: vs_extension | |
path: src/Snippetica.VisualStudio.Vsix/manifest.json | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: vs_extension | |
path: src/Snippetica.VisualStudio.Vsix/Overview.md | |
- uses: actions/upload-artifact@v3 | |
name: "Upload Visual Studio snippets" | |
with: | |
name: vs_snippets | |
path: src/Snippetica.VisualStudio.Vsix/**/*.snippet | |
build_vs_code_extensions: | |
needs: pre_build | |
runs-on: ubuntu-20.04 | |
env: | |
Version: ${{ needs.pre_build.outputs.version }} | |
DefineConstants: VSCODE | |
strategy: | |
matrix: | |
component: | |
- name: cpp | |
directoryName: Snippetica.Cpp | |
- name: csharp | |
directoryName: Snippetica.CSharp | |
- name: vb | |
directoryName: Snippetica.VisualBasic | |
defaults: | |
run: | |
working-directory: "src/Snippetica.VisualStudioCode.Vsix/${{ matrix.component.directoryName }}/package" | |
steps: | |
- uses: actions/checkout@v3 | |
- run: dotnet restore | |
working-directory: src/Snippetica.CodeGeneration.SnippetGenerator | |
- run: dotnet build --no-restore | |
working-directory: src/Snippetica.CodeGeneration.SnippetGenerator | |
- run: "./src/Snippetica.CodeGeneration.SnippetGenerator/bin/Release/net6.0/Snippetica.CodeGeneration.SnippetGenerator src src/Snippetica.CodeGeneration.Metadata/Data" | |
working-directory: "." | |
name: "Generate snippets" | |
- run: > | |
sed -i 's/"version": "1.0.0"/"version": "${{ needs.pre_build.outputs.version3 }}"/' "package.json" | |
- run: npm install -g @vscode/vsce | |
- run: vsce package | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: "vs_code_extension_${{ matrix.component.name }}" | |
path: "src/Snippetica.VisualStudioCode.Vsix/${{ matrix.component.directoryName }}/package/*.vsix" | |
# publish_nuget: | |
# runs-on: ubuntu-20.04 | |
# needs: build_nuget | |
# if: github.ref_type == 'tag' && startsWith(github.ref_name, 'v') | |
# steps: | |
# - uses: actions/download-artifact@v3 | |
# with: | |
# name: nuget_packages | |
# path: nuget_packages | |
# - run: dotnet nuget push "*.nupkg" -k ${{ secrets.NUGET_API_KEY }} -s "https://api.nuget.org/v3/index.json" | |
# working-directory: nuget_packages | |
publish_vs_extension: | |
needs: build_vs_extension | |
runs-on: windows-latest | |
if: github.ref_type == 'tag' && startsWith(github.ref_name, 'v') | |
steps: | |
- uses: actions/download-artifact@v3 | |
with: | |
name: vs_extension | |
path: vs_extension | |
- run: | | |
$visualStudioPath = vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VSSDK -property installationPath | |
$vsixPublisher = Join-Path "$visualStudioPath" "VSSDK\VisualStudioIntegration\Tools\Bin\VsixPublisher.exe" | |
& "$vsixPublisher" publish -payload Snippetica.VisualStudio.vsix -publishManifest manifest.json -personalAccessToken ${{ secrets.VS_MARKETPLACE_TOKEN }} | |
working-directory: vs_extension | |
name: Publish VS extension to Marketplace | |
publish_vs_code_extension: | |
needs: [ pre_build, build_vs_code_extensions ] | |
runs-on: ubuntu-20.04 | |
if: github.ref_type == 'tag' && startsWith(github.ref_name, 'v') | |
strategy: | |
matrix: | |
component: | |
- name: cpp | |
- name: csharp | |
- name: vb | |
steps: | |
- uses: actions/download-artifact@v3 | |
with: | |
name: vs_code_extension_${{ matrix.component.name }} | |
path: vs_code_extension | |
- run: npm install -g @vscode/vsce | |
- run: vsce publish -p ${{ secrets.VS_MARKETPLACE_TOKEN }} -i "snippetica-${{ matrix.component.name }}-${{ needs.pre_build.outputs.version3 }}.vsix" | |
working-directory: vs_code_extension |