Skip to content

Commit

Permalink
Merge branch 'master' into Fix.Windows7
Browse files Browse the repository at this point in the history
  • Loading branch information
gerardog authored Feb 18, 2023
2 parents bb16b8b + cdbd385 commit b5d7c55
Show file tree
Hide file tree
Showing 11 changed files with 141 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
with:
fetch-depth: 0
- name: Install dependencies
run: choco install GitVersion.Portable ilmerge --confirm --no-progress
run: choco install GitVersion.Portable --version 5.6.11 --confirm --no-progress; choco install il-repack --confirm --no-progress
- name: Update project version
run: gitversion /l console /output buildserver /updateAssemblyInfo /verbosity minimal
- name: Get project version
Expand Down
30 changes: 29 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 GitVersion.Portable --version 5.6.11 --confirm --no-progress; 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 All @@ -124,6 +126,32 @@ jobs:
identifier: gerardog.gsudo
installers-regex: '\.msi$' # Only .msi files

publishNuget:
name: Push to Nuget
#if: github.ref == 'refs/heads/master' && github.repository == 'gerardog/gsudo'
if: github.repository == 'gerardog/gsudo'
runs-on: windows-latest
needs: [build, release]
permissions:
contents: write
environment:
name: release-nuget
env:
version: ${{ needs.build.outputs.version }}
version_MajorMinorPatch: ${{ needs.build.outputs.version_MajorMinorPatch }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/download-artifact@v3
with:
name: Binaries
path: ./artifacts
- name: Import Nuget Api Key
run: nuget setapikey ${{ secrets.NUGET_APIKEY }}
- name: Build Package for Nuget & Upload
run: ./build/06-release-Nuget.ps1

docs:
needs: publish
uses: ./.github/workflows/docs.yml
Expand Down
6 changes: 3 additions & 3 deletions build/00-prerequisites.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
choco install ilmerge
choco install il-repack
choco install GitVersion.Portable
choco install wixtoolset
choco install hub
choco install dotnet-7.0-sdk --pre

choco install dotnet-7.0-sdk
choco install NuGet.CommandLine
12 changes: 12 additions & 0 deletions build/01-build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,21 @@ dotnet publish .\src\gsudo\gsudo.csproj -c Release -o .\artifacts\arm64 -f net7
dotnet publish .\src\gsudo\gsudo.csproj -c Release -o .\artifacts\x64 -f net7.0 -r win-x64 --sc -p:PublishAot=true -p:IlcOptimizationPreference=Size -v minimal -p:WarningLevel=0 || $(exit $LASTEXITCODE)
"-- Building net7.0 win-x86"
dotnet publish .\src\gsudo\gsudo.csproj -c Release -o .\artifacts\x86 -f net7.0 -r win-x86 --sc -p:PublishReadyToRun=true -p:PublishSingleFile=true -v minimal -p:WarningLevel=0 || $(exit $LASTEXITCODE)
"-- Building net4.6 AnyCpu"
dotnet publish .\src\gsudo\gsudo.csproj -c Release -o .\artifacts\net46-AnyCpu\unmerged -f net46 -p:Platform=AnyCpu -v minimal -p:WarningLevel=0 || $(exit $LASTEXITCODE)

"-- Repacking net4.6 AnyCpu into a single EXE"

ilrepack .\artifacts\net46-AnyCpu\unmerged\gsudo.exe .\artifacts\net46-AnyCpu\unmerged\*.dll /out:.\artifacts\net46-AnyCpu\gsudo.exe /target:exe /targetplatform:v4 /ndebug /wildcards || $(exit $LASTEXITCODE)

if ($?) {
rm artifacts\net46-AnyCpu\unmerged -Recurse
echo "artifacts\net46-AnyCpu\unmerged -> ilmerge -> artifacts\net46-AnyCpu\"
}

cp .\src\gsudo.Wrappers\* .\artifacts\x86
cp .\src\gsudo.Wrappers\* .\artifacts\x64
cp .\src\gsudo.Wrappers\* .\artifacts\arm64
cp .\src\gsudo.Wrappers\* .\artifacts\net46-AnyCpu

popd
2 changes: 2 additions & 0 deletions build/03-sign.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ $files = @(
"artifacts\x64\*.p*1"
"artifacts\x86\*.exe",
"artifacts\x86\*.p*1",
"artifacts\net46-AnyCpu\*.exe",
"artifacts\net46-AnyCpu\*.p*1",
"artifacts\arm64\*.exe",
"artifacts\arm64\*.p*1"
) -join " "
Expand Down
2 changes: 1 addition & 1 deletion build/04-release-GitHub.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if ($env:version) {
Get-ChildItem .\artifacts\ -File | Remove-Item # Remove files on artifacts root
Get-ChildItem .\artifacts\ -Filter *.pdb -Recurse | Remove-Item # Remove *.pdb on subfolders

Compress-Archive -Path ./artifacts/x86,./artifacts/x64,./artifacts/arm64 -DestinationPath "artifacts/gsudo.v$($version).zip" -force -CompressionLevel Optimal
Compress-Archive -Path ./artifacts/x86,./artifacts/x64,./artifacts/arm64,./artifacts/net46-AnyCpu -DestinationPath "artifacts/gsudo.v$($version).zip" -force -CompressionLevel Optimal
(Get-FileHash artifacts\gsudo.v$($version).zip).hash > artifacts\gsudo.v$($version).zip.sha256

$msbuild = &"${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -prerelease -products * -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe
Expand Down
4 changes: 2 additions & 2 deletions build/05-release-Chocolatey.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ 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\..

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

if ($env:version) {
"- Getting version from env:version"
$version = $env:version
Expand Down
32 changes: 32 additions & 0 deletions build/06-release-Nuget.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
pushd $PSScriptRoot\..

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

if ($env:version) {
"- Getting version from env:version"
$version = $env:version
$version_MajorMinorPatch=$env:version_MajorMinorPatch
} else {
"- Getting version using GitVersion"
$version = $(gitversion /showvariable LegacySemVer)
$version_MajorMinorPatch=$(gitversion /showvariable MajorMinorPatch)
}
"- Using version number v$version / v$version_MajorMinorPatch"

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

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


"- 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.")

"`n- Uploading v$version to Nuget"
nuget push artifacts\nuget\gsudo.$($version).nupkg -Source https://api.nuget.org/v3/index.json || $(throw "Nuget push failed.")


"- Success"
popd
1 change: 0 additions & 1 deletion build/06-release-Scoop.ps1

This file was deleted.

56 changes: 56 additions & 0 deletions build/Nuget/gsudo.nuspec.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?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="any/any/gsudo/**/gsudo.exe" buildAction="None" copyToOutput="true" flatten="false"/>
</contentFiles>
</metadata>
<files>
<file src="..\..\artifacts\x64\gsudo.exe" target="contentFiles\any\any\gsudo\x64" />
<file src="..\..\artifacts\x86\gsudo.exe" target="contentFiles\any\any\gsudo\x86" />
<file src="..\..\artifacts\arm64\gsudo.exe" target="contentFiles\any\any\gsudo\arm64" />
<file src="..\..\artifacts\net46-anycpu\gsudo.exe" target="contentFiles\any\any\gsudo\net46-AnyCpu" />
</files>
</package>
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4772,9 +4772,9 @@ json-schema-traverse@^1.0.0:
integrity sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==

json5@^2.1.2, json5@^2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.1.tgz#655d50ed1e6f95ad1a3caababd2b0efda10b395c"
integrity sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==
version "2.2.3"
resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283"
integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==

jsonfile@^6.0.1:
version "6.1.0"
Expand Down

0 comments on commit b5d7c55

Please sign in to comment.