Skip to content

Commit 6c509db

Browse files
authored
feat: workflows
- added workflows - prettier - eslint - removed redundant declaration file
1 parent ec9880e commit 6c509db

26 files changed

+1773
-186
lines changed

.github/workflows/bump_version.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Bump version, commit and push tag
2+
# This workflow is triggered on push to a release branch (release/patch, release/minor, release/major).
3+
# It uses the npm-get-version-action to get the current version from package.json and bumps the version based on the branch name.
4+
# It also commits the changes made to package.json and pushes the tag to the repository.
5+
on:
6+
push:
7+
branches:
8+
- 'release/*'
9+
workflow_call:
10+
jobs:
11+
bump_version:
12+
# Only run if the PR is from a release branch (release/patch, release/minor, release/major)
13+
if: ${{ github.ref_name == 'release/patch' || github.ref_name == 'release/minor' || github.ref_name == 'release/major' }}
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
node-version: [ 20.x ]
18+
steps:
19+
# Checkout the repo
20+
- uses: actions/checkout@v4
21+
# Setup node
22+
- uses: actions/setup-node@v4
23+
with:
24+
node-version: ${{ matrix.node-version }}
25+
26+
- name: Install dependencies
27+
run: npm install
28+
29+
- name: Setup Git user
30+
run: |
31+
git config user.name "GitHub Actions"
32+
git config user.email "[email protected]"
33+
34+
- name: Check for uncommitted changes
35+
run: |
36+
if [ -n "$(git status --porcelain)" ]; then
37+
echo "Uncommitted changes detected. Committing..."
38+
git add .
39+
git commit -m "Pre-version bump changes"
40+
else
41+
echo "Working directory clean. Proceeding with version bump."
42+
fi
43+
44+
- name: Bump version patch
45+
if: github.ref == 'refs/heads/release/patch'
46+
run: npm run version:patch && git push --follow-tags
47+
48+
- name: Bump version minor
49+
if: github.ref == 'refs/heads/release/minor'
50+
run: npm run version:minor && git push --follow-tags
51+
52+
- name: Bump version major
53+
if: github.ref == 'refs/heads/release/major'
54+
run: npm run version:major && git push --follow-tags

.github/workflows/ci.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: CI
2+
# This workflow is triggered on push to the main branch.
3+
# It uses the npm-get-version-action to get the current version from package.json and creates a GitHub release from the latest tag.
4+
# It also publishes the package to NPM.
5+
on:
6+
push:
7+
branches:
8+
- 'main'
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
strategy:
15+
matrix:
16+
node-version: [ 20.x ]
17+
steps:
18+
# Checkout the repo
19+
- uses: actions/checkout@v4
20+
with :
21+
ref: ${{ github.refs }}
22+
# Setup node
23+
- uses: actions/setup-node@v4
24+
with:
25+
node-version: ${{ matrix.node-version }}
26+
# Add the registry URL to publish to NPM (optional)
27+
registry-url: 'https://registry.npmjs.org'
28+
# Add the scope of the package to publish to NPM (optional)
29+
scope: '@rohit1901'
30+
# Install dependencies
31+
- name: Install dependencies
32+
if: ${{ success() }}
33+
run: npm install
34+
# Get the current version from package.json
35+
- name: Get the current version from package.json
36+
id: package-version
37+
uses: martinbeentjes/[email protected]
38+
# Build the project
39+
- name: Build the project
40+
if: ${{ success() }}
41+
run: npm run build
42+
# Create a GitHub release
43+
- name: Create a GitHub Release from the latest tag
44+
if: ${{ success() }}
45+
run: gh release create v${{ steps.package-version.outputs.current-version }}
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
# Publish to NPM
49+
- name: Publish to NPM
50+
if: ${{ success() }}
51+
run: npm publish --access public
52+
env:
53+
NODE_AUTH_TOKEN: ${{secrets.NPM_PUBLISH_TOKEN}}

.github/workflows/test_format.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Test and format
2+
# This workflow is triggered on push to any feature branch. It runs tests, lints, formats, and builds the project.
3+
# It also commits the changes made by the prettier formatter.
4+
on:
5+
push:
6+
branches:
7+
- 'feature/*'
8+
workflow_call:
9+
jobs:
10+
format_test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
node-version: [ 20.x ]
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: actions/setup-node@v4
18+
with:
19+
node-version: ${{ matrix.node-version }}
20+
- run: npm install
21+
- run: npm run lint
22+
- run: npm run format
23+
- run: npm test --if-present
24+
- run: npm run build --if-present
25+
# Commit changes
26+
- name: Commit changes using git-auto-commit-action@v5
27+
uses: stefanzweifel/[email protected]
28+
id: auto-commit-action
29+
with:
30+
commit_message: Prettier format

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,8 @@ node_modules
88
dist
99

1010
# MacOS
11-
.DS_Store
11+
.DS_Store
12+
13+
# TypeScript
14+
*.tsbuildinfo
15+
*.d.ts

.prettierignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
dist/
2+
.idea/
3+
*.tgz
4+
*lock.json

.prettierrc

Whitespace-only changes.

eslint.config.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// @ts-check
2+
3+
import eslint from '@eslint/js';
4+
import tseslint from 'typescript-eslint';
5+
6+
export default tseslint.config(
7+
eslint.configs.recommended,
8+
...tseslint.configs.recommended,
9+
{
10+
rules: {
11+
'no-prototype-builtins': 'off',
12+
'@typescript-eslint/no-explicit-any': 'off',
13+
}
14+
}
15+
);

example/example.app.d.ts

Lines changed: 0 additions & 2 deletions
This file was deleted.

example/example.main.d.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

example/example.main.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import React from 'react'
22
import ReactDOM from 'react-dom/client'
3-
import {IntlReact} from "../src/t.tsx";
3+
import {IntlReact} from "../src/t";
44
import en from "../src/i18n/en.json";
55
import de from "../src/i18n/de.json";
6-
import ExampleApp from "./example.app.tsx";
6+
import ExampleApp from "./example.app";
77

88
ReactDOM.createRoot(document.getElementById('root')!).render(
99
<React.StrictMode>

0 commit comments

Comments
 (0)