-
Notifications
You must be signed in to change notification settings - Fork 0
101 lines (80 loc) · 3.02 KB
/
ci.yml
File metadata and controls
101 lines (80 loc) · 3.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
name: CI
on:
push:
branches: [main]
tags: ['v*.*.*'] # Trigger on version tags
pull_request:
branches: [main]
workflow_dispatch: # Allow manual trigger
jobs:
validate:
name: Validate Code & Run Tests
runs-on: [self-hosted, linux, x64] # Use Ubuntu runner
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v2 # Use official setup-bun action
- name: Install dependencies
run: bun install --frozen-lockfile # Use frozen lockfile for reproducibility
- name: Check formatting
run: bun run check-format
- name: Lint code
run: bun run lint
- name: Run tests with coverage
run: bun run test:cov # This will fail if coverage < 100% due to vitest.config.ts
# Optional: Upload coverage report (e.g., to Codecov)
# - name: Upload coverage reports to Codecov
# uses: codecov/codecov-action@v4
# with:
# token: ${{ secrets.CODECOV_TOKEN }} # Store token in GitHub secrets
# files: ./coverage/lcov.info # Path to lcov report
publish:
name: Publish to npm
needs: validate # Run only if validate job succeeds
if: startsWith(github.ref, 'refs/tags/v') # Run only on tag push
runs-on: [self-hosted, linux, x64]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v2
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Build project
run: bun run build # Assumes build script handles everything
- name: Setup Node.js for npm publish
uses: actions/setup-node@v4
with:
node-version: 'lts/*' # Use LTS Node.js version
registry-url: 'https://registry.npmjs.org' # Point to npm registry
- name: Publish to npm
run: npm publish --access public # Publish the package
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} # Store token in GitHub secrets
# Optional: Build and push Docker image if applicable
# - name: Build and push Docker image
# uses: docker/build-push-action@v5
# with:
# context: .
# push: true
# tags: your-dockerhub-username/media-curator:${{ github.ref_name }} # Example tag
release:
name: Create GitHub Release
needs: publish # Run only if publish job succeeds
if: startsWith(github.ref, 'refs/tags/v') # Run only on tag push
runs-on: [self-hosted, linux, x64]
permissions:
contents: write # Needed to create releases
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for release notes generation
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true # Auto-generate release notes from Conventional Commits
# Optional: Upload build artifacts to the release
# files: |
# dist/*