Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add CI and release workflows #4

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/release-crate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Release Crate

on:
release:
types:
- published

jobs:
registries:
name: Publish to Crates.io
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable

- name: Set version
run: |
# Remove the "v" from the version.
VERSION=$(echo ${{ github.ref_name }} | cut -b2-)
echo "Version: ${VERSION}"

sed -i 's/version = "0.0.0-git"/version = "'${VERSION}'"/' Cargo.toml
sed -i 's/version = "0.0.0-git"/version = "'${VERSION}'"/' Cargo.lock

- name: Publish to crates.io
run: |
cargo publish --allow-dirty
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
48 changes: 48 additions & 0 deletions .github/workflows/release-npm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Release NPM

on:
release:
types:
- published

jobs:
registries:
name: Publish to GitHub NPM
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install Node toolchain
uses: actions/setup-node@v3
with:
node-version: '20'

- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable

- name: Install wasm-pack
run: |
cargo install wasm-pack

- name: Set version
run: |
# Remove the "v" from the version.
VERSION=$(echo ${{ github.ref_name }} | cut -b2-)
echo "Version: ${VERSION}"

sed -i 's/version = "0.0.0-git"/version = "'${VERSION}'"/' Cargo.toml

- name: Create NPM package
run: |
wasm-pack build --release
sed -i s%nile-library%@nile/library% pkg/package.json

- uses: JS-DevTools/npm-publish@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
registry: "https://npm.pkg.github.com"
package: pkg/package.json
36 changes: 36 additions & 0 deletions .github/workflows/testing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Testing

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
testing:
name: Testing
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable

- name: Install wasm-pack
run: |
cargo install wasm-pack

- name: Build library
run: |
wasm-pack build --release --target web
cargo build --release

- name: Check coding style
run: |
cargo fmt --check
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "nile-validator"
version = "0.1.0"
name = "nile-library"
version = "0.0.0-git"
edition = "2021"

[lib]
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# nile - String Validator
# nile-library - Library supporting nile

This repository contains OpenTTD's translation string validator for `nile`.
This repository contains the libirary that supports OpenTTD's translation tool `nile`.

This tool validates if a translation is valid for a given base-string, by following all the (sometimes complex) rules for OpenTTD.
This library for example validates if a translation is valid for a given base-string, and converts base-strings into a translatable form.

## Installation

Expand Down
8 changes: 4 additions & 4 deletions src/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ pub struct ValidationError {
* @returns A clear and specific error message if the translation is invalid. None otherwise.
*/
pub fn validate(
config: LanguageConfig,
base: String,
case: String,
translation: String,
_config: LanguageConfig,
_base: String,
_case: String,
_translation: String,
) -> Option<ValidationError> {
None
}
Loading