Skip to content

Commit

Permalink
CD: Publish VSIX extension to the VS Marketplace (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
Djoums authored Apr 11, 2024
1 parent ea26cc4 commit eb727ec
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 29 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ on:
branches:
- 'main'
pull_request:

permissions:
contents: read

env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_NOLOGO: true
Expand Down
53 changes: 27 additions & 26 deletions .github/workflows/create-tag-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ on:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
- '[0-9]+.[0-9]+.[0-9]+-beta[0-9]+'

permissions:
actions: write
contents: write

env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_NOLOGO: true
Expand Down Expand Up @@ -91,23 +93,22 @@ jobs:
- run: echo "PACKAGE=$(find . -name "EcoCode.${{ needs.versioning.outputs.tag }}.nupkg" | head -n 1)" >> $GITHUB_ENV
- run: dotnet nuget push ${{ env.PACKAGE }} -k "${{ secrets.NUGET_API_KEY }}" -s https://api.nuget.org/v3/index.json

# Reenable when we have a VS Marketplace account and API key
# publish-vsix: # Only if both builds succeeded, and the tag is not a pre-release
# needs: [versioning, build-nuget, build-vsix]
# if: ${{ needs.versioning.outputs.tag == needs.versioning.outputs.version }}
# runs-on: windows-latest
# steps:
# - uses: actions/cache/restore@v4
# with:
# path: vsix
# key: cache-${{ github.sha }}
# enableCrossOsArchive: true
# fail-on-cache-miss: true
# - uses: cezarypiatek/VsixPublisherAction@1.1
# with:
# extension-file: vsix\EcoCode.vsix
# publish-manifest-file: vsix\publishManifest.json
# personal-access-code: ${{ secrets.VSMARKETPLACE_API_KEY }}
publish-vsix: # Only if both builds succeeded, and the tag is not a pre-release
needs: [versioning, build-nuget, build-vsix]
if: ${{ needs.versioning.outputs.tag == needs.versioning.outputs.version }}
runs-on: windows-latest
steps:
- uses: actions/cache/restore@v4
with:
path: vsix
key: cache-${{ github.sha }}
enableCrossOsArchive: true
fail-on-cache-miss: true
- uses: cezarypiatek/VsixPublisherAction@1.1
with:
extension-file: vsix\EcoCode.vsix
publish-manifest-file: vsix\publishManifest.json
personal-access-code: ${{ secrets.VSMARKETPLACE_API_KEY }}

create-release: # Only if both builds succeeded
needs: [versioning, build-nuget, build-vsix]
Expand Down Expand Up @@ -135,29 +136,29 @@ jobs:
nupkg/**/EcoCode.${{ needs.versioning.outputs.tag }}.nupkg
vsix/EcoCode.vsix
# Use when the live warning project is hosted and ready
# update-live-warnings-project:
# Adapt when the test project is hosted and ready
# update-test-project:
# needs: create-release
# runs-on: ubuntu-latest
# steps:
# - name: Checkout live warnings project
# - name: Checkout test project
# uses: actions/checkout@v4
# with:
# repository: 'your-github-username/live-warnings-repository'
# token: ${{ secrets.ACCESS_TOKEN }}
# path: 'live-warnings'
# repository: 'your-github-username/ecoCode-csharp-test-project'
# token: ${{ secrets.TESTPROJECT_ACCESS_TOKEN }}
# path: 'test-project'

# - name: Update package version in csproj
# run: |
# sed -i 's/<PackageReference Include="EcoCode" Version=".*">/<PackageReference Include="EcoCode" Version="${{ needs.versioning.outputs.tag }}">' live-warnings/ecoCode-csharp-livewarnings.csproj
# sed -i 's/<PackageReference Include="EcoCode" Version=".*">/<PackageReference Include="EcoCode" Version="${{ needs.versioning.outputs.tag }}">' test-project/ecoCode-csharp-test-project.csproj

# - name: Commit and push if changed
# run: |
# cd live-warnings
# cd test-project
# git config user.name github-actions
# git config user.email github-actions@github.com
# git add .
# git commit -m "Update EcoCode package version to ${{ needs.versioning.outputs.tag }}" || exit 0
# git push
# env:
# ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
# ACCESS_TOKEN: ${{ secrets.TESTPROJECT_ACCESS_TOKEN }}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ This set of Roslyn analyzers implements these catalogs as rules for scanning you

There are several ways you can use the ecoCode analyzers in your .Net projects:
1. As a NuGet package : https://www.nuget.org/packages/EcoCode/.
2. As a Visual Studio extension, you'll find the .vsix file in the [latest release](https://github.com/green-code-initiative/ecoCode-csharp/releases/latest) on GitHub. It will be published on the VS marketplace once everything is ready !
2. As a Visual Studio extension : https://marketplace.visualstudio.com/items?itemName=ecoCode.ecoCode
3. Coming soon : as a VS Code extension.
4. Coming soon : as a .Net CLI Tool to scan existing code bases.
5. Coming soon : a documentation on how to set up [SonarScanner for .Net](https://docs.sonarsource.com/sonarqube/latest/analyzing-source-code/scanners/sonarscanner-for-dotnet/) and display the EcoCode warnings in [SonarQube](https://www.sonarsource.com/products/sonarqube/).
Expand Down
4 changes: 2 additions & 2 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "8.0.203",
"version": "8.0.204",
"rollForward": "latestMajor"
}
}
}
11 changes: 11 additions & 0 deletions src/EcoCode.Vsix/EcoCode.Vsix.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,15 @@
<ProjectReference Include="..\EcoCode.CodeFixes\EcoCode.CodeFixes.csproj" />
</ItemGroup>

<ItemGroup>
<!-- https://github.com/dotnet/sdk/issues/433 -->
<ProjectReference Update="@(ProjectReference)" AdditionalProperties="TargetFramework=netstandard2.0" />

<!-- https://github.com/Microsoft/extendvs/issues/57 -->
<ProjectReference Update="@(ProjectReference)" Name="%(Filename)" />
</ItemGroup>

<Target Name="VsixCompatibilityAnalyzer"> <!-- Skip the very long analysis step on every publication pipeline -->
</Target>

</Project>

0 comments on commit eb727ec

Please sign in to comment.