-
Notifications
You must be signed in to change notification settings - Fork 0
119 lines (99 loc) · 3.35 KB
/
Copy pathci.yml
File metadata and controls
119 lines (99 loc) · 3.35 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
runs-on: blacksmith-2vcpu-ubuntu-2404
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install dependencies
run: bun install
- name: Type check
run: bun run typecheck
- name: Build
run: bun run build
- name: Verify build output
run: |
test -f dist/index.js || exit 1
test -f dist/cli.js || exit 1
shell: bash
website:
runs-on: blacksmith-2vcpu-ubuntu-2404
defaults:
run:
working-directory: website
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "22"
cache: npm
cache-dependency-path: website/package-lock.json
- name: Install dependencies
run: npm ci
- name: Type check
run: npm run typecheck
- name: Build
run: npm run build
# Auto-create version tag when package.json version changes on main
auto-tag:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: test
runs-on: blacksmith-2vcpu-ubuntu-2404
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 2
- name: Check for version change
id: version
run: |
# Get current version from package.json
CURRENT_VERSION=$(jq -r '.version' package.json)
echo "current=$CURRENT_VERSION" >> $GITHUB_OUTPUT
# Get previous version from the commit before
git show HEAD~1:package.json > /tmp/prev-package.json 2>/dev/null || echo '{"version":"0.0.0"}' > /tmp/prev-package.json
PREV_VERSION=$(jq -r '.version' /tmp/prev-package.json)
echo "previous=$PREV_VERSION" >> $GITHUB_OUTPUT
# Check if version changed
if [ "$CURRENT_VERSION" != "$PREV_VERSION" ]; then
echo "changed=true" >> $GITHUB_OUTPUT
echo "Version changed: $PREV_VERSION -> $CURRENT_VERSION"
else
echo "changed=false" >> $GITHUB_OUTPUT
echo "Version unchanged: $CURRENT_VERSION"
fi
- name: Check if tag exists
if: steps.version.outputs.changed == 'true'
id: tag-check
run: |
TAG="v${{ steps.version.outputs.current }}"
if git ls-remote --tags origin | grep -q "refs/tags/$TAG"; then
echo "exists=true" >> $GITHUB_OUTPUT
echo "Tag $TAG already exists"
else
echo "exists=false" >> $GITHUB_OUTPUT
echo "Tag $TAG does not exist"
fi
- name: Create and push tag
if: steps.version.outputs.changed == 'true' && steps.tag-check.outputs.exists == 'false'
run: |
TAG="v${{ steps.version.outputs.current }}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "$TAG" -m "Release $TAG"
git push origin "$TAG"
echo "Created and pushed tag: $TAG"
echo "This tag push will automatically trigger the Release workflow"