Skip to content

Commit

Permalink
feat(pedm): add Nuget build, fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
kbouchard-dev authored and awakecoding committed Aug 13, 2024
1 parent 6c18ff1 commit 40835a3
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 44 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/publish-libraries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,16 @@ jobs:
strategy:
fail-fast: false
matrix:
library: [ dotnet-client, dotnet-subscriber, utils ]
library: [ dotnet-client, dotnet-subscriber, utils, pedm-dotnet-client ]
include:
- library: dotnet-client
libpath: ./devolutions-gateway/openapi/dotnet-client
- library: dotnet-subscriber
libpath: ./devolutions-gateway/openapi/dotnet-subscriber
- library: utils
libpath: ./utils/dotnet
- library: pedm-dotnet-client
libpath: ./crates/devolutions-pedm/openapi/dotnet-client

steps:
- name: Check out ${{ github.repository }}
Expand All @@ -62,8 +64,8 @@ jobs:
& "$Path/build.ps1"
New-Item -ItemType "directory" -Path . -Name "nuget-packages"
Get-ChildItem -Path $Path -Recurse *.nupkg | ForEach { Copy-Item $_ "./nuget-packages" }
Get-ChildItem -Path $Path -Recurse *.snupkg | ForEach { Copy-Item $_ "./nuget-packages" }
Get-ChildItem -Path $Path -Recurse -Include '*.nupkg' | ForEach { Copy-Item $_ "./nuget-packages" }
Get-ChildItem -Path $Path -Recurse -Include '*.snupkg' | ForEach { Copy-Item $_ "./nuget-packages" }
- name: Upload packages
uses: actions/upload-artifact@v4
Expand Down
8 changes: 7 additions & 1 deletion crates/devolutions-pedm-shared/src/build.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
use std::env;
use std::ffi::OsString;
use std::io::{Error, ErrorKind, Result};
use std::path::PathBuf;

pub fn target_dir() -> Result<PathBuf> {
let mut dir = PathBuf::from(env::var("OUT_DIR").unwrap());

let target_dirs = [OsString::from(env::var("TARGET").unwrap()), OsString::from("target")];

loop {
if dir.file_name().is_some_and(|f| *f == *env::var("PROFILE").unwrap()) {
if dir
.parent()
.is_some_and(|f| f.file_name().is_some_and(|f| target_dirs.iter().any(|x| x == f)))
{
return Ok(dir);
} else if !dir.pop() {
return Err(Error::new(ErrorKind::NotFound, "Target path not found"));
Expand Down
12 changes: 4 additions & 8 deletions crates/devolutions-pedm-shared/src/policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,16 +325,14 @@ pub struct ElevationConfigurations {
#[repr(transparent)]
#[derive(Serialize, Deserialize, JsonSchema, Debug, PartialEq, Eq, Hash, Clone)]
#[serde(try_from = "String")]
pub struct Id {
id: String,
}
pub struct Id(String);

impl Id {
pub fn try_new(id: String) -> anyhow::Result<Self> {
let pat = Regex::new(ID_PATTERN)?;

pat.is_match(&id)
.then(|| Id { id })
.then(|| Id(id))
.ok_or_else(|| anyhow::anyhow!("Invalid ID"))
}
}
Expand All @@ -349,7 +347,7 @@ impl TryFrom<String> for Id {

impl fmt::Display for Id {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.id.fmt(f)
self.0.fmt(f)
}
}

Expand Down Expand Up @@ -379,9 +377,7 @@ impl Identifiable for Profile {
impl Default for Profile {
fn default() -> Self {
Self {
id: Id {
id: "default".to_owned(),
},
id: Id("default".to_owned()),
name: "Unnamed profile".to_owned(),
elevation_method: ElevationMethod::LocalAdmin,
elevation_settings: ElevationConfigurations::default(),
Expand Down
6 changes: 0 additions & 6 deletions crates/devolutions-pedm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ edition = "2021"
license = "MIT/Apache-2.0"
authors = ["Devolutions Inc. <[email protected]>"]
description = "Devolutions Agent PEDM module"
build = "build.rs"
publish = false

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down Expand Up @@ -39,10 +38,5 @@ tower-http = { version = "0.5.2", features = ["timeout"] }
parking_lot = "0.12.3"
cfg-if = "1.0.0"

[build-dependencies]
devolutions-pedm-shared = { path = "../devolutions-pedm-shared", features = ["build", "policy"] }
schemars = "0.8.21"
serde_json = "1.0.124"

[lints]
workspace = true
19 changes: 0 additions & 19 deletions crates/devolutions-pedm/build.rs

This file was deleted.

2 changes: 1 addition & 1 deletion crates/devolutions-pedm/openapi/dotnet-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ No description provided (generated by Openapi Generator https://github.com/opena
This C# SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:

- API version:
- SDK version: 2024.7.5
- SDK version: 2024.8.13
- Generator version: 7.7.0
- Build package: org.openapitools.codegen.languages.CSharpClientCodegen

Expand Down
10 changes: 10 additions & 0 deletions crates/devolutions-pedm/openapi/dotnet-client/build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/env pwsh

$ErrorActionPreference = "Stop"

Push-Location -Path $PSScriptRoot

dotnet build --configuration Release
dotnet pack --configuration Release

Pop-Location
2 changes: 1 addition & 1 deletion crates/devolutions-pedm/openapi/dotnet-client/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"packageAuthors": "Devolutions Inc.",
"packageName": "Devolutions.Pedm.Client",
"packageTitle": "Devolutions PEDM REST API Client",
"packageVersion": "2024.7.5",
"packageVersion": "2024.8.13",
"packageDescription": "Client for Devolutions PEDM REST API",
"packageGuid": "0eb49e08-5842-4a2e-a5ac-926e6dd65c15",
"packageCopyright": "© Devolutions Inc. All rights reserved.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class Configuration : IReadableConfiguration
/// Version of the package.
/// </summary>
/// <value>Version of the package.</value>
public const string Version = "2024.7.5";
public const string Version = "2024.8.13";

/// <summary>
/// Identifier for ISO 8601 DateTime Format
Expand Down Expand Up @@ -116,7 +116,7 @@ public class Configuration : IReadableConfiguration
public Configuration()
{
Proxy = null;
UserAgent = WebUtility.UrlEncode("OpenAPI-Generator/2024.7.5/csharp");
UserAgent = WebUtility.UrlEncode("OpenAPI-Generator/2024.8.13/csharp");
BasePath = "http://localhost";
DefaultHeaders = new ConcurrentDictionary<string, string>();
ApiKey = new ConcurrentDictionary<string, string>();
Expand Down Expand Up @@ -539,7 +539,7 @@ public static string ToDebugReport()
report += " OS: " + System.Environment.OSVersion + "\n";
report += " .NET Framework Version: " + System.Environment.Version + "\n";
report += " Version of the API: \n";
report += " SDK Package Version: 2024.7.5\n";
report += " SDK Package Version: 2024.8.13\n";

return report;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<Description>Client for Devolutions PEDM REST API</Description>
<Copyright>© Devolutions Inc. All rights reserved.</Copyright>
<RootNamespace>Devolutions.Pedm.Client</RootNamespace>
<Version>2024.7.5</Version>
<Version>2024.8.13</Version>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\Devolutions.Pedm.Client.xml</DocumentationFile>
<RepositoryUrl>https://github.com/Devolutions/devolutions-gateway.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
Expand Down
2 changes: 1 addition & 1 deletion crates/devolutions-pedm/openapi/pedm-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ components:
MaximumSeconds: 0
$ref: '#/components/schemas/ElevationConfigurations'
Id:
default: ''
default: default
$ref: '#/components/schemas/Id'
Name:
default: Unnamed profile
Expand Down

0 comments on commit 40835a3

Please sign in to comment.