Created github distribution app

This commit is contained in:
unknown 2015-07-26 15:14:29 -06:00
parent 7dc8cd3c8a
commit e714d8ab2c
7 changed files with 238 additions and 0 deletions

View File

@ -10,9 +10,13 @@ copy /Y src\Jackett.Service\bin\Release\JackettService.exe build\JackettService.
copy /Y src\Jackett.Service\bin\Release\JackettService.exe.config build\JackettService.exe.config
copy /Y src\Jackett.Tray\bin\Release\JackettTray.exe build\JackettTray.exe
copy /Y src\Jackett.Tray\bin\Release\JackettTray.exe.config build\JackettTray.exe.config
copy /Y src\Jackett.Distribution\bin\Release\JackettDistribution.exe distributor.exe
copy /Y LICENSE build\LICENSE
copy /Y README.md build\README.md
cd build
del *.pdb
del *.xml
cd ..
iscc Installer.iss

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>

View File

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{99D893EC-1A8A-42A9-AC6B-FE047AFC32F0}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Jackett.Distribution</RootNamespace>
<AssemblyName>JackettDistribution</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Octokit, Version=0.14.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Octokit.0.14.0\lib\net45\Octokit.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -0,0 +1,116 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.IO.Compression;
using Octokit;
using Octokit.Internal;
namespace Jackett.Distribution
{
class Program
{
static readonly string repoOwner = "zone117x";
static readonly string repoName = "Jackett";
static readonly string buildZipFile = "JackettBuild.zip";
static readonly string installFile = Path.Combine("Output", "setup.exe");
static GitHubClient github;
static Version localVersion;
static void Main(string[] args)
{
if (args.Length == 0)
{
throw new Exception("Missing github API token argument");
}
var token = args[0];
github = new GitHubClient(new ProductHeaderValue("Jackett"));
github.Credentials = new Credentials(token);
localVersion = GetJackettVersion();
var latestReleaseVersion = LatestGithubRelease().Result;
if (localVersion <= latestReleaseVersion)
{
Console.WriteLine("Latest Github release is {0}, will not upload local version {1}", latestReleaseVersion, localVersion);
return;
}
Console.WriteLine("Zipping release build " + localVersion);
ZippingReleaseBuild();
UploadRelease().Wait();
}
static Version GetJackettVersion()
{
return new Version(5, 0, 1);
var assemblyVersion = AssemblyName.GetAssemblyName(Path.Combine("Build", "Jackett.dll")).Version;
return new Version(assemblyVersion.Major, assemblyVersion.Minor, assemblyVersion.Build);
}
static async Task<Version> LatestGithubRelease()
{
var releases = await github.Release.GetAll(repoOwner, repoName);
var latest = releases.Where(t => t.PublishedAt != null).OrderByDescending(t => t.TagName).FirstOrDefault();
var version = Version.Parse(latest.TagName.Replace("v", ""));
return version;
}
static void ZippingReleaseBuild()
{
if (File.Exists(buildZipFile))
File.Delete(buildZipFile);
ZipFile.CreateFromDirectory("Build", buildZipFile);
}
static async Task UploadRelease()
{
// get last master commit to tag
/*var masterBranch = await github.Repository.GetBranch(repoOwner, repoName, "master");
var lastCommit = masterBranch.Commit.Sha;
// create tag
var tagName = "v" + localVersion.ToString();
var tag = new NewTag
{
Message = "Tagging a new release of Jackett",
Tag = tagName,
Object = lastCommit,
Type = TaggedType.Commit,
Tagger = new SignatureResponse("DistributionBot", "zone117x@gmail.com", DateTime.UtcNow)
};
var tagResult = await github.GitDatabase.Tag.Create(repoOwner, repoName, tag);*/
// create release entry
var newRelease = new NewRelease("v" + localVersion.ToString());
newRelease.Name = "Beta Release";
newRelease.Body = "";
newRelease.Draft = true;
newRelease.Prerelease = false;
var releaseResult = await github.Release.Create(repoOwner, repoName, newRelease);
var buildZipAsset = new ReleaseAssetUpload()
{
FileName = string.Format("Jackett.v{0}.zip", localVersion),
ContentType = "application/zip",
RawData = File.OpenRead(buildZipFile)
};
var buildZipAssetResult = await github.Release.UploadAsset(releaseResult, buildZipAsset);
var installFileAsset = new ReleaseAssetUpload()
{
FileName = string.Format("Jackett.v{0}.Windows.Installer.exe", localVersion),
ContentType = "application/octet-stream",
RawData = File.OpenRead(installFile)
};
var installFileAssetResult = await github.Release.UploadAsset(releaseResult, installFileAsset);
}
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("JackettDistribution")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("JackettDistribution")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("99d893ec-1a8a-42a9-ac6b-fe047afc32f0")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Octokit" version="0.14.0" targetFramework="net452" />
</packages>

View File

@ -23,6 +23,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jackett.Tray", "Jackett.Tra
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jackett.Test", "Jackett.Test\Jackett.Test.csproj", "{E75D4F15-5DA3-4332-ADB1-28FB673DAE56}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jackett.Distribution", "Jackett.Distribution\Jackett.Distribution.csproj", "{99D893EC-1A8A-42A9-AC6B-FE047AFC32F0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -53,6 +55,10 @@ Global
{E75D4F15-5DA3-4332-ADB1-28FB673DAE56}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E75D4F15-5DA3-4332-ADB1-28FB673DAE56}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E75D4F15-5DA3-4332-ADB1-28FB673DAE56}.Release|Any CPU.Build.0 = Release|Any CPU
{99D893EC-1A8A-42A9-AC6B-FE047AFC32F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{99D893EC-1A8A-42A9-AC6B-FE047AFC32F0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{99D893EC-1A8A-42A9-AC6B-FE047AFC32F0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{99D893EC-1A8A-42A9-AC6B-FE047AFC32F0}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE