Skip to content

Commit

Permalink
ci: added Windows deploy scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
JaCzekanski committed Jul 29, 2019
1 parent aa757bd commit fcc82fc
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ environment:
TOOLSET: vs2017
platform: x64

# TODO: Move to PowerShell script
before_build:
- git submodule update --init --recursive

Expand All @@ -43,10 +44,16 @@ configuration:
build:
project: avocado.sln

# TODO: Move to PowerShell script
after_build:
# Premake renames x86 to Win32 - undo that
- ps: if ($env:platform -eq "Win32") { $env:platform = "x86" }

- ps: $env:OS=$env:platform
- ps: $env:DATE=date +%Y%m%d
- ps: $env:COMMIT=git rev-parse --short=7 HEAD
- ps: $env:ARTIFACT="avocado-$($env:OS)-$($env:DATE)-$($env:COMMIT)"

- mkdir artifact

# copy avocado.exe, SDL2.dll and data directory
Expand All @@ -64,6 +71,9 @@ after_build:
# make zip archive
- 7z a avocado.zip %APPVEYOR_BUILD_FOLDER%\artifact\.

- mkdir upload
- ps: Copy-Item avocado.zip -Destination upload/$env:ARTIFACT

test_script:
- .\%TARGETDIR%\avocado_test.exe --success -r junit > test-result.xml || ver > nul

Expand All @@ -81,3 +91,6 @@ on_failure:
artifacts:
- path: avocado.zip
name: avocado

deploy_script:
- ps: ./.appveyor/deploy.ps1 $env:DEPLOY_KEY upload/
39 changes: 39 additions & 0 deletions .appveyor/deploy.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
$API_KEY=$args[0]
$FILE=$args[1]

if (!$API_KEY -Or !$FILE) {
Write-Output "usage: $($MyInvocation.MyCommand.Name) <API_KEY> <FILE>"
Exit 1
}

$FILES=""

If (Test-Path -Path "$FILE" -PathType Leaf) {
$FILES="-F file=@`"$FILE`""
} ElseIf (Test-Path -Path "$FILE" -PathType Container) {

Get-ChildItem "$FILE" | Foreach-Object {
$name = $_.FullName
$FILES="$FILES -F file[]=@`"$name`""
}

} Else {
Write-Output "$FILE does not exist"
Exit 2
}

$REVISION="$(git rev-parse --short=7 HEAD)"
$BRANCH=$env:APPVEYOR_REPO_BRANCH
$AUTHOR="$(git log -1 "$REVISION" --pretty="%aN")"
$MESSAGE="$(git log -1 "$REVISION" --pretty="%s")"
$DATE="$(git log -1 "$REVISION" --pretty="%aI")"

curl -X POST `
-H "Authorization: Bearer $API_KEY" `
-H "X-Commit-Revision: $REVISION" `
-H "X-Commit-Branch: $BRANCH" `
-H "X-Commit-Author: $AUTHOR" `
-H "X-Commit-Message: $MESSAGE" `
-H "X-Commit-Date: $DATE" `
$FILES -L `
https://avocado-builds.czekanski.info/api/upload

0 comments on commit fcc82fc

Please sign in to comment.