Implement automatic crowdin strings upload in AppVeyor (#937)

* Initial crowdin-ci integration

* Fix syntax

* Fix detached heads

* Fix syntax for java-only installs

* Finish the PR

* Misc
This commit is contained in:
Łukasz Domeradzki 2018-11-06 06:00:01 +01:00 committed by GitHub
parent 45e5117f22
commit 5471394bab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 207 additions and 229 deletions

View file

@ -6,6 +6,8 @@ image: Visual Studio 2017
configuration: Release
clone_depth: 10
environment:
CROWDIN_API_KEY:
secure: oGuZaQo2z5/JkEYaKrD9Ing+TgwZ3qQVf+9Jdz73Fephy04z5rWPGCCtkjaMLTcY
DOTNET_CHANNEL: 2.1
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_INSTALL_DIR: tools\dotnet
@ -34,7 +36,9 @@ install:
}
if ($env:DOTNET_CHANNEL) {
&([scriptblock]::Create((Invoke-WebRequest -Uri 'https://dot.net/v1/dotnet-install.ps1'))) -Channel "$env:DOTNET_CHANNEL" -InstallDir "$env:DOTNET_INSTALL_DIR" -NoPath
dotnet --info
&([scriptblock]::Create((Invoke-WebRequest 'https://dot.net/v1/dotnet-install.ps1'))) -Channel "$env:DOTNET_CHANNEL" -InstallDir "$env:DOTNET_INSTALL_DIR" -NoPath
$env:Path = "$pwd\$env:DOTNET_INSTALL_DIR;$env:Path"
}
before_build:
@ -46,7 +50,7 @@ before_build:
$ProgressPreference = 'SilentlyContinue'
if (Test-Path -Path "$env:DOTNET_INSTALL_DIR" -PathType Container) {
if (Test-Path "$env:DOTNET_INSTALL_DIR" -PathType Container) {
$env:Path = "$pwd\$env:DOTNET_INSTALL_DIR;$env:Path"
}
@ -66,12 +70,12 @@ build_script:
$ProgressPreference = 'SilentlyContinue'
if (Test-Path -Path "$env:DOTNET_INSTALL_DIR" -PathType Container) {
if (Test-Path "$env:DOTNET_INSTALL_DIR" -PathType Container) {
$env:Path = "$pwd\$env:DOTNET_INSTALL_DIR;$env:Path"
}
Push-Location -Path ASF-ui
Push-Location ASF-ui
npm ci --no-progress
@ -108,7 +112,7 @@ test_script:
$ProgressPreference = 'SilentlyContinue'
if (Test-Path -Path "$env:DOTNET_INSTALL_DIR" -PathType Container) {
if (Test-Path "$env:DOTNET_INSTALL_DIR" -PathType Container) {
$env:Path = "$pwd\$env:DOTNET_INSTALL_DIR;$env:Path"
}
@ -128,7 +132,7 @@ after_test:
$ProgressPreference = 'SilentlyContinue'
if (Test-Path -Path "$env:DOTNET_INSTALL_DIR" -PathType Container) {
if (Test-Path "$env:DOTNET_INSTALL_DIR" -PathType Container) {
$env:Path = "$pwd\$env:DOTNET_INSTALL_DIR;$env:Path"
}
@ -140,7 +144,7 @@ after_test:
$ErrorActionPreference = 'Stop'
$ProgressPreference = 'SilentlyContinue'
Set-Location -Path "$env:APPVEYOR_BUILD_FOLDER"
Set-Location "$env:APPVEYOR_BUILD_FOLDER"
if ($variant -like '*-netf') {
$compressionMethod = 'Deflate' # This depends on what ZipArchive supports on given platform
@ -162,20 +166,20 @@ after_test:
}
# If we include any helper scripts for this variant, copy them to output directory
if (Test-Path -Path "ArchiSteamFarm\scripts\$variant" -PathType Container) {
Copy-Item "ArchiSteamFarm\scripts\$variant\*" -Destination "ArchiSteamFarm\out\$variant"
if (Test-Path "ArchiSteamFarm\scripts\$variant" -PathType Container) {
Copy-Item "ArchiSteamFarm\scripts\$variant\*" "ArchiSteamFarm\out\$variant"
}
# Until https://github.com/dotnet/cli/issues/3267 happens, we'll hack dotnet binary icon on Windows and include .ico file on other platforms
if ($targetFramework -ne "$env:NET_FRAMEWORK_VERSION") {
if (Test-Path -Path "ArchiSteamFarm\out\$variant\ArchiSteamFarm.exe" -PathType Leaf) {
if (Test-Path "ArchiSteamFarm\out\$variant\ArchiSteamFarm.exe" -PathType Leaf) {
tools\rcedit\rcedit-x64.exe "ArchiSteamFarm\out\$variant\ArchiSteamFarm.exe" --set-icon 'resources\ASF.ico'
if ($LastExitCode -ne 0) {
throw "Last command failed."
}
} else {
Copy-Item 'resources\ASF.ico' -Destination "ArchiSteamFarm\out\$variant\ArchiSteamFarm.ico"
Copy-Item 'resources\ASF.ico' "ArchiSteamFarm\out\$variant\ArchiSteamFarm.ico"
}
}
@ -185,8 +189,8 @@ after_test:
# Include extra logic for builds marked for release
if ($env:APPVEYOR_REPO_TAG -eq 'true') {
# Update link in Changelog.html accordingly
if (Test-Path -Path "ArchiSteamFarm\out\$variant\Changelog.html" -PathType Leaf) {
(Get-Content -Path "ArchiSteamFarm\out\$variant\Changelog.html").Replace('ArchiSteamFarm/commits/master', "ArchiSteamFarm/releases/tag/$env:APPVEYOR_REPO_TAG_NAME") | Set-Content -Path "ArchiSteamFarm\out\$variant\Changelog.html"
if (Test-Path "ArchiSteamFarm\out\$variant\Changelog.html" -PathType Leaf) {
(Get-Content "ArchiSteamFarm\out\$variant\Changelog.html").Replace('ArchiSteamFarm/commits/master', "ArchiSteamFarm/releases/tag/$env:APPVEYOR_REPO_TAG_NAME") | Set-Content "ArchiSteamFarm\out\$variant\Changelog.html"
}
# If this build is going to be deployed further, prefer maximum compression
@ -216,11 +220,22 @@ after_test:
foreach ($variant in $env:VARIANTS.Split([char[]] $null, [System.StringSplitOptions]::RemoveEmptyEntries)) {
Start-Job -Name "$variant" -ScriptBlock $PublishBlock -ArgumentList "$variant"
Start-Job -Name "$variant" $PublishBlock -ArgumentList "$variant"
}
Get-Job | Receive-Job -AutoRemoveJob -Wait
Get-Job | Receive-Job -Wait -AutoRemoveJob
if (!($env:APPVEYOR_PULL_REQUEST_NUMBER) -and ($env:APPVEYOR_REPO_BRANCH -eq 'master') -and ($env:APPVEYOR_REPO_TAG -eq 'false') -and (Test-Path 'crowdin.yml' -PathType Leaf) -and (Test-Path 'tools\crowdin-cli\crowdin_identity_example.yml' -PathType Leaf) -and (Test-Path 'tools\crowdin-cli\archi_core.ps1' -PathType Leaf)) {
(Get-Content 'tools\crowdin-cli\crowdin_identity_example.yml').Replace('CROWDIN_API_KEY', "$env:CROWDIN_API_KEY") | Set-Content 'tools\crowdin-cli\crowdin_identity.yml'
try {
& tools\crowdin-cli\archi_core.ps1 --upload
} finally {
Remove-Item 'tools\crowdin-cli\crowdin_identity.yml'
}
}
deploy:
- provider: GitHub
tag: $(appveyor_repo_tag_name)

View file

@ -1,5 +1,6 @@
"preserve_hierarchy": true
"files": [
# Note: any modifications to this file should carry appropriate modifications to tools/crowdin-cli scripts as well (CI integration)
{
"source": "/ArchiSteamFarm/Localization/Strings.resx",
"translation": "/ArchiSteamFarm/Localization/Strings.%locale%.resx"

View file

@ -5,6 +5,8 @@ Crowdin CLI
**[Source](https://github.com/crowdin/crowdin-cli-2)**
**[Latest version](https://downloads.crowdin.com/cli/v2/crowdin-cli.zip)**
---
Scripts included in this directory are used by ASF developers for synchronization of strings/translations between GitHub and **[Crowdin](https://github.com/JustArchiNET/ArchiSteamFarm/wiki/Localization)**. If you're not ASF developer that has access to our localization platform, then you won't find anything interesting here.
@ -13,20 +15,24 @@ Scripts included in this directory are used by ASF developers for synchronizatio
## Before you begin
- Make sure that your `crowdin_identity.yml` file exists - this is the file with login credentials that is not being committed to GitHub. If it doesn't exist yet (e.g. because you've just cloned the repo), create it from `crowdin_identity_example.yml` and fill `api_key` that can be found **[here](https://crowdin.com/project/archisteamfarm/settings#api)**.
Make sure that your `crowdin_identity.yml` file exists. This is the file with login credentials that is not being committed to GitHub. If it doesn't exist yet (e.g. because you've just cloned the repo), create it from `crowdin_identity_example.yml` and fill `api_key` that can be found in our **[project settings](https://crowdin.com/project/archisteamfarm/settings#api)**.
---
## Installation
Follow **[instructions](https://support.crowdin.com/cli-tool/#installation)** and ensure that `crowdin` command is recognized by your shell.
Follow **[crowdin instructions](https://support.crowdin.com/cli-tool/#installation)** and ensure that `crowdin` command is recognized by your shell. This is recommended setup.
Alternatively, at the bare minimum install latest **[Java JRE](https://www.oracle.com/technetwork/java/javase/downloads)**, ensure that `java` command is recognized by your shell and that your java version is able to execute bundled `crowdin-cli.jar`.
---
## Usage
- `archi_upload` for pushing strings to Crowdin.
`archi_upload` for pushing source strings to Crowdin (if not done automatically by CI).
- `archi_download` for downloading translations from Crowdin.
`archi_download` for downloading translated strings from Crowdin (if not done automatically by CI).
- `archi_sync` for upload + download.
`archi_sync` for upload + download.
`archi_core` for custom workflows and integration.

View file

@ -0,0 +1,158 @@
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
$ProgressPreference = 'SilentlyContinue'
$branch = 'master'
$crowdinConfigPath = 'crowdin.yml'
$crowdinHomePath = 'tools\crowdin-cli'
$crowdinIdentityPath = "$crowdinHomePath\crowdin_identity.yml"
$crowdinJarPath = "$crowdinHomePath\crowdin-cli.jar"
$projectHomePath = '..\..'
function Commit-Module($project, $path) {
Push-Location "$project"
try {
git pull origin "$branch"
if ($LastExitCode -ne 0) {
throw "Last command failed."
}
git add -A "$path"
if ($LastExitCode -ne 0) {
throw "Last command failed."
}
git commit -m "Translations update"
if ($LastExitCode -ne 0) {
throw "Last command failed."
}
} finally {
Pop-Location
}
}
function Crowdin-Download {
Pull-Module 'ASF-ui'
Pull-Module 'ASF-WebConfigGenerator'
Pull-Module 'wiki'
Crowdin-Execute 'download'
Commit-Module 'ASF-ui' 'src\i18n\locale\*.json'
Commit-Module 'ASF-WebConfigGenerator' 'src\locale\*.json'
Commit-Module 'wiki' 'locale\*.md'
git reset
if ($LastExitCode -ne 0) {
throw "Last command failed."
}
git add -A "ArchiSteamFarm\Localization\*.resx" "ASF-ui" "ASF-WebConfigGenerator" "wiki"
if ($LastExitCode -ne 0) {
throw "Last command failed."
}
git commit -m "Translations update"
if ($LastExitCode -ne 0) {
throw "Last command failed."
}
git push origin "$branch" --recurse-submodules=on-demand
if ($LastExitCode -ne 0) {
throw "Last command failed."
}
}
function Crowdin-Execute($command) {
if (Get-Command 'crowdin' -ErrorAction SilentlyContinue) {
& crowdin -b "$branch" --identity "$crowdinIdentityPath" $command
if ($LastExitCode -ne 0) {
throw "Last command failed."
}
} elseif ((Test-Path "$crowdinJarPath" -PathType Leaf) -and (Get-Command 'java' -ErrorAction SilentlyContinue)) {
& java -jar "$crowdinJarPath" -b "$branch" --identity "$crowdinIdentityPath" $command
if ($LastExitCode -ne 0) {
throw "Last command failed."
}
} else {
throw "Could not find crowdin executable!"
}
}
function Crowdin-Upload {
Pull-Module 'ASF-ui'
Pull-Module 'ASF-WebConfigGenerator'
Pull-Module 'wiki'
Crowdin-Execute 'upload sources'
}
function Pull-Module($project) {
Push-Location "$project"
try {
git checkout -f "$branch"
if ($LastExitCode -ne 0) {
throw "Last command failed."
}
git reset --hard
if ($LastExitCode -ne 0) {
throw "Last command failed."
}
git clean -fd
if ($LastExitCode -ne 0) {
throw "Last command failed."
}
git pull origin "$branch"
if ($LastExitCode -ne 0) {
throw "Last command failed."
}
} finally {
Pop-Location
}
}
Push-Location "$PSScriptRoot\$projectHomePath"
try {
if (!(Test-Path "$crowdinConfigPath" -PathType Leaf)) {
throw "$crowdinConfigPath could not be found, aborting."
}
if (!(Test-Path "$crowdinIdentityPath" -PathType Leaf)) {
throw "$crowdinIdentityPath could not be found, aborting."
}
foreach ($arg in $args) {
switch -Wildcard ($arg) {
'*download' {
Crowdin-Download
}
'*upload' {
Crowdin-Upload
}
default {
throw "$arg action is unknown, aborting."
}
}
}
} finally {
Pop-Location
}

View file

@ -2,32 +2,6 @@ Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
$ProgressPreference = 'SilentlyContinue'
Set-Location $PSScriptRoot
Set-Location ..\\..
crowdin -b master --identity tools\\crowdin-cli\\crowdin_identity.yml download
git reset
Push-Location -Path ASF-ui
git pull
git add -A "src\i18n\locale\*.json"
git commit -m "Translations update"
Pop-Location
Push-Location -Path ASF-WebConfigGenerator
git pull
git add -A "src\locale\*.json"
git commit -m "Translations update"
Pop-Location
Push-Location -Path wiki
git pull
git add -A "locale\*.md"
git commit -m "Translations update"
Pop-Location
git add -A "ArchiSteamFarm\Localization\*.resx" "ASF-ui" "ASF-WebConfigGenerator" "wiki"
git commit -m "Translations update"
git push --recurse-submodules=on-demand
Push-Location "$PSScriptRoot\..\.."
& archi_core.ps1 --download
pause

View file

@ -1,32 +0,0 @@
#!/bin/bash
set -eu
cd "$(dirname "$(readlink -f "$0")")"
cd ../..
crowdin -b master --identity tools/crowdin-cli/crowdin_identity.yml download
git reset
cd ASF-ui
git pull
git add -A "src/i18n/locale/*.json"
git commit -m "Translations update"
cd ..
cd ASF-WebConfigGenerator
git pull
git add -A "src/locale/*.json"
git commit -m "Translations update"
cd ..
cd wiki
git pull
git add -A "locale/*.md"
git commit -m "Translations update"
cd ..
git add -A "ArchiSteamFarm/Localization/*.resx" "ASF-ui" "ASF-WebConfigGenerator" "wiki"
git commit -m "Translations update"
git push --recurse-submodules=on-demand
read -p "Press enter to continue..."

View file

@ -2,52 +2,6 @@ Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
$ProgressPreference = 'SilentlyContinue'
Set-Location $PSScriptRoot
Set-Location ..\\..
Push-Location -Path ASF-ui
git reset --hard
git clean -fd
git pull
Pop-Location
Push-Location -Path ASF-WebConfigGenerator
git reset --hard
git clean -fd
git pull
Pop-Location
Push-Location -Path wiki
git reset --hard
git clean -fd
git pull
Pop-Location
crowdin -b master --identity tools\\crowdin-cli\\crowdin_identity.yml upload sources
crowdin -b master --identity tools\\crowdin-cli\\crowdin_identity.yml download
git reset
Push-Location -Path ASF-ui
git pull
git add -A "src\i18n\locale\*.json"
git commit -m "Translations update"
Pop-Location
Push-Location -Path ASF-WebConfigGenerator
git pull
git add -A "src\locale\*.json"
git commit -m "Translations update"
Pop-Location
Push-Location -Path wiki
git pull
git add -A "locale\*.md"
git commit -m "Translations update"
Pop-Location
git add -A "ArchiSteamFarm\Localization\*.resx" "ASF-ui" "ASF-WebConfigGenerator" "wiki"
git commit -m "Translations update"
git push --recurse-submodules=on-demand
Push-Location "$PSScriptRoot\..\.."
& archi_core.ps1 --upload --download
pause

View file

@ -1,52 +0,0 @@
#!/bin/bash
set -eu
cd "$(dirname "$(readlink -f "$0")")"
cd ../..
cd ASF-ui
git reset --hard
git clean -fd
git pull
cd ..
cd ASF-WebConfigGenerator
git reset --hard
git clean -fd
git pull
cd ..
cd wiki
git reset --hard
git clean -fd
git pull
cd ..
crowdin -b master --identity tools/crowdin-cli/crowdin_identity.yml upload sources
crowdin -b master --identity tools/crowdin-cli/crowdin_identity.yml download
git reset
cd ASF-ui
git pull
git add -A "src/i18n/locale/*.json"
git commit -m "Translations update"
cd ..
cd ASF-WebConfigGenerator
git pull
git add -A "src/locale/*.json"
git commit -m "Translations update"
cd ..
cd wiki
git pull
git add -A "locale/*.md"
git commit -m "Translations update"
cd ..
git add -A "ArchiSteamFarm/Localization/*.resx" "ASF-ui" "ASF-WebConfigGenerator" "wiki"
git commit -m "Translations update"
git push --recurse-submodules=on-demand
read -p "Press enter to continue..."

View file

@ -2,26 +2,6 @@ Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
$ProgressPreference = 'SilentlyContinue'
Set-Location $PSScriptRoot
Set-Location ..\\..
Push-Location -Path ASF-ui
git reset --hard
git clean -fd
git pull
Pop-Location
Push-Location -Path ASF-WebConfigGenerator
git reset --hard
git clean -fd
git pull
Pop-Location
Push-Location -Path wiki
git reset --hard
git clean -fd
git pull
Pop-Location
crowdin -b master --identity tools\\crowdin-cli\\crowdin_identity.yml upload sources
Push-Location "$PSScriptRoot\..\.."
& archi_core.ps1 --upload
pause

View file

@ -1,26 +0,0 @@
#!/bin/bash
set -eu
cd "$(dirname "$(readlink -f "$0")")"
cd ../..
cd ASF-ui
git reset --hard
git clean -fd
git pull
cd ..
cd ASF-WebConfigGenerator
git reset --hard
git clean -fd
git pull
cd ..
cd wiki
git reset --hard
git clean -fd
git pull
cd ..
crowdin -b master --identity tools/crowdin-cli/crowdin_identity.yml upload sources
read -p "Press enter to continue..."

Binary file not shown.

View file

@ -1,2 +1,2 @@
"project_identifier": "archisteamfarm"
"api_key": "FILL_ME"
"api_key": "CROWDIN_API_KEY"