Skip to content

Commit c86a646

Browse files
authored
Add workflow (#25)
1 parent 629dbeb commit c86a646

File tree

3 files changed

+204
-1
lines changed

3 files changed

+204
-1
lines changed

.github/workflows/deployment.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Deployment
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
8+
jobs:
9+
check-changes:
10+
runs-on: ubuntu-latest
11+
outputs:
12+
changed: ${{ steps.filter.outputs.changed }}
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: '20.x'
21+
22+
- name: Check for changes in .ts and .tsx files
23+
id: filter
24+
uses: dorny/paths-filter@v3
25+
with:
26+
filters: |
27+
changed:
28+
- 'src/**/*.ts'
29+
- 'src/**/*.tsx'
30+
31+
deploy:
32+
runs-on: ubuntu-latest
33+
needs: check-changes
34+
if: ${{ needs.check-changes.outputs.changed == 'true' }}
35+
steps:
36+
- name: Checkout code
37+
uses: actions/checkout@v4
38+
with:
39+
fetch-depth: 0
40+
41+
- name: Set up Node.js
42+
uses: actions/setup-node@v4
43+
with:
44+
node-version: '20.x'
45+
46+
- name: Enable Corepack
47+
run: corepack enable
48+
49+
- name: Install dependencies
50+
run: yarn install
51+
52+
- name: Bump version
53+
run: yarn version patch
54+
55+
- name: Publish package
56+
run: |
57+
echo "npmAuthToken: \${NPM_TOKEN}" >> .yarnrc.yml
58+
yarn npm publish
59+
env:
60+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
61+
62+
- name: Set git username with email
63+
run: |
64+
git config user.name "pumpkiinbell"
65+
git config user.email "[email protected]"
66+
67+
- name: Tag version
68+
run: |
69+
VERSION=$(jq -r '.version' package.json)
70+
COMMIT_MESSAGE=$(git log -1 --pretty=%B)
71+
git tag -a "v$VERSION" -m "$COMMIT_MESSAGE"
72+
73+
- name: Commit version bump
74+
run: |
75+
VERSION=$(jq -r '.version' package.json)
76+
git add package.json
77+
git commit -m "bump version to $VERSION"
78+
79+
- name: Push changes and tags
80+
run: |
81+
git push -u origin HEAD --follow-tags --force
82+
env:
83+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/integration.yml

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: Integration
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- develop
7+
8+
jobs:
9+
check-changes:
10+
runs-on: ubuntu-latest
11+
outputs:
12+
changed: ${{ steps.filter.outputs.changed }}
13+
changed_files: ${{ steps.filter.outputs.changed_files }}
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Set up Node.js
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: '20.x'
22+
23+
- name: Check for changes in .ts and .tsx files
24+
id: filter
25+
uses: dorny/paths-filter@v3
26+
with:
27+
list-files: csv
28+
filters: |
29+
changed:
30+
- 'src/**/*.ts'
31+
- 'src/**/*.tsx'
32+
33+
verify-documentation:
34+
runs-on: ubuntu-latest
35+
needs: check-changes
36+
if: ${{ needs.check-changes.outputs.changed == 'true' }}
37+
steps:
38+
- name: Checkout code
39+
uses: actions/checkout@v4
40+
41+
- name: Verify documentation exists
42+
run: |
43+
for file in $(echo "${{ needs.check-changes.outputs.changed_files }}" | tr ',' '\n'); do
44+
if [[ "$file" != *.ts && "$file" != *.tsx ]]; then
45+
continue
46+
fi
47+
dir_name=$(basename $(dirname "$file"))
48+
base_name=$(basename "${file%.*}")
49+
if [ "$dir_name" != "$base_name" ]; then
50+
continue
51+
fi
52+
doc_file="$(dirname "$file")/$base_name.md"
53+
if [ ! -f "$doc_file" ]; then
54+
echo "Documentation missing for $file"
55+
exit 1
56+
fi
57+
done
58+
59+
verify-test:
60+
runs-on: ubuntu-latest
61+
needs: check-changes
62+
if: ${{ needs.check-changes.outputs.changed == 'true' }}
63+
steps:
64+
- name: Checkout code
65+
uses: actions/checkout@v4
66+
67+
- name: Set up Node.js
68+
uses: actions/setup-node@v4
69+
with:
70+
node-version: '20.x'
71+
72+
- name: Verify and run tests with coverage
73+
run: |
74+
corepack enable
75+
yarn install
76+
77+
for file in $(echo "${{ needs.check-changes.outputs.changed_files }}" | tr ',' '\n'); do
78+
if [[ "$file" != *.ts && "$file" != *.tsx ]]; then
79+
continue
80+
fi
81+
dir_name=$(basename $(dirname "$file"))
82+
base_name=$(basename "${file%.*}")
83+
if [ "$dir_name" != "$base_name" ]; then
84+
continue
85+
fi
86+
test_file="$(dirname "$file")/$base_name.spec.ts"
87+
if [ ! -f "$test_file" ]; then
88+
test_file="$(dirname "$file")/$base_name.spec.tsx"
89+
if [ ! -f "$test_file" ]; then
90+
echo "Test file missing for $file"
91+
exit 1
92+
fi
93+
fi
94+
yarn run test:coverage $test_file
95+
done
96+
97+
verify-jsdoc:
98+
runs-on: ubuntu-latest
99+
needs: check-changes
100+
if: ${{ needs.check-changes.outputs.changed == 'true' }}
101+
steps:
102+
- name: Checkout code
103+
uses: actions/checkout@v4
104+
105+
- name: Check for JSDoc comments
106+
run: |
107+
for file in $(echo "${{ needs.check-changes.outputs.changed_files }}" | tr ',' '\n'); do
108+
if [[ "$file" != *.ts && "$file" != *.tsx ]]; then
109+
continue
110+
fi
111+
dir_name=$(basename $(dirname "$file"))
112+
base_name=$(basename "${file%.*}")
113+
if [ "$dir_name" != "$base_name" ]; then
114+
continue
115+
fi
116+
if ! grep -q "/**" "$file"; then
117+
echo "JSDoc comments missing in $file"
118+
exit 1
119+
fi
120+
done

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "reactive-kit",
3-
"version": "0.1.0",
3+
"version": "0.2.2",
44
"main": "./src/index.ts",
55
"files": [
66
"dist/**/*",

0 commit comments

Comments
 (0)