Skip to content

Commit 476e2f5

Browse files
authored
fix: re-introduce integration tests + new workflow + library updates. (#60)
* re-introduce tests + improve workflow + lib updates. * remove yarn.lock
1 parent 777f781 commit 476e2f5

21 files changed

+4337
-4525
lines changed

.github/workflows/main.yml

Lines changed: 93 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,103 @@
1-
name: status
2-
on: push
1+
name: Auto Release
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
permissions:
9+
id-token: write # Required for OIDC
10+
contents: read
311

412
jobs:
5-
npm:
6-
name: Publish to NPM
13+
release:
14+
# Prevent infinite loop
15+
if: github.actor != 'github-actions[bot]'
716
runs-on: ubuntu-latest
17+
818
steps:
9-
- uses: actions/checkout@master
10-
- uses: actions/setup-node@master
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
# ✅ Ensure merge came from development
25+
- name: Ensure merge came from development
26+
id: check_merge
27+
run: |
28+
COMMIT_MSG=$(git log -1 --pretty=%B)
29+
30+
echo "$COMMIT_MSG"
31+
32+
if echo "$COMMIT_MSG" | grep -q "development"; then
33+
echo "merged=true" >> $GITHUB_OUTPUT
34+
else
35+
echo "merged=false" >> $GITHUB_OUTPUT
36+
fi
37+
38+
- name: Stop if not a development merge
39+
if: steps.check_merge.outputs.merged != 'true'
40+
run: |
41+
echo "Not a development merge. Skipping."
42+
exit 0
43+
44+
- name: Setup Node
45+
uses: actions/setup-node@v4
1146
with:
12-
node-version: "12.x"
47+
node-version: 22
48+
- run: npm install
49+
- run: npm run format
50+
- run: npm run lint
51+
- run: npm run build
52+
53+
# ✅ Detect bump type from commit message
54+
- name: Detect version bump type
55+
id: bump_type
56+
run: |
57+
COMMIT_MSG=$(git log -1 --pretty=%B)
58+
59+
if echo "$COMMIT_MSG" | grep -qi "^refactor:"; then
60+
echo "type=major" >> $GITHUB_OUTPUT
61+
elif echo "$COMMIT_MSG" | grep -qi "^feat:"; then
62+
echo "type=minor" >> $GITHUB_OUTPUT
63+
elif echo "$COMMIT_MSG" | grep -qi "^fix:"; then
64+
echo "type=patch" >> $GITHUB_OUTPUT
65+
else
66+
echo "type=patch" >> $GITHUB_OUTPUT
67+
fi
1368
14-
- name: install
15-
run: npm install
69+
# ✅ Bump version
70+
- name: Bump version
71+
run: |
72+
npm version ${{ steps.bump_type.outputs.type }} --no-git-tag-version
1673
17-
- name: format
18-
run: npm run format
74+
git config user.name "github-actions[bot]"
75+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
1976
20-
- name: lint
21-
run: npm run lint
77+
git add package.json
78+
if [ -f package-lock.json ]; then
79+
git add package-lock.json
80+
fi
2281
23-
- name: build
24-
run: scripts/build_and_move
82+
git commit -m "ci: bump ${{ steps.bump_type.outputs.type }} version [skip ci]"
83+
git push
2584
26-
- name: publish (npm)
27-
uses: primer/publish@v2.0.0
28-
env:
29-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30-
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
31-
args: "--dry-run -- --unsafe-perm"
85+
# ✅ Get new version
86+
- name: Get final version
87+
id: final_version
88+
run: |
89+
VERSION=$(node -p "require('./package.json').version")
90+
echo "version=$VERSION" >> $GITHUB_OUTPUT
91+
92+
# ✅ Create tag
93+
- name: Create tag
94+
run: |
95+
git tag v${{ steps.final_version.outputs.version }}
96+
git push origin v${{ steps.final_version.outputs.version }}
97+
98+
# ✅ Create GitHub Release
99+
- name: Create GitHub Release
100+
uses: softprops/action-gh-release@v2
101+
with:
102+
tag_name: v${{ steps.final_version.outputs.version }}
103+
name: Release v${{ steps.final_version.outputs.version }}

package.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,20 @@
2626
"test": "jest"
2727
},
2828
"dependencies": {
29-
"got": "^11.8.2",
29+
"got": "^11.8.6",
3030
"slugify": "^1.5.0"
3131
},
3232
"devDependencies": {
33-
"@types/jest": "^26.0.23",
34-
"@typescript-eslint/eslint-plugin": "^4.22.0",
35-
"@typescript-eslint/parser": "^4.22.0",
36-
"eslint": "^7.25.0",
37-
"eslint-config-prettier": "^8.3.0",
38-
"jest": "^26.6.3",
39-
"prettier": "^2.2.1",
40-
"rimraf": "^3.0.2",
41-
"ts-jest": "^26.5.5",
42-
"typescript": "^4.2.4"
33+
"@types/jest": "^30.0.0",
34+
"@typescript-eslint/eslint-plugin": "^8.56.1",
35+
"@typescript-eslint/parser": "^8.56.1",
36+
"eslint": "^10.0.2",
37+
"eslint-config-prettier": "^10.1.8",
38+
"jest": "^30.2.0",
39+
"prettier": "^3.8.1",
40+
"rimraf": "^6.1.3",
41+
"ts-jest": "^29.4.6",
42+
"typescript": "^5.9.3"
4343
},
4444
"repository": {
4545
"type": "git",
@@ -61,4 +61,4 @@
6161
}
6262
},
6363
"license": "MIT"
64-
}
64+
}

0 commit comments

Comments
 (0)