DEV Community

Cover image for Localazy Release Tags management with GitHub Actions
Localazy Team for Localazy

Posted on • Originally published at localazy.com

Localazy Release Tags management with GitHub Actions

Release Tags are a great way of managing differing states of your translation. E.g., you can use one tag for production while another for the testing environment. To make things easier, it’s now possible to automate this process with GitHub actions.

We already support automated uploads and downloads with GitHub Actions for some time. For a general dive-in into the basic usage of Localazy's GitHub actions, check out our previous article. Today, we're going to look at how we can take this automation one step further.

Read the article: Automated Localization: GitHub Actions ❀ Localazy

🏷️ What are release tags?

Release tags work pretty much like tags on GitHub, GitLab, or Docker. They allow you to mark the state of your Localazy app, preserving the translations and translation progress at the given time, which is super helpful, for instance, when you use different branches for production, testing, and development.

You can preserve translations for production for as long as you are working on a new release, and only once you publish it, you start using the latest translations as well.

You can read more about Release tags in the documentation.

πŸ“š A comprehensive overview

In the lines below, you'll find a comprehensive overview of everything Localazy's Tag action can do for you. All the options are based on the capabilities of Localazy CLI.

Check out related documentation to read about every option in greater detail.

To run a GH action, you need to create a YAML file in .github/workflows in your code. Each example represents a single step of a complete custom workflow. You can skip to see the full workflow to see the whole configuration.

The following paragraphs presume you have access to Release tags through an active professional plan and you have integrated Localazy in your code (there are write and read keys in either localazy.json or localazy.keys.json)

List tags

This lists all the tags associated with your application.

      - name: List tags
        uses: localazy/tag@v1
        with:
          list: true
Enter fullscreen mode Exit fullscreen mode

Publish tag

This command saves the current state of your app under a given new-tag name.

      - name: Publish new-tag
        uses: localazy/tag@v1
        with:
          publish: 'new-tag'
Enter fullscreen mode Exit fullscreen mode

Promote tag

Replaces the target tag, new-tag-2, with the state of the new-tag.

      - name: Promote new-tag
        uses: localazy/tag@v1   
        with:
          promote_from: 'new-tag'
          promote_to: 'new-tag-2'
Enter fullscreen mode Exit fullscreen mode

Rename tag

Simply renames the target tag.

      - name: Rename new-tag
        uses: localazy/tag@v1   
        with:
          rename_from: 'new-tag'
          rename_to: 'renamed-tag'
Enter fullscreen mode Exit fullscreen mode

Merge tags

Merging tags allows you to apply translations from the source tag to the target tag. The result of the operation is stored as the output tag. Several optional parameters alter what kind of changes are applied.

Check out the documentation for a complete overview.

In this example, we merge state of the renamed-tag into new-tag-2 and save the output under a new merged-tag. On top of that, we added a single parameter --add-languages which adds any missing language to the target tag if the source tag contains any additional languages.

      - name: Merge tag
        uses: localazy/tag@v1   
        with:
          merge_from: 'renamed-tag'
          merge_to: 'new-tag-2'
          merge_output: 'merged-tag'
          merge_parameters: '--add-languages'
Enter fullscreen mode Exit fullscreen mode

Delete tag

Lastly, this command deletes an existing tag.

      - name: Delete renamed-tag
        uses: localazy/tag@v1   
        with:
          delete: 'renamed-tag'
Enter fullscreen mode Exit fullscreen mode

πŸ—ƒοΈ Full workflow

When this workflow successfully finishes, it will leave your app in the same state as before since the config will delete all the newly created tags at the end. Feel free to create a new testing project and try it out.

### .github/workflows/locales.yml

on: [push]

jobs:
  release_tags:
    runs-on: ubuntu-latest
    name: Complex overview of tags management
    steps:
      - uses: actions/checkout@v1
      - name: List tags
        uses: localazy/tag@v1
        with:
          list: true
      - name: Publish new-tag
        uses: localazy/tag@v1
        with:
          publish: 'new-tag'
      - name: Publish new-tag-2
        uses: localazy/tag@v1   
        with:
          publish: 'new-tag-2'
      - name: Promote new-tag
        uses: localazy/tag@v1   
        with:
          promote_from: 'new-tag'
          promote_to: 'new-tag-2'
      - name: Rename new-tag
        uses: localazy/tag@v1   Q
        with:
          rename_from: 'new-tag'
          rename_to: 'renamed-tag'
      - name: Merge tag
        uses: localazy/tag@v1   
        with:
          merge_from: 'renamed-tag'
          merge_to: 'new-tag-2'
          merge_output: 'merged-tag'
          merge_parameters: '--add-languages'
      - name: Delete renamed-tag
        uses: localazy/tag@v1   
        with:
          delete: 'renamed-tag'
      - name: Delete merged-tag
        uses: localazy/tag@v1   
        with:
          delete: 'merged-tag'
      - name: Delete new-tag-2
        uses: localazy/tag@v1   
        with:
          delete: 'new-tag-2'
Enter fullscreen mode Exit fullscreen mode

βœ”οΈ Closing words

This was a comprehensive overview of what you can do with Github actions and Localazy's Release Tags. You may checkout the sample repo for reference. Happy coding!

You might also like

Top comments (0)