Skip to content

Commit 242f8de

Browse files
authored
Merge pull request #123 from simplelocalize/dev
Add support for --tags in upload & download
2 parents b50b5a5 + 11f342c commit 242f8de

File tree

15 files changed

+82
-23
lines changed

15 files changed

+82
-23
lines changed
Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
name: Build executables
1+
name: Build and release
22

33
on:
4+
release:
5+
types: [created]
46
push:
57
branches:
68
- 'master'
@@ -11,9 +13,6 @@ concurrency:
1113
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
1214
cancel-in-progress: true
1315

14-
env:
15-
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
16-
1716
jobs:
1817
build-jar:
1918
name: "Build JAR"
@@ -30,12 +29,20 @@ jobs:
3029
- name: "Build JAR"
3130
run: mvn -DskipTests -Pfatjar clean package
3231
- name: 'Get version'
33-
run: echo "::set-env name=VERSION::$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)"
32+
run: echo "VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV
3433
- name: 'Upload artifact'
3534
uses: actions/upload-artifact@v4
3635
with:
3736
name: 'simplelocalize-cli-${{env.VERSION}}.jar'
3837
path: 'target/simplelocalize-cli-${{env.VERSION}}.jar'
38+
- name: 'Upload JAR to Release'
39+
if: github.event_name == 'release'
40+
uses: softprops/action-gh-release@v1
41+
with:
42+
files: 'target/simplelocalize-cli-${{env.VERSION}}.jar'
43+
env:
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
3946
build-executable:
4047
name: "Build ${{ matrix.label }} executable"
4148
strategy:
@@ -85,3 +92,10 @@ jobs:
8592
with:
8693
name: simplelocalize-cli-${{ matrix.label }}
8794
path: ./target/${{ matrix.downloadFilename }}
95+
- name: 'Upload Executable to Release'
96+
if: github.event_name == 'release'
97+
uses: softprops/action-gh-release@v1
98+
with:
99+
files: './target/${{ matrix.downloadFilename }}'
100+
env:
101+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/run-tests.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ concurrency:
1010
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
1111
cancel-in-progress: true
1212

13-
env:
14-
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
15-
1613
jobs:
1714
run_tests:
1815
name: "Run tests"
@@ -36,8 +33,3 @@ jobs:
3633
restore-keys: ${{ runner.os }}-sonar
3734
- name: "Test with Maven"
3835
run: mvn --settings .maven.xml clean install -B -V
39-
# - name: "SonarCloud Analyze"
40-
# env:
41-
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42-
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
43-
# run: mvn clean -B verify -Ptest org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
name: Install and execute
1+
name: Test executables
22

33
on:
4-
push:
5-
branches:
6-
- 'master'
74
release:
85
types: [published]
96
schedule:
@@ -21,7 +18,7 @@ jobs:
2118
fail-fast: false
2219
matrix:
2320
os: [ macos-11, macos-12, macos-13, ubuntu-22.04 ]
24-
version: [ '2.5', '2.4', '2.3', '2.2' ]
21+
version: [ '2.9', '2.8', '2.7', '2.6' ]
2522
steps:
2623
- uses: actions/checkout@v3
2724
- name: Test on ${{ matrix.os }}

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>io.simplelocalize</groupId>
66
<artifactId>simplelocalize-cli</artifactId>
7-
<version>2.9.0</version>
7+
<version>2.10.0</version>
88
<packaging>jar</packaging>
99
<name>simplelocalize-cli</name>
1010
<description>Official SimpleLocalize Command Line Interface</description>

reflect-config.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"java.lang.String",
1616
"java.lang.String",
1717
"java.util.List",
18+
"java.util.List",
1819
"java.lang.String",
1920
"java.lang.String",
2021
"java.lang.String",
@@ -48,6 +49,7 @@
4849
"java.lang.String",
4950
"java.lang.String",
5051
"java.util.List",
52+
"java.util.List",
5153
"java.lang.String",
5254
"java.lang.String",
5355
"java.lang.String",

src/main/java/io/simplelocalize/cli/SimplelocalizeCliCommand.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ public void upload(
9191
@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,
9292
@Option(names = {"--uploadFormat", "--format"}, description = "Translations file format") String uploadFormat,
9393
@Option(names = {"--uploadOptions", "--options"}, split = ",", description = "(Optional) Upload options") List<String> uploadOptions,
94+
@Option(names = {"--uploadTags", "--tags"}, split = ",", description = "(Optional) Assign tags to translation keys") List<String> tags,
9495
@Option(names = {"--uploadNamespace", "--namespace"}, description = "(Optional) Specify namespace for single file upload (cannot be used with {ns} in uploadPath)") String namespace,
9596
@Option(names = {"--uploadLanguageKey", "--languageKey"}, description = "(Optional) Specify language key for single file upload (cannot be used with {lang} in uploadPath)") String languageKey,
9697
@Option(names = {"--uploadCustomerId", "--customerId"}, description = "(Optional) Assign customerId to uploaded translations") String customerId,
@@ -140,6 +141,11 @@ public void upload(
140141
configuration.setUploadNamespace(namespace);
141142
}
142143

144+
if (tags != null && !tags.isEmpty())
145+
{
146+
configuration.setUploadTags(tags);
147+
}
148+
143149
List<String> effectiveUploadOptions = new ArrayList<>();
144150
List<String> configurationUploadOptions = configuration.getUploadOptions();
145151
if (configurationUploadOptions != null)
@@ -190,6 +196,7 @@ public void download(
190196
@Option(names = {"--downloadPath", "--path"}, description = "Directory where translations should be downloaded") String downloadPath,
191197
@Option(names = {"--downloadFormat", "--format"}, description = "Translations file format") String downloadFormat,
192198
@Option(names = {"--downloadOptions", "--options"}, split = ",", description = "(Optional) Download options, use comma separated values for multiple options") List<String> downloadOptions,
199+
@Option(names = {"--downloadTags", "--tags"}, split = ",", description = "(Optional) Download translation keys with given tags") List<String> tags,
193200
@Option(names = {"--downloadSort", "--sort"}, description = "(Optional) Download sorting") String downloadSort,
194201
@Option(names = {"--downloadLanguageKey", "--languageKey"}, split = ",", description = "(Optional) Download translations only for given language key, use comma separated values for multiple keys") List<String> languageKeys,
195202
@Option(names = {"--downloadCustomerId", "--customerId"}, description = "(Optional) Download translations only for given customerId") String customerId,
@@ -242,6 +249,11 @@ public void download(
242249
configuration.setDownloadSort(downloadSort);
243250
}
244251

252+
if (tags != null && !tags.isEmpty())
253+
{
254+
configuration.setDownloadTags(tags);
255+
}
256+
245257
List<String> nonNullConfigurationFileDownloadOptions = Objects.requireNonNullElse(configuration.getDownloadOptions(), List.of());
246258
configuration.setDownloadOptions(nonNullConfigurationFileDownloadOptions);
247259
boolean hasArgumentDownloadOptions = downloadOptions != null && !downloadOptions.isEmpty();

src/main/java/io/simplelocalize/cli/Version.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
public class Version
44
{
55

6-
public static final String NUMBER = "2.9.0";
6+
public static final String NUMBER = "2.10.0";
77

88
private Version()
99
{

src/main/java/io/simplelocalize/cli/client/SimpleLocalizeUriFactory.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import java.net.URI;
88
import java.nio.file.Path;
99
import java.util.List;
10+
import java.util.Objects;
1011

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

37+
List<String> tags = Objects.requireNonNullElse(exportRequest.tags(), List.of());
38+
if (!tags.isEmpty())
39+
{
40+
endpointUrl += "&tags=" + String.join(",", tags);
41+
}
42+
3643
String namespace = exportRequest.namespace();
3744
if (StringUtils.isNotEmpty(namespace))
3845
{
@@ -76,6 +83,12 @@ URI buildUploadUri(UploadRequest uploadRequest, boolean isPreviewMode)
7683
endpointUrl += "&uploadOptions=" + String.join(",", uploadOptions);
7784
}
7885

86+
List<String> tags = Objects.requireNonNullElse(uploadRequest.tags(), List.of());
87+
if (!tags.isEmpty())
88+
{
89+
endpointUrl += "&tags=" + String.join(",", tags);
90+
}
91+
7992
String namespace = uploadRequest.namespace();
8093
if (StringUtils.isNotEmpty(namespace))
8194
{

src/main/java/io/simplelocalize/cli/client/dto/ExportRequest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ public record ExportRequest(
1111
String customerId,
1212
String namespace,
1313
List<String> options,
14-
String sort
14+
String sort,
15+
List<String> tags
1516
)
1617
{
1718
}

src/main/java/io/simplelocalize/cli/client/dto/UploadRequest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ public record UploadRequest(
1313
List<String> options,
1414
String namespace,
1515
String customerId,
16-
String translationKey
16+
String translationKey,
17+
List<String> tags
1718
)
1819
{
1920
}

0 commit comments

Comments
 (0)