Skip to content
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Build executables
name: Build and release

on:
release:
types: [created]
push:
branches:
- 'master'
Expand All @@ -11,9 +13,6 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true

jobs:
build-jar:
name: "Build JAR"
Expand All @@ -30,12 +29,20 @@ jobs:
- name: "Build JAR"
run: mvn -DskipTests -Pfatjar clean package
- name: 'Get version'
run: echo "::set-env name=VERSION::$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)"
run: echo "VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV
- name: 'Upload artifact'
uses: actions/upload-artifact@v4
with:
name: 'simplelocalize-cli-${{env.VERSION}}.jar'
path: 'target/simplelocalize-cli-${{env.VERSION}}.jar'
- name: 'Upload JAR to Release'
if: github.event_name == 'release'
uses: softprops/action-gh-release@v1
with:
files: 'target/simplelocalize-cli-${{env.VERSION}}.jar'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

build-executable:
name: "Build ${{ matrix.label }} executable"
strategy:
Expand Down Expand Up @@ -85,3 +92,10 @@ jobs:
with:
name: simplelocalize-cli-${{ matrix.label }}
path: ./target/${{ matrix.downloadFilename }}
- name: 'Upload Executable to Release'
if: github.event_name == 'release'
uses: softprops/action-gh-release@v1
with:
files: './target/${{ matrix.downloadFilename }}'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8 changes: 0 additions & 8 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true

jobs:
run_tests:
name: "Run tests"
Expand All @@ -36,8 +33,3 @@ jobs:
restore-keys: ${{ runner.os }}-sonar
- name: "Test with Maven"
run: mvn --settings .maven.xml clean install -B -V
# - name: "SonarCloud Analyze"
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
# run: mvn clean -B verify -Ptest org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
name: Install and execute
name: Test executables

on:
push:
branches:
- 'master'
release:
types: [published]
schedule:
Expand All @@ -21,7 +18,7 @@ jobs:
fail-fast: false
matrix:
os: [ macos-11, macos-12, macos-13, ubuntu-22.04 ]
version: [ '2.5', '2.4', '2.3', '2.2' ]
version: [ '2.9', '2.8', '2.7', '2.6' ]
steps:
- uses: actions/checkout@v3
- name: Test on ${{ matrix.os }}
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.simplelocalize</groupId>
<artifactId>simplelocalize-cli</artifactId>
<version>2.9.0</version>
<version>2.10.0</version>
<packaging>jar</packaging>
<name>simplelocalize-cli</name>
<description>Official SimpleLocalize Command Line Interface</description>
Expand Down
2 changes: 2 additions & 0 deletions reflect-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"java.lang.String",
"java.lang.String",
"java.util.List",
"java.util.List",
"java.lang.String",
"java.lang.String",
"java.lang.String",
Expand Down Expand Up @@ -48,6 +49,7 @@
"java.lang.String",
"java.lang.String",
"java.util.List",
"java.util.List",
"java.lang.String",
"java.lang.String",
"java.lang.String",
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/io/simplelocalize/cli/SimplelocalizeCliCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public void upload(
@Option(names = {"--uploadPath", "--path"}, description = "Path to file with translation or translation keys to upload. Use '{lang}' to define language key if you are uploading more than one file with translations.") String uploadPath,
@Option(names = {"--uploadFormat", "--format"}, description = "Translations file format") String uploadFormat,
@Option(names = {"--uploadOptions", "--options"}, split = ",", description = "(Optional) Upload options") List<String> uploadOptions,
@Option(names = {"--uploadTags", "--tags"}, split = ",", description = "(Optional) Assign tags to translation keys") List<String> tags,
@Option(names = {"--uploadNamespace", "--namespace"}, description = "(Optional) Specify namespace for single file upload (cannot be used with {ns} in uploadPath)") String namespace,
@Option(names = {"--uploadLanguageKey", "--languageKey"}, description = "(Optional) Specify language key for single file upload (cannot be used with {lang} in uploadPath)") String languageKey,
@Option(names = {"--uploadCustomerId", "--customerId"}, description = "(Optional) Assign customerId to uploaded translations") String customerId,
Expand Down Expand Up @@ -140,6 +141,11 @@ public void upload(
configuration.setUploadNamespace(namespace);
}

if (tags != null && !tags.isEmpty())
{
configuration.setUploadTags(tags);
}

List<String> effectiveUploadOptions = new ArrayList<>();
List<String> configurationUploadOptions = configuration.getUploadOptions();
if (configurationUploadOptions != null)
Expand Down Expand Up @@ -190,6 +196,7 @@ public void download(
@Option(names = {"--downloadPath", "--path"}, description = "Directory where translations should be downloaded") String downloadPath,
@Option(names = {"--downloadFormat", "--format"}, description = "Translations file format") String downloadFormat,
@Option(names = {"--downloadOptions", "--options"}, split = ",", description = "(Optional) Download options, use comma separated values for multiple options") List<String> downloadOptions,
@Option(names = {"--downloadTags", "--tags"}, split = ",", description = "(Optional) Download translation keys with given tags") List<String> tags,
@Option(names = {"--downloadSort", "--sort"}, description = "(Optional) Download sorting") String downloadSort,
@Option(names = {"--downloadLanguageKey", "--languageKey"}, split = ",", description = "(Optional) Download translations only for given language key, use comma separated values for multiple keys") List<String> languageKeys,
@Option(names = {"--downloadCustomerId", "--customerId"}, description = "(Optional) Download translations only for given customerId") String customerId,
Expand Down Expand Up @@ -242,6 +249,11 @@ public void download(
configuration.setDownloadSort(downloadSort);
}

if (tags != null && !tags.isEmpty())
{
configuration.setDownloadTags(tags);
}

List<String> nonNullConfigurationFileDownloadOptions = Objects.requireNonNullElse(configuration.getDownloadOptions(), List.of());
configuration.setDownloadOptions(nonNullConfigurationFileDownloadOptions);
boolean hasArgumentDownloadOptions = downloadOptions != null && !downloadOptions.isEmpty();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/simplelocalize/cli/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
public class Version
{

public static final String NUMBER = "2.9.0";
public static final String NUMBER = "2.10.0";

private Version()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.net.URI;
import java.nio.file.Path;
import java.util.List;
import java.util.Objects;

public class SimpleLocalizeUriFactory
{
Expand All @@ -33,6 +34,12 @@ URI buildDownloadUri(ExportRequest exportRequest)
endpointUrl += "&downloadOptions=" + String.join(",", downloadOptions);
}

List<String> tags = Objects.requireNonNullElse(exportRequest.tags(), List.of());
if (!tags.isEmpty())
{
endpointUrl += "&tags=" + String.join(",", tags);
}

String namespace = exportRequest.namespace();
if (StringUtils.isNotEmpty(namespace))
{
Expand Down Expand Up @@ -76,6 +83,12 @@ URI buildUploadUri(UploadRequest uploadRequest, boolean isPreviewMode)
endpointUrl += "&uploadOptions=" + String.join(",", uploadOptions);
}

List<String> tags = Objects.requireNonNullElse(uploadRequest.tags(), List.of());
if (!tags.isEmpty())
{
endpointUrl += "&tags=" + String.join(",", tags);
}

String namespace = uploadRequest.namespace();
if (StringUtils.isNotEmpty(namespace))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ public record ExportRequest(
String customerId,
String namespace,
List<String> options,
String sort
String sort,
List<String> tags
)
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ public record UploadRequest(
List<String> options,
String namespace,
String customerId,
String translationKey
String translationKey,
List<String> tags
)
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ public class Configuration
@Builder.Default
private List<String> uploadOptions = new ArrayList<>();

@Builder.Default
private List<String> uploadTags = new ArrayList<>();

@Builder.Default
private Boolean dryRun = false;

Expand All @@ -68,6 +71,9 @@ public class Configuration
@Builder.Default
private List<String> downloadOptions = new ArrayList<>();

@Builder.Default
private List<String> downloadTags = new ArrayList<>();

@Builder.Default
private List<String> downloadLanguageKeys = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

public class DownloadCommand implements CliCommand
{
Expand Down Expand Up @@ -41,7 +42,13 @@ public void invoke() throws IOException, InterruptedException
final List<String> languageKeys = configuration.getDownloadLanguageKeys();
if (!languageKeys.isEmpty())
{
log.info("Language(s): {}", languageKeys);
log.info("Languages: {}", languageKeys);
}

final List<String> tags = Objects.requireNonNullElse(configuration.getDownloadTags(), List.of());
if (!tags.isEmpty())
{
log.info("Tags: {}", tags);
}

final String sort = configuration.getDownloadSort();
Expand Down Expand Up @@ -90,6 +97,7 @@ public void invoke() throws IOException, InterruptedException
.withCustomerId(customerId)
.withOptions(downloadOptions)
.withSort(sort)
.withTags(tags)
.build();
final List<DownloadableFile> downloadableFiles = client.exportFiles(exportRequest);
for (DownloadableFile downloadableFile : downloadableFiles)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ public void invoke() throws IOException, InterruptedException
log.info("Language: {}", uploadLanguageKey);
}

final List<String> uploadTags = configuration.getUploadTags();
if (!uploadTags.isEmpty())
{
log.info("Tags: {}", uploadTags);
}

final String uploadNamespace = configuration.getUploadNamespace();
final boolean hasDefinedNamespace = StringUtils.isNotBlank(uploadNamespace);
if (hasDefinedNamespace)
Expand Down Expand Up @@ -120,6 +126,7 @@ public void invoke() throws IOException, InterruptedException
.withNamespace(effectiveNamespace)
.withCustomerId(uploadCustomerId)
.withOptions(uploadOptions)
.withTags(uploadTags)
.build();

String logMessage = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ void shouldDownloadMultipleFiles() throws Exception
.withFormat("android")
.withLanguageKeys(List.of("en"))
.withOptions(List.of("SPLIT_BY_NAMESPACES"))
.withTags(List.of())
.build()))
.thenReturn(List.of(
DownloadableFile.builder().withNamespace("common").withUrl("https://s3.simplelocalize.io/file1.xml").build(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import java.nio.file.Path;
import java.util.Collections;
import java.util.List;

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.times;
Expand Down Expand Up @@ -58,6 +59,7 @@ public void shouldUploadTwelveFiles() throws Exception
.withPath(Path.of("./junit/download-test/values-{lang}/strings.xml"))
.withFormat("android")
.withOptions(Collections.emptyList())
.withTags(List.of())
.build(),
"languageKey", "path"
)
Expand Down Expand Up @@ -85,6 +87,7 @@ public void shouldUploadOneFileWithLangTemplate() throws Exception
.withFormat("android")
.withLanguageKey("en")
.withOptions(Collections.emptyList())
.withTags(List.of())
.build(),
"path"
)
Expand Down Expand Up @@ -112,6 +115,7 @@ public void shouldUploadOneFileWithOnlyTranslationKeys() throws Exception
.withFormat("android")
.withLanguageKey("en")
.withOptions(Collections.emptyList())
.withTags(List.of())
.build()
)
);
Expand Down Expand Up @@ -155,6 +159,7 @@ public void shouldUploadOneFile() throws Exception
.withFormat("android")
.withLanguageKey("en")
.withOptions(Collections.emptyList())
.withTags(List.of())
.build(),
"path"
)
Expand Down
Loading