-
Notifications
You must be signed in to change notification settings - Fork 0
150 lines (124 loc) · 4.3 KB
/
Copy pathrelease.yml
File metadata and controls
150 lines (124 loc) · 4.3 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
name: Release & Publish
on:
push:
tags:
- 'v*'
permissions:
contents: write
id-token: write
jobs:
# ── Unit tests ──────────────────────────────────────────────────────────────
unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
defaults:
run:
working-directory: cli
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
cache-dependency-path: cli/package-lock.json
- name: Install dependencies
run: npm ci
- name: Run unit tests
run: npm run test
# ── E2E tests (requires Docker) ─────────────────────────────────────────────
e2e-tests:
name: E2E Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
cache-dependency-path: cli/package-lock.json
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Start Docker daemon and verify
run: |
sudo systemctl start docker || true
docker version
docker info
- name: Pull PostgreSQL image (cache warm-up)
run: docker pull postgres:16-alpine
- name: Install dependencies
working-directory: cli
run: npm ci
- name: Build
working-directory: cli
run: npm run build
- name: Run E2E tests
working-directory: cli
run: npm run test:e2e
env:
TESTCONTAINERS_RYUK_DISABLED: true
DOCKER_HOST: unix:///var/run/docker.sock
# ── Release & Publish (only after all tests pass) ───────────────────────────
release:
name: Release & Publish
needs: [unit-tests, e2e-tests]
runs-on: ubuntu-latest
defaults:
run:
working-directory: cli
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
cache-dependency-path: cli/package-lock.json
registry-url: https://registry.npmjs.org
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Extract version from tag
id: version
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> "$GITHUB_OUTPUT"
- name: Verify package.json version matches tag
run: |
PKG_VERSION=$(node -p "require('./package.json').version")
if [ "$PKG_VERSION" != "${{ steps.version.outputs.VERSION }}" ]; then
echo "Package version ($PKG_VERSION) does not match tag (${{ steps.version.outputs.VERSION }})"
exit 1
fi
- name: Generate changelog
id: changelog
run: |
PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
if [ -n "$PREVIOUS_TAG" ]; then
COMMITS=$(git log "$PREVIOUS_TAG"..HEAD --pretty=format:"- %s (%h)" --no-merges)
else
COMMITS=$(git log --pretty=format:"- %s (%h)" --no-merges -20)
fi
{
echo "CHANGELOG<<EOF"
echo "## What's Changed"
echo ""
echo "$COMMITS"
echo ""
echo "**Full Changelog**: https://github.com/${{ github.repository }}/compare/${PREVIOUS_TAG}...${{ github.ref_name }}"
echo "EOF"
} >> "$GITHUB_OUTPUT"
- name: Create GitHub Release
uses: actions/github-script@v7
with:
script: |
await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: context.refName,
name: `Release ${{ steps.version.outputs.VERSION }}`,
body: `${{ steps.changelog.outputs.CHANGELOG }}`,
draft: false,
prerelease: false
});
- name: Publish to npm
run: npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}