Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b6bea2f9 authored by Philipp Kewisch's avatar Philipp Kewisch
Browse files

Add releaser keys to automation setup and fix formatting

parent a89e79ec
Loading
Loading
Loading
Loading
+28 −10
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ CHANNEL_ENVIRONMENTS = {
                    "releaseTarget": "github|play",
                    # TODO enable this when ready to publish
                    # "playTargetTrack": "production",
                    "packageFormat": "apk"
                    "packageFormat": "apk",
                },
            ],
        },
@@ -67,7 +67,7 @@ CHANNEL_ENVIRONMENTS = {
                    "releaseTarget": "github|play",
                    # TODO enable this when ready to publish
                    # "playTargetTrack": "beta",
                    "packageFormat": "apk"
                    "packageFormat": "apk",
                },
            ],
        },
@@ -256,7 +256,7 @@ def create_github_environment(repo, environment_name, branches=None, approvers=N
            f"Failed to create environment {environment_name}. Response: {response.status_code}, {response.text}"
        )

    for branch in (branches or []):
    for branch in branches or []:
        url = f"https://api.github.com/repos/{repo}/environments/{environment_name}/deployment-branch-policies"
        data = {"name": branch, "type": "branch"}
        response = requests.post(url, headers=headers, json=data)
@@ -363,6 +363,7 @@ def create_signing_environment(repo, environment, branch, props_file):
            repo, secret_name, encrypted_value, key_id, environment
        )


def create_release_environment(repo, branches):
    environment = "publish_release"

@@ -379,6 +380,20 @@ def create_release_environment(repo, branches):
        repo, "PLAY_STORE_ACCOUNT", encrypted_play_account, key_id, environment
    )

    with open("thunderbird-mobile-gh-releaser-bot.pem") as fp:
        encrypted_releaser_key = encrypt_secret(public_key, fp.read())
    with open("thunderbird-mobile-gh-releaser-bot.clientid.txt") as fp:
        releaser_client_id = fp.read().strip()

    set_github_environment_secret(
        repo, "RELEASER_APP_PRIVATE_KEY", encrypted_releaser_key, key_id, environment
    )

    set_github_environment_variable(
        repo, "RELEASER_APP_CLIENT_ID", releaser_client_id, environment
    )


def main():
    # Argument parsing for positional inputs and repo flag
    parser = argparse.ArgumentParser(
@@ -436,7 +451,9 @@ def main():
        if environment_name not in includeset:
            continue

        create_github_environment(args.repo, environment_name, branches=[data["branch"]])
        create_github_environment(
            args.repo, environment_name, branches=[data["branch"]]
        )

        for name, value in data["variables"].items():
            if isinstance(value, dict) or isinstance(value, list):
@@ -460,5 +477,6 @@ def main():
    if "publish_release" in includeset:
        create_release_environment(args.repo, ["main", "beta", "release"])


if __name__ == "__main__":
    main()