Skip to content

Commit

Permalink
chore: add CI and release workflows (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
TrueBrain authored Apr 25, 2024
1 parent 957c702 commit 99ed000
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 11 deletions.
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
}

0 comments on commit 99ed000

Please sign in to comment.