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

Release/include qm #85

Closed
wants to merge 8 commits into from
Closed
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
2 changes: 2 additions & 0 deletions docs/configuration/exclude.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ If you want to avoid some files to be shipped with your plugin, create a `.gitat

```gitignore
resources.qrc export-ignore
*.ts export-ignore
*.pro export-ignore
```
4 changes: 2 additions & 2 deletions docs/configuration/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ You can read the docstring of the [Parameters module](/_apidoc/qgispluginci.para

QGIS-Plugin-CI is best served if you use these two conventions :

* [Semantic versioning](https://semver.org/)
* [Keep A Changelog](https://keepachangelog.com)
- [Semantic versioning](https://semver.org/)
- [Keep A Changelog](https://keepachangelog.com)

## Options

Expand Down
2 changes: 2 additions & 0 deletions docs/usage/cli_package.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ optional arguments:
--transifex-token TRANSIFEX_TOKEN
The Transifex API token. If specified translations
will be pulled and compiled.
-t, --local-translation
If specified, local *.ts files are compiled into *.qm files which are then included into final package.
-u --plugin-repo-url PLUGIN_REPO_URL
If specified, a XML repository file will be created in the current directory, the zip URL will use this parameter.
-c --allow-uncommitted-changes
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 @@ -19,6 +19,8 @@ optional arguments:
--transifex-token TRANSIFEX_TOKEN
The Transifex API token. If specified translations
will be pulled and compiled.
-t, --local-translation
If specified, local *.ts files are compiled into *.qm files which are then included into final package.
--github-token GITHUB_TOKEN
The Github API token. If specified, the archive will
be pushed to an already existing release.
Expand Down
41 changes: 31 additions & 10 deletions qgispluginci/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def create_archive(
raise_min_version: str = None,
disable_submodule_update: bool = False,
):

plugin_folder_path = Path(parameters.plugin_path)
repo = git.Repo()

top_tar_handle, top_tar_file = mkstemp(suffix=".tar")
Expand All @@ -53,7 +53,7 @@ def create_archive(
initial_stash = None
diff = repo.index.diff(None)
if diff:
print("Uncommitted changes:")
print("\n*** Uncommitted changes:")
for diff in diff:
print(diff)
if not allow_uncommitted_changes:
Expand Down Expand Up @@ -129,9 +129,11 @@ def create_archive(
stash = "HEAD"
if stash == "" or stash is None:
stash = "HEAD"

# create TAR archive
print("archive plugin with stash: {}".format(stash))
print("\nArchive plugin with stash: {}".format(stash))
repo.git.archive(stash, "-o", top_tar_file, parameters.plugin_path)

# adding submodules
for submodule in repo.submodules:
_, sub_tar_file = mkstemp(suffix=".tar")
Expand Down Expand Up @@ -160,11 +162,10 @@ def create_archive(
# add translation files
if add_translations:
with tarfile.open(top_tar_file, mode="a") as tt:
print("adding translations")
for file in glob("{}/i18n/*.qm".format(parameters.plugin_path)):
print(" adding translation: {}".format(os.path.basename(file)))
# https://stackoverflow.com/a/48462950/1548052
tt.add(file)
print("\nAdding translations...")
for qm in plugin_folder_path.glob("**/*.qm"):
tt.add(qm)
print(f"Translation added: {qm}")

# compile qrc files
pyqt5ac.main(
Expand All @@ -189,6 +190,7 @@ def create_archive(
# adding the content of TAR archive
with tarfile.open(top_tar_file, mode="r:") as tt:
for m in tt.getmembers():
print(m)
if m.isdir():
continue
f = tt.extractfile(m)
Expand Down Expand Up @@ -382,6 +384,7 @@ def release(
release_tag: str = None,
github_token: str = None,
upload_plugin_repo_github: bool = False,
local_translation: bool = False,
transifex_token: str = None,
osgeo_username: str = None,
osgeo_password: str = None,
Expand Down Expand Up @@ -423,12 +426,30 @@ def release(
parser = ChangelogParser()
release_version = parser.latest_version()

# check parameters conflicts about translation
if local_translation and transifex_token:
print(
"Translation source can't be both from Transifex and local. "
"Transifex will be preferred."
)
local_translation = False

if transifex_token is not None:
tr = Translation(
parameters, create_project=False, transifex_token=transifex_token
parameters=parameters,
source_translation="transifex",
transifex_create_project=False,
transifex_token=transifex_token,
)
tr.process_translation_transifex()
tr.pull()
tr.compile_strings()
elif local_translation:
print("Using local translations")
tr = Translation(parameters=parameters, source_translation="local")
tr.process_translation_local()
else:
print("No translation operations")

archive_name = parameters.archive_name(parameters.plugin_path, release_version)

Expand All @@ -441,7 +462,7 @@ def release(
parameters,
release_version,
archive_name,
add_translations=transifex_token is not None,
add_translations=any([transifex_token, local_translation]),
allow_uncommitted_changes=allow_uncommitted_changes,
is_prerelease=is_prerelease,
disable_submodule_update=disable_submodule_update,
Expand Down
Loading