Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow adding additional assets #230

Merged
merged 2 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/usage/cli_package.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ optional arguments:
changes made by qgis-plugin-ci.
-d --disable-submodule-update
If omitted, a git submodule is updated. If specified, git submodules will not be updated/initialized before packaging.

-a ASSET_PATH, --asset-path ASSET_PATH
An additional asset path to add. Can be specified multiple times.
```

## Additional metadata
Expand Down
2 changes: 2 additions & 0 deletions docs/usage/cli_release.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ options:
--alternative-repo-url ALTERNATIVE_REPO_URL
The URL of the endpoint to publish the plugin (defaults to
plugins.qgis.org)
-a ASSET_PATH, --asset-path ASSET_PATH
An additional asset path to add. Can be specified multiple times.
--osgeo-username OSGEO_USERNAME
The Osgeo user name to publish the plugin.
--osgeo-password OSGEO_PASSWORD
Expand Down
14 changes: 14 additions & 0 deletions qgispluginci/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ def cli():
action="store_true",
help="If omitted, a git submodule is updated. If specified, git submodules will not be updated/initialized before packaging.",
)
package_parser.add_argument(
"-a",
"--asset-path",
action="append",
help="An additional asset path to add. Can be specified multiple times.",
)

# changelog
changelog_parser = subparsers.add_parser(
Expand Down Expand Up @@ -113,6 +119,12 @@ def cli():
action="store_true",
help="If omitted, a git submodule is updated. If specified, git submodules will not be updated/initialized before packaging.",
)
release_parser.add_argument(
"-a",
"--asset-path",
action="append",
help="An additional asset path to add. Can be specified multiple times.",
)
release_parser.add_argument(
"--alternative-repo-url",
help="The URL of the endpoint to publish the plugin (defaults to plugins.qgis.org)",
Expand Down Expand Up @@ -188,6 +200,7 @@ def cli():
allow_uncommitted_changes=args.allow_uncommitted_changes,
plugin_repo_url=args.plugin_repo_url,
disable_submodule_update=args.disable_submodule_update,
asset_paths=args.asset_path,
)

# RELEASE
Expand All @@ -204,6 +217,7 @@ def cli():
osgeo_password=args.osgeo_password,
allow_uncommitted_changes=args.allow_uncommitted_changes,
disable_submodule_update=args.disable_submodule_update,
asset_paths=args.asset_path,
)

# TRANSLATION PULL
Expand Down
9 changes: 9 additions & 0 deletions qgispluginci/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from glob import glob
from pathlib import Path
from tempfile import mkstemp
from typing import List

import git
from github import Github, GithubException
Expand Down Expand Up @@ -54,6 +55,7 @@ def create_archive(
is_prerelease: bool = False,
raise_min_version: str = None,
disable_submodule_update: bool = False,
asset_paths: List[str] = [],
):
repo = git.Repo()

Expand Down Expand Up @@ -226,6 +228,11 @@ def create_archive(
logger.debug(f"\tAdding resource: {file}")
# https://stackoverflow.com/a/48462950/1548052
tt.add(file)
# Add assets
if len(asset_paths) > 0:
with tarfile.open(top_tar_file, mode="a") as tt:
for asset_path in asset_paths:
tt.add(asset_path)

# converting to ZIP
# why using TAR before? because it provides the prefix and makes things easier
Expand Down Expand Up @@ -477,6 +484,7 @@ def release(
allow_uncommitted_changes: bool = False,
plugin_repo_url: str = None,
disable_submodule_update: bool = False,
asset_paths: List[str] = [],
):
"""

Expand Down Expand Up @@ -547,6 +555,7 @@ def release(
allow_uncommitted_changes=allow_uncommitted_changes,
is_prerelease=is_prerelease,
disable_submodule_update=disable_submodule_update,
asset_paths=asset_paths,
)

# if pushing to QGIS repo and pre-release, create an extra package with qgisMinVersion to 3.14
Expand Down