Skip to content

Commit

Permalink
Publish to NuGet
Browse files Browse the repository at this point in the history
  • Loading branch information
gerardog committed Feb 17, 2023
1 parent ea4a4b6 commit d7a2b16
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 6 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
contents: write
steps:
- name: Install dependencies
run: choco install GitVersion.Portable wixtoolset --confirm --no-progress
run: choco install NuGet.CommandLine GitVersion.Portable wixtoolset --confirm --no-progress
- uses: actions/checkout@v2
with:
fetch-depth: 0
Expand Down Expand Up @@ -110,6 +110,8 @@ jobs:
path: ./artifacts
- name: Import Chocolatey Api Key
run: choco apikey --key ${{ secrets.CHOCOLATEY_APIKEY }} --source https://push.chocolatey.org/
- name: Import Nuget Api Key
run: nuget setapikey ${{ secrets.NUGET_APIKEY }}
- name: Build Package for Chocolatey & Upload
run: ./build/05-release-Chocolatey.ps1
- name: Upload build artifacts
Expand Down
18 changes: 13 additions & 5 deletions build/05-release-Chocolatey.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ if (! (Test-IsAdmin)) {
throw "Must be admin to properly test generated package"
}

Get-Item .\artifacts\x64\gsudo.exe > $null || $(throw "Missing binaries/artifacts")
pushd $PSScriptRoot\..

pushd $PSScriptRoot\..
Get-Item .\artifacts\x64\gsudo.exe > $null || $(throw "Missing binaries/artifacts")

if ($env:version) {
"- Getting version from env:version"
Expand All @@ -21,8 +21,9 @@ if ($env:version) {
}
"- Using version number v$version / v$version_MajorMinorPatch"

"- Cleaning Choco template folder"
"- Cleaning Choco & Nuget template folder"
git clean .\Build\Chocolatey\gsudo -xf
git clean .\Build\Nuget\gsudo -xf

"- Adding Artifacts"
cp artifacts\x?? .\Build\Chocolatey\gsudo\tools -Recurse -Force -Exclude *.pdb
Expand All @@ -33,6 +34,8 @@ Get-ChildItem .\build\Chocolatey\gsudo\tools\ -Recurse -Filter *.exe | % { ni "$
# Generate Tools\VERIFICATION.txt
Get-Content .\Build\Chocolatey\verification.txt.template | Out-File -encoding UTF8 .\Build\Chocolatey\gsudo\Tools\VERIFICATION.txt

(Get-Content Build\Nuget\gsudo.nuspec.template) -replace '#VERSION#', "$version" | Out-File -encoding UTF8 .\Build\Nuget\gsudo.nuspec

"- Calculating Hashes "

@"
Expand All @@ -47,7 +50,11 @@ Get-childitem *.bak -Recurse | Remove-Item
mkdir Artifacts\Chocolatey -Force > $null
& choco pack .\Build\Chocolatey\gsudo\gsudo.nuspec -outdir="$((get-item Artifacts\Chocolatey).FullName)" || $(throw "Choco pack failed.")

"- Testing package"
"- Packing v$version to nuget"
mkdir Artifacts\Nuget -Force > $null
& nuget pack .\Build\Nuget\gsudo.nuspec -OutputDirectory "$((get-item Artifacts\Nuget).FullName)" || $(throw "Nuget pack failed.")

"- Testing choco package"
if (choco list -lo | Where-object { $_.StartsWith("gsudo") }) {
choco upgrade gsudo --failonstderr -s Artifacts\Chocolatey -f -pre --confirm || $(throw "Choco upgrade failed.")
} else {
Expand All @@ -57,7 +64,8 @@ if (choco list -lo | Where-object { $_.StartsWith("gsudo") }) {
if($(choco apikey).Count -lt 2) { throw "Missing Chocolatey ApiKey. Use: choco apikey -k <your key here> -s https://push.chocolatey.org/" }

"`n- Uploading v$version to chocolatey"
choco push artifacts\Chocolatey\gsudo.$($version).nupkg || $(throw "Choco push failed.")
:: choco push artifacts\Chocolatey\gsudo.$($version).nupkg || $(throw "Choco push failed.")


"- Success"
popd
55 changes: 55 additions & 0 deletions build/Nuget/gsudo.nuspec.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Do not remove this test for UTF-8: if “Ω” doesn’t appear as greek uppercase omega letter enclosed in quotation marks, you should use an editor that supports UTF-8, not this one. -->
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata>
<!-- == PACKAGE SPECIFIC SECTION == -->
<!-- This section is about this package, although id and version have ties back to the software -->
<!-- id is lowercase and if you want a good separator for words, use '-', not '.'. Dots are only acceptable as suffixes for certain types of packages, e.g. .install, .portable, .extension, .template -->
<!-- If the software is cross-platform, attempt to use the same id as the debian/rpm package(s) if possible. -->
<id>gsudo</id>
<!-- version should MATCH as closely as possible with the underlying software -->
<!-- Is the version a prerelease of a version? https://docs.nuget.org/create/versioning#creating-prerelease-packages -->
<!-- Note that unstable versions like 0.0.1 can be considered a released version, but it's possible that one can release a 0.0.1-beta before you release a 0.0.1 version. If the version number is final, that is considered a released version and not a prerelease. -->
<version>#VERSION#</version>
<owners>Gerardo Grignoli</owners>
<!-- ============================== -->

<!-- == SOFTWARE SPECIFIC SECTION == -->
<!-- This section is about the software itself -->
<title>gsudo - a sudo for windows</title>
<authors>Gerardo Grignoli &amp; GitHub contributors</authors>
<!-- projectUrl is required for the community feed -->
<!--<iconUrl>http://cdn.rawgit.com/gerardog/master/icons/gsudo.png</iconUrl>-->
<copyright>2023 Gerardo Grignoli</copyright>
<licenseUrl>https://opensource.org/licenses/MIT</licenseUrl>
<description>
`gsudo` allows to run commands with elevated permissions within the current console.
It is a `sudo` equivalent for Windows, with a similar user-experience as the original *nix sudo.

Elevated commands are shown in the caller (non-elevated) console, no switching to another console required.

http://github.com/gerardog/gsudo

### Usage

```gsudo [command] [arguments]```
Executes the specified command, elevated, and returns.

Examples

```gsudo notepad c:\Windows\System32\drivers\etc\hosts```
```gsudo cmd```

</description>
<releaseNotes>http://github.com/gerardog/gsudo/releases/v#VERSION#</releaseNotes>

<contentFiles>
<files include="gsudo.exe" buildAction="None" copyToOutput="true"/>
</contentFiles>
</metadata>
<files>
<file src="..\..\artifacts\x64\gsudo.exe" target="x64" />
<file src="..\..\artifacts\x86\gsudo.exe" target="x86" />
<file src="..\..\artifacts\net46-anycpu\gsudo.exe" target="AnyCpu" />
</files>
</package>

0 comments on commit d7a2b16

Please sign in to comment.