Skip to content

Commit

Permalink
chore: prepare release flow (#23)
Browse files Browse the repository at this point in the history
* chore: prepare release flow

* feat: export types in `tolgee-cli/extractor` for custom extractors

* fix: properly ignore extractor.d.ts

* fix: run build before releasing

πŸ€¦β€β™€οΈπŸ€¦β€β™€οΈπŸ€¦β€β™€οΈπŸ€¦β€β™€οΈπŸ€¦β€β™€οΈ

* feat: `prerelease` branch for `-rc.x`

* feat: test package integrity

* fix: specify runs-on in workflow

* chore: rename package to `@tolgee/cli`

* fix: extractor import test
  • Loading branch information
cyyynthia authored Jan 19, 2023
1 parent b9bb6e6 commit e56af05
Show file tree
Hide file tree
Showing 13 changed files with 15,965 additions and 5,394 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Release
on:
workflow_run:
workflows: [ Test ]
branches: [ main, next, prerelease ]
types:
- completed

jobs:
release:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18

- name: Cache dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: cache-node-modules-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
- name: Install dependencies
run: npm ci

- name: Build the CLI
run: npm run build
- name: Run npm release
run: npm run release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GIT_AUTHOR_NAME: Tolgee Machine
GIT_AUTHOR_EMAIL: [email protected]
GIT_COMMITTER_NAME: Tolgee Machine
GIT_COMMITTER_EMAIL: [email protected]
39 changes: 34 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Test
on:
push:
branches: [ main ]
branches: [ main, next, prerelease ]
pull_request:

jobs:
Expand All @@ -10,9 +10,19 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actionsx/prettier@v2
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Cache dependencies
uses: actions/cache@v3
with:
args: --check ./src ./test ./scripts jest.config.ts jest.unit.config.ts jest.e2e.config.ts
path: ~/.npm
key: cache-node-modules-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
- name: Install dependencies
run: npm ci

- name: Run prettier
run: npm run lint

test-unit:
name: Unit Tests
Expand All @@ -21,7 +31,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
- name: Cache dependencies
uses: actions/cache@v3
with:
Expand All @@ -40,7 +50,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
- name: Cache dependencies
uses: actions/cache@v3
with:
Expand All @@ -56,3 +66,22 @@ jobs:
- name: Stop Tolgee Container
run: npm run tolgee:stop
if: always()

test-package:
name: Package integrity
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: cache-node-modules-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
- name: Install dependencies
run: npm ci

- name: Validate package
run: npm run test:package
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@

node_modules
dist
node_modules
dist-types
extractor.d.ts
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
access=public
enable-pre-post-scripts=true
32 changes: 11 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,26 @@ An experimental πŸ§ͺ command line tool to interact with Tolgee directly from you
The CLI lets you pull strings from the Tolgee platform into your projects, push local strings to the Tolgee platform,
extract strings from your code, and much more!

- Pull requests welcomed! 🀩
- Pull requests welcome! 🀩

## Installation
> **Warning**
> As this package is still highly experimental πŸ§ͺ, the package is not available yet on NPM. You'll need to install
> it manually if you want to play with it!
The Tolgee CLI is published as a NPM package. You simply need to install it, and you're good to go!
```sh
npm i --global @tolgee/cli
```

Use `npm run run-dev -- <your command & options>` to run the CLI. For example:
> **Warning**: The Tolgee CLI is currently experimental and subject to bugs. Breaking changes may happen before stable release!
>
> Help us reach stable version faster by reporting any bug you encounter on the [issue tracker](https://github.com/tolgee/tolgee-cli/issues/new?labels=bug).
> Feedback is also greatly appreciated!
`npm run run-dev -- pull --project-id 1337 --api-key tgpak_geztgn27nbsxo53pebugcy3lmv3scijanvsw65zapzphoxt6 i18n`
See our [documentation](https://tolgee.io/tolgee-cli/installation) for more information.

## Usage
Once installed, you'll have access to the `tolgee` command. Run `tolgee help` to see all the supported commands, their
options and arguments.

## Authentication
You can save authentication tokens via the `tolgee login <api key>` command. Tokens will be stored on disk and will be
used anytime you invoke the CLI.

### Environment variables
In some scenarios (e.g. CI environment), the easiest way to pass sensitive information securely is via environment
variables. You can use the `TOLGEE_API_KEY` environment variable to pass credentials to the CLI.

## Configuration
To avoid having to specify common parameters every time you invoke the CLI, you can set them up for a whole project
via a `.tolgeerc.json` file at the root of your project.

The following parameters are supported:
- `apiUrl` (string): URL of the Tolgee server. Only needed if you're using a self-hosted installation.
- `projectId` (number): The ID of the project within Tolgee.
Make sure to give the [docs](https://tolgee.io/tolgee-cli/usage) a look!

## Contributing
Contributions are welcome! Check out [HACKING.md](HACKING.md) for some information about the project internals and
Expand Down
Loading

0 comments on commit e56af05

Please sign in to comment.