Skip to content

Commit

Permalink
Add release workflow (#42)
Browse files Browse the repository at this point in the history
Added release automation workflow and unit tests for scripts
  • Loading branch information
kerenr-jfrog authored Oct 7, 2024
1 parent 48f34c0 commit e460417
Show file tree
Hide file tree
Showing 15 changed files with 413 additions and 125 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/build-vsix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Build VSIX

on:
workflow_call:
inputs:
ref:
required: true
type: string

jobs:
build:
runs-on: windows-latest

env:
# jfrog cli version can be changed here
JFROG_CLI_VERSION: '2.67.0'

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}

- name: Setup MSBuild
uses: microsoft/setup-msbuild@v1
with:
vs-version: 'latest'

# caching NuGet packages for optimizing the build process
- name: Cache NuGet packages
uses: actions/cache@v3
with:
path: ~/.nuget/packages
key: nuget-${{ runner.os }}-${{ hashFiles('**/*.csproj') }}
restore-keys: nuget-${{ runner.os }}-

- name: Restore dependencies
run: |
dotnet restore
nuget restore
- name: Download JFrog CLI executable
run: |
.\scripts\DownloadJfrogCli.ps1
shell: pwsh

# build the vsix project using multi-core compilation and parallel builds
- name: Build VSIX Project
run: msbuild JFrogVSExtension.sln /p:Configuration=Release /p:Platform="Any CPU" /p:BuildInParallel=true /m

# Upload vsix and unit test as artifacts for other workflows usage
- name: Upload vsix artifacts
uses: actions/upload-artifact@v3
with:
name: vsix-artifacts
path: "JFrogVSExtension/bin/Release/"

- name: Upload tests artifacts
uses: actions/upload-artifact@v3
with:
name: tests-artifacts
path: "UnitTestJfrogVSExtension/bin/Release/"
4 changes: 2 additions & 2 deletions .github/workflows/cla.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:

- name: "CLA Assistant"
if: ${{ steps.sign-or-recheck.outputs.match != '' || github.event_name == 'pull_request_target' }}
# Alpha Release
uses: cla-assistant/github-action@v2.1.1-beta

uses: cla-assistant/github-action@v2.6.0
env:
# Generated and maintained by github
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
73 changes: 73 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Release

on:
release:
types: [published]

jobs:

pre-build:
name: Update version in source code
runs-on: windows-latest
env:
NEW_VERSION: '${{ github.ref_name }}'
MANIFEST_FILE_PATH: "JfrogVSExtension/source.extension.vsixmanifest"

steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
ref: ${{ github.event.release.target_commitish }}

- name: Update VSIX Version in manifest file
run: .\scripts\UpdateVsixVersion.ps1
shell: pwsh

- name: Commit and push changes
run: |
git config --local user.name "${{ github.actor }}"
git config --local user.email "${{ github.actor }}@users.noreply.github.com"
git add .
git commit -m "Updated VSIX version to ${{ env.NEW_VERSION }}"
git push
call-build-workflow:
# build and package the vsix project
uses: ./.github/workflows/build-vsix.yml
with:
ref: ${{ github.event.release.target_commitish }}
needs: pre-build

release:
runs-on: windows-latest
needs: call-build-workflow
steps:
# download build workflow artifacts
- name: Download VSIX artifacts
uses: actions/download-artifact@v3
with:
name: vsix-artifacts
path: ./JFrogVSExtension/bin/Release

- name: Upload VSIX and attach it to the Release page
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./JFrogVSExtension/bin/Release/JFrogVSExtension.vsix
asset_name: JFrogVSExtension.vsix
asset_content_type: application/octet-stream

# upload the vsix and manifest files to Visual Studio Marketplace using VsixPublisher
- name: Publish to Visual Studio Marketplace
env:
# vsix publisher executable is already installed in the github windows runner at the following path
VSIX_PUBLISHER_PATH: "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VSSDK/VisualStudioIntegration/Tools/Bin/VsixPublisher.exe"
VSIX_PATH: "./JFrogVSExtension/bin/Release/JFrogVSExtension.vsix"
PUBLISH_MANIFEST_PATH: "./JFrogVSExtension/PublishManifest.json"
run: |
$Env:VSIX_PUBLISHER_PATH publish `
-payload $Env:VSIX_PATH `
-publishManifest $Env:PUBLISH_MANIFEST_PATH `
-personalAccessToken ${{ secrets.VS_MARKETPLACE_PAT }}
51 changes: 23 additions & 28 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,39 @@
name: Run Tests
name: Build and Run Tests

on:
push:
pull_request:
type: [ labeled ]
type: [ labeled ]

jobs:
build:
call-build-workflow:
uses: ./.github/workflows/build-vsix.yml
with:
ref: ${{ github.event.pull_request.head.sha }}

test:
runs-on: windows-latest
needs: call-build-workflow

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Setup MSBuild
uses: microsoft/setup-msbuild@v1
# download build workflow artifacts
- name: Download VSIX artifact
uses: actions/download-artifact@v3
with:
vs-version: 'latest'
name: vsix-artifacts
path: ./JFrogVSExtension/bin/Release

- name: Cache NuGet packages # optimizing the build process
uses: actions/cache@v3
- name: Download Unit Test artifacts
uses: actions/download-artifact@v3
with:
path: ~/.nuget/packages
key: nuget-${{ runner.os }}-${{ hashFiles('**/*.csproj') }}
restore-keys: nuget-${{ runner.os }}-

- name: Restore dependencies
run: |
dotnet restore
nuget restore
- name: Download JFrog CLI executable
env:
JFROG_CLI_VERSION: '2.67.0' # jfrog cli version can be changed here
run: .\JFrogVSExtension\Resources\DownloadJfrogCli.ps1
shell: pwsh

- name: Build VSIX Project # build the vsix project using multi-core compilation and parallel builds
run: msbuild JFrogVSExtension.sln /p:Configuration=Release /p:Platform="Any CPU" /p:BuildInParallel=true /m
name: tests-artifacts
path: ./UnitTestJfrogVSExtension/bin/Release

- name: Run MSTest Project # run tests in release mode with logs presentation
# run tests in release mode with logs presentation
- name: Run MSTest Project
run: dotnet test --no-build --configuration Release --logger "console;verbosity=detailed" ./UnitTestJfrogVSExtension/bin/Release/UnitTestJfrogVSExtension.dll

43 changes: 43 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Contribution Guide

## Guidelines
- If the existing tests do not already cover your changes, please add tests.

## Building the Sources

To build the plugin sources, please follow these steps:
1. Clone the code from git.
2. Download the [JFrog CLI executable](https://jfrog.com/getcli/) for Windows and place it under **$PROJECT_LOCATION\JFrogVSExtension\Resources**.
3. Open Visual Studio.
4. Open *Tools* --> *Get Tools and Features*

![alt](docs/images/getTools.png)

5. Select the *workloads* tab and scroll to the bottom for the *Other Toolsets* section. Install *Visual Studio extension development*. Read more about Visual Studio SDK [here](https://docs.microsoft.com/en-us/visualstudio/extensibility/installing-the-visual-studio-sdk?view=vs-2017).

![alt](docs/images/extension.png)

6. Once the installation is completed, re-open Visual Studio.
7. Click on *File* --> *Open* --> *Project/Solution* and navigate to the project root dir and select the sln file.
8. To build the project, click on *Build* tab --> *Build Solution*. The VSIX file will be created in the following location: **$PROJECT_LOCATION\bin\Release\JFrog.VSExtension.vsix**
9. If the build fails, please refer to the *Troublshooting Issues* section.

![alt](docs/images/build.png)

10. If you'd like to help us develop and enhance the extension, this step is for you.
To build and run the plugin following your code changes, click on *Debug* --> *Start Debugging*.

![alt](docs/images/debug.png)

## Run the tests
After build has finished successfuly, you can run the tests using:
1. Visual Studio Test Explorer - click on *Test* -> *Run All Tests*.
2. Command line interface - navigate to the tests folder /UnitTestJfrogVSExtension/bin/{Release/Debug} and then run the following command:
```bash
dotnet test .\UnitTestJfrogVSExtension.dll
```

## Troublshooting Issues
When openning the project in Visual Studio for the first time, the following error may appear : *"Fody.WeavingTask" task was not given a value for the required parameter "SolutionDir"*.

To fix this,close the solution and open it again. More information can be found [here](https://stackoverflow.com/questions/50225374/xamarinissues-with-fody-weavingtask-and-solutiondir)
14 changes: 14 additions & 0 deletions JFrogVSExtension/PublishManifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"$schema": "http://json.schemastore.org/vsix-publish",
"categories": [ "build", "coding" ], // The categories of the extension. Between 1 and 3 categories are required.
"identity": {
"internalName": "JFrog V2" // If not specified, we try to generate the name from the display name of the extension in the vsixmanifest file.
// Required if the display name is not the actual name of the extension.
},
"overview": "../README.md", // Path to the "readme" file that gets uploaded to the Marketplace. Required.
"priceCategory": "free", // Either "free", "trial", or "paid". Defaults to "free".
"publisher": "JFrog", // The name of the publisher. Required.
"private": false, // Specifies whether or not the extension should be public when uploaded. Defaults to false.
"qna": true, // Specifies whether or not the extension should have a Q&A section. Defaults to true.
"repo": "https://github.com/jfrog/jfrog-visual-studio-extension" // Not required.
}
46 changes: 23 additions & 23 deletions JFrogVSExtension/source.extension.vsixmanifest
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="JFrogVSExtension.c07afb03-9f9a-45e2-8e6f-78442325bb24" Version="2.0.1" Language="en-US" Publisher="JFrog" />
<DisplayName>JFrog V2</DisplayName>
<Description xml:space="preserve">Visual Studio extension to integrate with JFrog Xray for scanning solution components. </Description>
<Icon>Resources\Icon.png</Icon>
<PreviewImage>Resources\PreviewImage.png</PreviewImage>
</Metadata>
<Installation>
<InstallationTarget Version="[17.0,18.0)" Id="Microsoft.VisualStudio.Community">
<ProductArchitecture>amd64</ProductArchitecture>
</InstallationTarget>
</Installation>
<Dependencies>
<Dependency Id="Microsoft.Framework.NDP" DisplayName="Microsoft .NET Framework" d:Source="Manual" Version="[4.5,)" />
</Dependencies>
<Prerequisites>
<Prerequisite Id="Microsoft.VisualStudio.Component.CoreEditor" Version="[15.0,)" DisplayName="Visual Studio core editor" />
</Prerequisites>
<Assets>
<Asset Type="Microsoft.VisualStudio.ToolboxControl" d:Source="Project" d:ProjectName="%CurrentProject%" Path="|%CurrentProject%;PkgdefProjectOutputGroup|" />
<Asset Type="Microsoft.VisualStudio.VsPackage" d:Source="Project" d:ProjectName="%CurrentProject%" Path="|%CurrentProject%;PkgdefProjectOutputGroup|" />
</Assets>
</PackageManifest>
<Metadata>
<Identity Id="JFrogVSExtension.c07afb03-9f9a-45e2-8e6f-78442325bb24" Version="2.0.1" Language="en-US" Publisher="JFrog" />
<DisplayName>JFrog V2</DisplayName>
<Description xml:space="preserve">Visual Studio extension to integrate with JFrog Xray for scanning solution components. </Description>
<Icon>Resources\Icon.png</Icon>
<PreviewImage>Resources\PreviewImage.png</PreviewImage>
</Metadata>
<Installation>
<InstallationTarget Version="[17.0,18.0)" Id="Microsoft.VisualStudio.Community">
<ProductArchitecture>amd64</ProductArchitecture>
</InstallationTarget>
</Installation>
<Dependencies>
<Dependency Id="Microsoft.Framework.NDP" DisplayName="Microsoft .NET Framework" d:Source="Manual" Version="[4.5,)" />
</Dependencies>
<Prerequisites>
<Prerequisite Id="Microsoft.VisualStudio.Component.CoreEditor" Version="[15.0,)" DisplayName="Visual Studio core editor" />
</Prerequisites>
<Assets>
<Asset Type="Microsoft.VisualStudio.ToolboxControl" d:Source="Project" d:ProjectName="%CurrentProject%" Path="|%CurrentProject%;PkgdefProjectOutputGroup|" />
<Asset Type="Microsoft.VisualStudio.VsPackage" d:Source="Project" d:ProjectName="%CurrentProject%" Path="|%CurrentProject%;PkgdefProjectOutputGroup|" />
</Assets>
</PackageManifest>
33 changes: 1 addition & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,39 +42,8 @@ The icon demonstrates the top severity issue of a selected component and its tra
5. Click on *Download*
6. Once the installation is completed, re-open Visual Studio.

## Building the Sources

To build the plugin sources, please follow these steps:
1. Clone the code from git.
2. Download the [JFrog CLI executable](https://jfrog.com/getcli/) for Windows and place it under **$PROJECT_LOCATION\JFrogVSExtension\Resources**.
3. Open Visual Studio.
4. Open *Tools* --> *Get Tools and Features*

![alt](docs/images/getTools.png)

5. Select the *workloads* tab and scroll to the bottom for the *Other Toolsets* section. Install *Visual Studio extension development*. Read more about Visual Studio SDK [here](https://docs.microsoft.com/en-us/visualstudio/extensibility/installing-the-visual-studio-sdk?view=vs-2017).

![alt](docs/images/extension.png)

6. Once the installation is completed, re-open Visual Studio.
7. Click on *File* --> *Open* --> *Project/Solution* and navigate to the project root dir and select the sln file.
8. To build the project, click on *Build* tab --> *Build Solution*. The VSIX file will be created in the following location: **$PROJECT_LOCATION\bin\Release\JFrog.VSExtension.vsix**
9. If the build fails, please refer to the *Troublshooting Issues* section.

![alt](docs/images/build.png)

10. If you'd like to help us develop and enhance the extension, this step is for you.
To build and run the plugin following your code changes, click on *Debug* --> *Start Debugging*.

![alt](docs/images/debug.png)

## Troublshooting Issues
When openning the project in Visual Studio for the first time, the following error may appear : *"Fody.WeavingTask" task was not given a value for the required parameter "SolutionDir"*.

To fix this,close the solution and open it again. More information can be found [here](https://stackoverflow.com/questions/50225374/xamarinissues-with-fody-weavingtask-and-solutiondir)

## Release Notes
The release notes are available [here](RELEASE.md#release-notes).
The release notes are available [here](https://github.com/jfrog/jfrog-visual-studio-extension/releases).

## Code Contributions
We welcome community contribution through pull requests.
19 changes: 0 additions & 19 deletions RELEASE.md

This file was deleted.

Loading

0 comments on commit e460417

Please sign in to comment.