Skip to content

Commit

Permalink
Sign apk (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperJMN authored Mar 31, 2024
1 parent da905bc commit 2a8885d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
6 changes: 5 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ steps:

- powershell: .\build.ps1 publishgithubrelease
env:
GitHubAuthenticationToken: $(GitHubAuthenticationToken)
GitHubAuthenticationToken: $(GitHubAuthenticationToken)
AndroidSigningKeyAlias: $(AndroidSigningKeyAlias)
AndroidSigningKeyPass: $(AndroidSigningKeyPass)
Base64Keystore: $(Base64Keystore)
AndroidSigningStorePass: $(AndroidSigningStorePass)
19 changes: 17 additions & 2 deletions build/Build.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Linq;
using Nuke.Common;
using Nuke.Common.IO;
Expand All @@ -16,7 +17,7 @@

class Build : NukeBuild
{
public static int Main() => Execute<Build>(x => x.PackDebian);
public static int Main() => Execute<Build>(x => x.PublishGitHubRelease);

public AbsolutePath OutputDirectory = RootDirectory / "output";
public AbsolutePath PublishDirectory => OutputDirectory / "publish";
Expand All @@ -26,7 +27,12 @@ class Build : NukeBuild
[Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")] readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.Release;
[GitVersion] readonly GitVersion GitVersion;
[GitRepository] readonly GitRepository Repository;
[Parameter("authtoken")] [Secret] readonly string GitHubAuthenticationToken;

[Parameter("GitHub Authentication Token")] [Secret] readonly string GitHubAuthenticationToken;
[Parameter("Contents of the keystore encoded as Base64.")] readonly string Base64Keystore;
[Parameter("The alias for the key in the keystore.")] readonly string AndroidSigningKeyAlias;
[Parameter("The password for the keystore file.")][Secret] readonly string AndroidSigningStorePass;
[Parameter("The password of the key within the keystore file.")] [Secret] readonly string AndroidSigningKeyPass;

Target Clean => td => td
.Executes(() =>
Expand Down Expand Up @@ -79,13 +85,22 @@ class Build : NukeBuild
.Executes(() =>
{
var androidProject = Solution.AllProjects.First(project => project.Name.EndsWith("Android"));
var keystore = OutputDirectory / "temp.keystore";
keystore.WriteAllBytes(Convert.FromBase64String(Base64Keystore));

DotNetPublish(settings => settings
.SetProperty("ApplicationVersion", GitVersion.CommitsSinceVersionSource)
.SetProperty("ApplicationDisplayVersion", GitVersion.MajorMinorPatch)
.SetProperty("AndroidKeyStore", "true")
.SetProperty("AndroidSigningKeyStore", keystore)
.SetProperty("AndroidSigningKeyAlias", AndroidSigningKeyAlias)
.SetProperty("AndroidSigningStorePass", AndroidSigningStorePass)
.SetProperty("AndroidSigningKeyPass", AndroidSigningKeyPass)
.SetConfiguration(Configuration)
.SetProject(androidProject)
.SetOutput(PackagesDirectory));

keystore.DeleteFile();
});


Expand Down

0 comments on commit 2a8885d

Please sign in to comment.