Skip to content

Commit

Permalink
add choco artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
r-Larch committed Oct 19, 2019
1 parent a2d5676 commit 49808d0
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 71 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ You can find the latest release here:
You can install MouseTrap with **chocolatey**:
```Powershell
# install the package
choco install mousetrap --version 1.0.1
choco install mousetrap --version 1.0.2
# running it
mousetrap
Expand All @@ -39,7 +39,7 @@ Right-clicking the icon shows some options:
Option | Description
-------------|------------------------------------------------------------------
**Settings** | allows you to configure it
Reinit | **[alpha-option]** to reinitialize it, in case it hangs :worried:
Reinit | **[beta-option]** to reinitialize it, in case it hangs :worried:
**Exit** | to close the running instance
_NOTE: reinit can be triggered by commandline:_ `mousetrap --reinit`
Expand Down
36 changes: 28 additions & 8 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ configuration: Release
platform: Any CPU
skip_tags: true # to prevent a endless build loop

environment:
choco_api_token:
secure: Rym1kbOorVRtBplky8zDAaWiNA3MnD48MoL5SboGtQPXqVJZVXJrytFD0AtwVqID

before_build:
- cmd: nuget restore

Expand All @@ -19,18 +23,34 @@ build:
verbosity: minimal
project: MouseTrap.sln

after_build:
- ps: .\build\Build-Release.ps1 $env:appveyor_build_version

artifacts:
- path: MouseTrap\bin\*.exe
- path: MouseTrap\bin\*.nupkg

deploy:
release: v$(appveyor_build_version)
# description: 'Release description'
provider: GitHub
- provider: GitHub
release: v$(appveyor_build_version)-beta
prerelease: true
draft: false
description: >
MouseTrap.exe is a portable executable.
Download and copy it to some save place (were you don't delete it by mistake)
and double click it to run.
[Documentation + Help](https://github.com/r-Larch/MouseTrap/blob/master/README.md)
![#f03c15](https://placehold.it/15/f03c15/000000?text=+) Please Note!!
> The **MouseTrap.exe is not signed!** Because Code signing certificates cost a lot of money.
So in case you get some "Windows protected your PC" warning, just hit "more infos" and then "Run anyway".
Or download the Source Code and Build it on your own.
auth_token:
secure: zYHtyBs13JvlzMOq5tFTt6qCGLGBKEBNGK0Ho/c9ZsuknYU5M62uYMymS66cxgDH
# artifact: /.*\.nupkg/ # upload all NuGet packages to release assets
draft: false
prerelease: false
# artifact: /*\.exe/
on:
branch: master # release from master branch only
# APPVEYOR_REPO_TAG: true # deploy on tag push only
branch: master

after_deploy:
- ps: choco push $(Resolve-Path $env:appveyor_build_folder\MouseTrap\bin\*.nupkg).ToString() --source https://push.chocolatey.org/ --key $env:choco_api_token
124 changes: 63 additions & 61 deletions build/Build-Release.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,38 +29,38 @@ $AssemblyInfo = [System.IO.Path]::Combine($ProjectRoot, "Properties/AssemblyInfo
$GithubGetRepoApi = "https://api.github.com/repos/r-Larch/MouseTrap";

function Main() {

# auto commit ? =============================

if ([Git]::HasStagedChanges()) {
[Git]::ShowStaged();
if ([UI]::Comfirm("you have staged changes! Do you wand to auto commit them?") -eq $false) {
[Git]::Discard($AssemblyInfo);
[Git]::Discard($chocoNuspec);
[UI]::ThrowError("Please commit your staged changes first");
}
}

if ([Git]::HasUnstagedChanges()) {
[Git]::ShowUnstaged();
if ([UI]::Comfirm("you have unstaged changes! Do you wand to auto commit them?") -eq $false) {
[UI]::ThrowError("Please commit your unstaged changes first");
}
else {
[Git]::Stage("*");
}
}
#if ([Git]::HasStagedChanges()) {
# [Git]::ShowStaged();
# if ([UI]::Comfirm("you have staged changes! Do you wand to auto commit them?") -eq $false) {
# [Git]::Discard($AssemblyInfo);
# [Git]::Discard($chocoNuspec);
# [UI]::ThrowError("Please commit your staged changes first");
# }
#}

#if ([Git]::HasUnstagedChanges()) {
# [Git]::ShowUnstaged();
# if ([UI]::Comfirm("you have unstaged changes! Do you wand to auto commit them?") -eq $false) {
# [UI]::ThrowError("Please commit your unstaged changes first");
# }
# else {
# [Git]::Stage("*");
# }
#}


# version number =============================

[Git]::Stage($AssemblyInfo); # backup
if ([string]::IsNullOrEmpty($ReleaseVersionNumber)) {
$ReleaseVersionNumber = GetVersion $AssemblyInfo;
}
else {
SetVersion $AssemblyInfo $ReleaseVersionNumber;
}
#[Git]::Stage($AssemblyInfo); # backup
#if ([string]::IsNullOrEmpty($ReleaseVersionNumber)) {
# $ReleaseVersionNumber = GetVersion $AssemblyInfo;
#}
#else {
# SetVersion $AssemblyInfo $ReleaseVersionNumber;
#}


# Git tags and history =============================
Expand All @@ -72,7 +72,7 @@ function Main() {

# update .nuspec =============================

[Git]::Stage($chocoNuspec); # backup
# [Git]::Stage($chocoNuspec); # backup
$repo = $(Invoke-Webrequest $GithubGetRepoApi).Content | ConvertFrom-Json;
$topics = $(Invoke-Webrequest $GithubGetRepoApi/topics -Headers @{'Accept'='application/vnd.github.mercy-preview+json'}).Content | ConvertFrom-Json
$xml = [xml] $(gc -Path $chocoNuspec -Encoding UTF8);
Expand All @@ -89,47 +89,47 @@ function Main() {
# $xml.package.metadata.docsUrl = ;
# $xml.package.metadata.iconUrl = ;
$xml.Save($chocoNuspec);


# commit changes =============================

[Git]::Stage($AssemblyInfo);
[Git]::Stage($chocoNuspec);
#[Git]::Stage($AssemblyInfo);
#[Git]::Stage($chocoNuspec);

if ([Git]::HasTag($tag)) {
if ([Git]::HasStagedChanges()) {
[Git]::RemoveTag($tag);
[Git]::Commit("Update $tag");
[Git]::AddTag($tag);
}
}
else {
if ([Git]::HasStagedChanges()) {
[Git]::Commit("Release $tag");
}
[Git]::AddTag($tag);
}
#if ([Git]::HasTag($tag)) {
# if ([Git]::HasStagedChanges()) {
# [Git]::RemoveTag($tag);
# [Git]::Commit("Update $tag");
# [Git]::AddTag($tag);
# }
#}
#else {
# if ([Git]::HasStagedChanges()) {
# [Git]::Commit("Release $tag");
# }
# [Git]::AddTag($tag);
#}


# Build =============================

BuildSolution $SolutionFile "Release" $OutputDir;
$exacutable = [System.IO.Path]::Combine($OutputDir, "MouseTrap.exe")
# BuildSolution $SolutionFile "Release" $OutputDir;
# $exacutable = [System.IO.Path]::Combine($OutputDir, "MouseTrap.exe")
# SignExecutable $exacutable "[email protected]";
Copy-Item $exacutable "$DistFolder\MouseTrap.$ReleaseVersionNumber.exe";
# Copy-Item $exacutable "$DistFolder\MouseTrap.$ReleaseVersionNumber.exe";
# Zip $OutputDir "$DistFolder\MouseTrap.$ReleaseVersionNumber.zip";


# choco =============================

ChocoPack $chocoNuspec $DistFolder;
ChocoPack $chocoNuspec $OutputDir;


# commit results =============================

[Git]::Stage("$DistFolder\MouseTrap.$ReleaseVersionNumber.exe");
[Git]::Stage("$DistFolder\MouseTrap.$ReleaseVersionNumber.nupkg");
[Git]::Commit("$tag binarys");
#[Git]::Stage("$DistFolder\MouseTrap.$ReleaseVersionNumber.exe");
#[Git]::Stage("$DistFolder\MouseTrap.$ReleaseVersionNumber.nupkg");
#[Git]::Commit("$tag binarys");


# cleanup =============================
Expand All @@ -139,7 +139,7 @@ function Main() {


function ChocoPack([string] $nuspec, [string] $nupkg) {

if (!$(Get-Command choco -errorAction SilentlyContinue)) {
Write-Host "Install chocolatey";
iwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex
Expand All @@ -151,16 +151,18 @@ function ChocoPack([string] $nuspec, [string] $nupkg) {
throw "The choco pack process returned an error code."
}

$xml = [xml] $(gc -Path $chocoNuspec -Encoding UTF8);
$name = $xml.package.metadata.id + "." + $xml.package.metadata.version + ".nupkg";
$file = [System.IO.Path]::Combine($nupkg, $name);
#$xml = [xml] $(gc -Path $chocoNuspec -Encoding UTF8);
#$name = $xml.package.metadata.id + "." + $xml.package.metadata.version + ".nupkg";
#$file = [System.IO.Path]::Combine($nupkg, $name);

if ([UI]::Ask("Enter 'choco push' to publish '$name':", "choco push")) {
& choco push $file;
if (-not $?) {
throw "The publish process returned an error code."
}
}
# Push-AppveyorArtifact $file;

# if ([UI]::Ask("Enter 'choco push' to publish '$name':", "choco push")) {
# & choco push $file;
# if (-not $?) {
# throw "The publish process returned an error code."
# }
# }
}


Expand Down Expand Up @@ -277,7 +279,7 @@ class UI {

function SignExecutable([string] $executable, [string] $subjectName) {
# Code signing, works on my machine but probably not very portable
# Use the following command to create a self-signed cert to build a signed version of the WACS executable
# Use the following command to create a self-signed cert to build a signed version of the WACS executable
# New-SelfSignedCertificate `
# -CertStoreLocation cert:\currentuser\my `
# -Subject "CN=WACS" `
Expand Down
Binary file removed dist/MouseTrap.1.0.0.exe
Binary file not shown.
Binary file removed dist/MouseTrap.1.0.0.nupkg
Binary file not shown.
Binary file removed dist/MouseTrap.1.0.1.exe
Binary file not shown.
Binary file removed dist/MouseTrap.1.0.1.nupkg
Binary file not shown.

0 comments on commit 49808d0

Please sign in to comment.