Skip to content

Commit e99be2f

Browse files
committed
chore: Add ci-cd, publish, and release Github Actions
1 parent b0cd570 commit e99be2f

File tree

4 files changed

+277
-6
lines changed

4 files changed

+277
-6
lines changed

.github/workflows/ci-cd.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: CI/CD Pipeline
2+
3+
on:
4+
push:
5+
branches: [main, develop]
6+
tags: ['v*']
7+
pull_request:
8+
branches: [main, develop]
9+
release:
10+
types: [published]
11+
12+
jobs:
13+
test:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Setup Bun
20+
uses: oven-sh/setup-bun@v2
21+
with:
22+
bun-version: latest
23+
24+
- name: Install dependencies
25+
run: bun install --frozen-lockfile
26+
27+
- name: Lint
28+
run: bun run lint
29+
30+
- name: Build
31+
run: bun run build
32+
33+
- name: Install Playwright browsers
34+
run: bunx playwright install --with-deps
35+
36+
- name: Run tests
37+
run: bun run test
38+
39+
- name: Upload test results
40+
uses: actions/upload-artifact@v4
41+
if: always()
42+
with:
43+
name: playwright-report
44+
path: playwright-report/
45+
retention-days: 30
46+
47+
publish:
48+
needs: test
49+
runs-on: ubuntu-latest
50+
if: github.event_name == 'release' && github.event.action == 'published'
51+
permissions:
52+
contents: read
53+
id-token: write # Required for npm provenance
54+
55+
steps:
56+
- name: Checkout code
57+
uses: actions/checkout@v4
58+
59+
- name: Setup Bun
60+
uses: oven-sh/setup-bun@v2
61+
with:
62+
bun-version: latest
63+
64+
- name: Install dependencies
65+
run: bun install --frozen-lockfile
66+
67+
- name: Build package
68+
run: bun run build
69+
70+
- name: Setup Node.js for npm
71+
uses: actions/setup-node@v4
72+
with:
73+
node-version: '20'
74+
registry-url: 'https://registry.npmjs.org'
75+
76+
- name: Verify package version matches tag
77+
run: |
78+
PACKAGE_VERSION=$(node -p "require('./package.json').version")
79+
TAG_VERSION=${GITHUB_REF#refs/tags/v}
80+
if [ "$PACKAGE_VERSION" != "$TAG_VERSION" ]; then
81+
echo "Package version ($PACKAGE_VERSION) doesn't match tag version ($TAG_VERSION)"
82+
exit 1
83+
fi
84+
85+
- name: Publish to npm
86+
run: npm publish --access public --provenance
87+
env:
88+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
89+
90+
- name: Create deployment status
91+
uses: actions/github-script@v7
92+
with:
93+
script: |
94+
github.rest.repos.createDeploymentStatus({
95+
owner: context.repo.owner,
96+
repo: context.repo.repo,
97+
deployment_id: context.payload.deployment?.id || 0,
98+
state: 'success',
99+
environment: 'npm',
100+
target_url: 'https://www.npmjs.com/package/@zeix/le-truc'
101+
});

.github/workflows/publish.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Publish to npm
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
inputs:
8+
version:
9+
description: 'Version to publish (leave empty to use package.json version)'
10+
required: false
11+
type: string
12+
13+
jobs:
14+
publish:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
id-token: write # Required for npm provenance
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
24+
- name: Setup Bun
25+
uses: oven-sh/setup-bun@v2
26+
with:
27+
bun-version: latest
28+
29+
- name: Install dependencies
30+
run: bun install --frozen-lockfile
31+
32+
- name: Build package
33+
run: bun run build
34+
35+
- name: Setup Node.js for npm
36+
uses: actions/setup-node@v4
37+
with:
38+
node-version: '20'
39+
registry-url: 'https://registry.npmjs.org'
40+
41+
- name: Update version (if specified)
42+
if: github.event.inputs.version != ''
43+
run: npm version ${{ github.event.inputs.version }} --no-git-tag-version
44+
45+
- name: Publish to npm
46+
run: npm publish --access public --provenance
47+
env:
48+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
49+
50+
- name: Create GitHub release (if manual dispatch)
51+
if: github.event_name == 'workflow_dispatch'
52+
uses: actions/create-release@v1
53+
env:
54+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55+
with:
56+
tag_name: v${{ steps.version.outputs.version || fromJson(steps.package.outputs.json).version }}
57+
release_name: Release v${{ steps.version.outputs.version || fromJson(steps.package.outputs.json).version }}
58+
draft: false
59+
prerelease: false

.github/workflows/release.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version_type:
7+
description: 'Version bump type'
8+
required: true
9+
type: choice
10+
options:
11+
- patch
12+
- minor
13+
- major
14+
default: 'patch'
15+
prerelease:
16+
description: 'Create prerelease'
17+
required: false
18+
type: boolean
19+
default: false
20+
21+
jobs:
22+
release:
23+
runs-on: ubuntu-latest
24+
permissions:
25+
contents: write
26+
id-token: write
27+
28+
steps:
29+
- name: Checkout code
30+
uses: actions/checkout@v4
31+
with:
32+
token: ${{ secrets.GITHUB_TOKEN }}
33+
fetch-depth: 0
34+
35+
- name: Setup Bun
36+
uses: oven-sh/setup-bun@v2
37+
with:
38+
bun-version: latest
39+
40+
- name: Install dependencies
41+
run: bun install --frozen-lockfile
42+
43+
- name: Run tests and build
44+
run: bun run build
45+
46+
- name: Configure Git
47+
run: |
48+
git config user.name "github-actions[bot]"
49+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
50+
51+
- name: Bump version
52+
id: version
53+
run: |
54+
if [ "${{ github.event.inputs.prerelease }}" = "true" ]; then
55+
NEW_VERSION=$(npm version pre${{ github.event.inputs.version_type }} --preid=beta --no-git-tag-version)
56+
else
57+
NEW_VERSION=$(npm version ${{ github.event.inputs.version_type }} --no-git-tag-version)
58+
fi
59+
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
60+
echo "version_number=${NEW_VERSION#v}" >> $GITHUB_OUTPUT
61+
62+
- name: Update changelog
63+
run: |
64+
echo "## ${{ steps.version.outputs.new_version }} - $(date +%Y-%m-%d)" >> CHANGELOG_NEW.md
65+
echo "" >> CHANGELOG_NEW.md
66+
echo "- Version bump: ${{ github.event.inputs.version_type }}" >> CHANGELOG_NEW.md
67+
echo "" >> CHANGELOG_NEW.md
68+
if [ -f CHANGELOG.md ]; then
69+
cat CHANGELOG.md >> CHANGELOG_NEW.md
70+
fi
71+
mv CHANGELOG_NEW.md CHANGELOG.md
72+
73+
- name: Commit changes
74+
run: |
75+
git add package.json CHANGELOG.md
76+
git commit -m "chore: bump version to ${{ steps.version.outputs.new_version }}"
77+
git tag ${{ steps.version.outputs.new_version }}
78+
git push origin main
79+
git push origin ${{ steps.version.outputs.new_version }}
80+
81+
- name: Create GitHub Release
82+
uses: actions/create-release@v1
83+
env:
84+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
85+
with:
86+
tag_name: ${{ steps.version.outputs.new_version }}
87+
release_name: Release ${{ steps.version.outputs.new_version }}
88+
draft: false
89+
prerelease: ${{ github.event.inputs.prerelease }}
90+
body: |
91+
## Changes in ${{ steps.version.outputs.new_version }}
92+
93+
This release was created automatically via GitHub Actions.
94+
95+
**Version bump:** ${{ github.event.inputs.version_type }}
96+
**Prerelease:** ${{ github.event.inputs.prerelease }}
97+
98+
View the full changelog at [CHANGELOG.md](https://github.com/${{ github.repository }}/blob/main/CHANGELOG.md)

package.json

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{
22
"name": "@zeix/le-truc",
33
"version": "0.15.0",
4-
"license": "MIT",
5-
"author": "Esther Brunner",
4+
"description": "Le Truc - the thing for type-safe reactive web components",
65
"keywords": [
76
"Le Truc",
87
"Web Components",
@@ -12,10 +11,24 @@
1211
"Signals",
1312
"Effects"
1413
],
15-
"module": "index.ts",
14+
"homepage": "https://github.com/zeixcom/le-truc#readme",
15+
"bugs": {
16+
"url": "https://github.com/zeixcom/le-truc/issues"
17+
},
18+
"repository": {
19+
"type": "git",
20+
"url": "git+https://github.com/zeixcom/le-truc.git"
21+
},
22+
"license": "MIT",
23+
"author": "Esther Brunner",
1624
"type": "module",
1725
"main": "index.js",
26+
"module": "index.ts",
1827
"types": "types/index.d.ts",
28+
"directories": {
29+
"doc": "docs",
30+
"example": "examples"
31+
},
1932
"scripts": {
2033
"build:prod": "bun build index.ts --outdir ./ --minify --define process.env.DEV_MODE=false --sourcemap=external",
2134
"build:dev": "BUN_ENV=development bun build index.dev.ts --outdir ./ --define process.env.DEV_MODE=true",
@@ -32,6 +45,9 @@
3245
"serve": "bun server/serve.ts --mode unified --build-first",
3346
"test": "bunx playwright test examples"
3447
},
48+
"dependencies": {
49+
"@zeix/cause-effect": "^0.16.1"
50+
},
3551
"devDependencies": {
3652
"@biomejs/biome": "^2.3.8",
3753
"@markdoc/markdoc": "^0.5.4",
@@ -44,8 +60,5 @@
4460
},
4561
"peerDependencies": {
4662
"typescript": "^5.9.3"
47-
},
48-
"dependencies": {
49-
"@zeix/cause-effect": "^0.16.1"
5063
}
5164
}

0 commit comments

Comments
 (0)