Skip to content

Commit

Permalink
feat: v2 release (#225)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii-bodnar authored May 29, 2024
1 parent 0f46116 commit 61ac8b9
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 91 deletions.
1 change: 1 addition & 0 deletions .github/workflows/update-main-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
type: choice
description: The main version to update
options:
- v2
- v1

jobs:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM crowdin/cli:3.19.4
FROM crowdin/cli:4.0.0

RUN apk --no-cache add curl git git-lfs jq gnupg;

Expand Down
34 changes: 18 additions & 16 deletions EXAMPLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
uses: actions/checkout@v4

- name: Synchronize with Crowdin
uses: crowdin/github-action@v1
uses: crowdin/github-action@v2
with:
upload_sources: true
upload_translations: true
Expand Down Expand Up @@ -83,7 +83,7 @@ jobs:
uses: actions/checkout@v4

- name: Synchronize with Crowdin
uses: crowdin/github-action@v1
uses: crowdin/github-action@v2
with:
upload_sources: true
upload_translations: false
Expand Down Expand Up @@ -115,18 +115,20 @@ jobs:
uses: actions/checkout@v4

- name: Crowdin sync
uses: crowdin/github-action@v1
uses: crowdin/github-action@v2
with:
upload_sources: true
upload_translations: false
source: src/locale/en.json # Sources pattern
translation: src/locale/%android_code%.json # Translations pattern
project_id: ${{ secrets.CROWDIN_PROJECT_ID }} # Crowdin Project ID
token: ${{ secrets.CROWDIN_PERSONAL_TOKEN }} # Crowdin Personal Access Token
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
```
The Action/CLI will automatically detect the [environment variables](https://crowdin.github.io/crowdin-cli/configuration#environment-variables) and use them for the configuration.
> **Note**
> To avoid any conflicts, do not use the `crowdin.yml` file in the repository when using the above configuration approach.

Expand All @@ -147,7 +149,7 @@ jobs:
uses: actions/checkout@v4
- name: Crowdin push
uses: crowdin/github-action@v1
uses: crowdin/github-action@v2
with:
upload_sources: true
upload_translations: false
Expand All @@ -174,7 +176,7 @@ jobs:
uses: actions/checkout@v4
- name: Crowdin push
uses: crowdin/github-action@v1
uses: crowdin/github-action@v2
with:
upload_sources: true
upload_translations: false
Expand Down Expand Up @@ -206,7 +208,7 @@ jobs:
uses: actions/checkout@v4
- name: Crowdin pull
uses: crowdin/github-action@v1
uses: crowdin/github-action@v2
with:
upload_sources: false
upload_translations: false
Expand Down Expand Up @@ -241,7 +243,7 @@ jobs:
uses: actions/checkout@v4
- name: Crowdin pull
uses: crowdin/github-action@v1
uses: crowdin/github-action@v2
with:
download_translations: false
download_bundle: 1
Expand Down Expand Up @@ -277,7 +279,7 @@ jobs:
uses: actions/checkout@v4
- name: Synchronize with Crowdin
uses: crowdin/github-action@v1
uses: crowdin/github-action@v2
with:
upload_sources: true
upload_translations: true
Expand Down Expand Up @@ -307,7 +309,7 @@ By default, the Action looks for the `crowdin.yml` file in the repository root.
# ...
- name: Crowdin
uses: crowdin/github-action@v1
uses: crowdin/github-action@v2
with:
config: '.github/crowdin.yml'
#...
Expand Down Expand Up @@ -339,7 +341,7 @@ jobs:
uses: actions/checkout@v4
- name: Matrix
uses: crowdin/github-action@v1
uses: crowdin/github-action@v2
with:
upload_sources: false
upload_translations: false
Expand Down Expand Up @@ -383,7 +385,7 @@ jobs:
fetch-depth: 0
- name: Synchronize with Crowdin
uses: crowdin/github-action@v1
uses: crowdin/github-action@v2
with:
upload_sources: true
upload_translations: true
Expand Down Expand Up @@ -464,7 +466,7 @@ There is a possibility to get the URL or number of the created Pull Request. You
```yaml
# ...
- name: Crowdin
uses: crowdin/github-action@v1
uses: crowdin/github-action@v2
id: crowdin-download
with:
download_translations: true
Expand Down Expand Up @@ -505,7 +507,7 @@ jobs:
uses: actions/checkout@v4
- name: Check translation progress
uses: crowdin/github-action@v1
uses: crowdin/github-action@v2
with:
command: 'status translation'
command_args: '--fail-if-incomplete'
Expand All @@ -532,7 +534,7 @@ jobs:
uses: actions/checkout@v4
- name: Pre-translate
uses: crowdin/github-action@v1
uses: crowdin/github-action@v2
with:
command: 'pre-translate'
command_args: '--language uk --method tm'
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 Crowdin
Copyright (c) Crowdin

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
17 changes: 3 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ This action allows you to easily integrate and automate the localization of your
- Downloads translations from Crowdin.
- Download sources from Crowdin.
- Creates a PR with the translations.
- Run any Crowdin CLI command.
- Run any [Crowdin CLI](https://crowdin.github.io/crowdin-cli/commands/crowdin) command.

## Usage

Expand All @@ -58,7 +58,7 @@ jobs:
uses: actions/checkout@v4

- name: crowdin action
uses: crowdin/github-action@v1
uses: crowdin/github-action@v2
with:
upload_sources: true
upload_translations: false
Expand Down Expand Up @@ -168,25 +168,14 @@ You can also run any other Crowdin CLI command by specifying the `command` and `

```yaml
- name: crowdin action
uses: crowdin/github-action@v1
uses: crowdin/github-action@v2
with:
command: 'pre-translate'
command_args: '-l uk --method tm --branch main'
```

To see the full list of available commands, visit the [official documentation](https://crowdin.github.io/crowdin-cli/).

### Crowdin configuration file

If your workflow file specifies the `config` property, you'll need to add the following to your [Crowdin configuration file](https://support.crowdin.com/configuration-file/) (e.g. `crowdin.yml`):

```yml
project_id_env: CROWDIN_PROJECT_ID
api_token_env: CROWDIN_PERSONAL_TOKEN
```

When the workflow runs, the real values of your token and project ID will be injected into the config using the secrets in the environment.

## Outputs

This action has the following outputs:
Expand Down
26 changes: 0 additions & 26 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,36 +123,10 @@ inputs:
default: 'false'
required: false

# branch options
add_crowdin_branch:
description: 'Option to create specified version branch in your Crowdin project'
deprecationMessage: 'This option is deprecated. Please use `command: branch add name` instead.'
required: false
new_branch_title:
description: 'Use to provide more details for translators. Title is available in UI only'
deprecationMessage: 'This option is deprecated. Please use `command: branch add name` instead.'
required: false
new_branch_export_pattern:
description: 'Branch export pattern. Defines branch name and path in resulting translations bundle'
deprecationMessage: 'This option is deprecated. Please use `command: branch add name` instead.'
required: false
new_branch_priority:
description: 'Defines priority level for each branch [LOW, NORMAL, HIGH]'
deprecationMessage: 'This option is deprecated. Please use `command: branch add name` instead.'
required: false
delete_crowdin_branch:
description: 'Option to remove specified version branch in your Crowdin project'
deprecationMessage: 'This option is deprecated. Please use `command: branch delete name` instead.'
required: false

# global options
crowdin_branch_name:
description: 'Option to upload or download files to the specified version branch in your Crowdin project'
required: false
identity:
description: 'Option to specify a path to user-specific credentials, without / at the beginning'
deprecationMessage: 'This option is deprecated. Please use the environment variables instead.'
required: false
config:
description: 'Option to specify a path to the configuration file, without / at the beginning'
required: false
Expand Down
34 changes: 1 addition & 33 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -286,16 +286,6 @@ setup_commit_signing() {
rm private.key
}

get_branch_available_options() {
for OPTION in "$@" ; do
if echo "$OPTION" | egrep -vq "^(--dryrun|--branch|--source|--translation)"; then
AVAILABLE_OPTIONS="${AVAILABLE_OPTIONS} ${OPTION}"
fi
done

echo "$AVAILABLE_OPTIONS"
}

echo "STARTING CROWDIN ACTION"

cd "${GITHUB_WORKSPACE}" || exit 1
Expand All @@ -317,10 +307,6 @@ if [ -n "$INPUT_CROWDIN_BRANCH_NAME" ]; then
set -- "$@" --branch="${INPUT_CROWDIN_BRANCH_NAME}"
fi

if [ -n "$INPUT_IDENTITY" ]; then
set -- "$@" --identity="${INPUT_IDENTITY}"
fi

if [ -n "$INPUT_CONFIG" ]; then
set -- "$@" --config="${INPUT_CONFIG}"
fi
Expand Down Expand Up @@ -368,18 +354,6 @@ if [ -n "$INPUT_COMMAND" ]; then
exit 0
fi

if [ -n "$INPUT_ADD_CROWDIN_BRANCH" ]; then
NEW_BRANCH_OPTIONS=$( get_branch_available_options "$@" )

if [ -n "$INPUT_NEW_BRANCH_PRIORITY" ]; then
NEW_BRANCH_OPTIONS="${NEW_BRANCH_OPTIONS} --priority=${INPUT_NEW_BRANCH_PRIORITY}"
fi

echo "CREATING BRANCH $INPUT_ADD_CROWDIN_BRANCH"

crowdin branch add "$INPUT_ADD_CROWDIN_BRANCH" $NEW_BRANCH_OPTIONS --title="${INPUT_NEW_BRANCH_TITLE}" --export-pattern="${INPUT_NEW_BRANCH_EXPORT_PATTERN}"
fi

if [ "$INPUT_UPLOAD_SOURCES" = true ]; then
upload_sources "$@"
fi
Expand Down Expand Up @@ -425,7 +399,7 @@ fi
if [ "$INPUT_DOWNLOAD_BUNDLE" ]; then
echo "DOWNLOADING BUNDLE $INPUT_DOWNLOAD_BUNDLE"

crowdin download bundle $INPUT_DOWNLOAD_BUNDLE $@
crowdin bundle download $INPUT_DOWNLOAD_BUNDLE $@

if [ "$INPUT_PUSH_TRANSLATIONS" = true ]; then
[ -z "${GITHUB_TOKEN}" ] && {
Expand All @@ -440,9 +414,3 @@ if [ "$INPUT_DOWNLOAD_BUNDLE" ]; then
push_to_branch
fi
fi

if [ -n "$INPUT_DELETE_CROWDIN_BRANCH" ]; then
echo "REMOVING BRANCH $INPUT_DELETE_CROWDIN_BRANCH"

crowdin branch delete "$INPUT_DELETE_CROWDIN_BRANCH" $( get_branch_available_options "$@" )
fi

0 comments on commit 61ac8b9

Please sign in to comment.