-
Notifications
You must be signed in to change notification settings - Fork 0
206 lines (174 loc) · 5.53 KB
/
Copy pathrelease.yml
File metadata and controls
206 lines (174 loc) · 5.53 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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
name: Release
on:
push:
tags:
- "v*"
permissions:
contents: write
packages: write
id-token: write
env:
NODE_VERSION: "22"
PNPM_VERSION: "9.15.0"
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
validate:
name: Validate Tag
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Extract version from tag
id: version
run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
- name: Validate semver
run: |
VERSION="${{ steps.version.outputs.version }}"
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$ ]]; then
echo "::error::Invalid semver tag: $VERSION"
exit 1
fi
build:
name: Build Packages
runs-on: ubuntu-latest
needs: [validate]
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: pnpm
registry-url: "https://registry.npmjs.org"
- run: pnpm install --frozen-lockfile
- run: pnpm build
- name: Verify build artifacts
run: |
test -d packages/shared/dist
test -d packages/core/dist
test -d packages/sdk/dist
test -d packages/x402-compliance/dist
test -d packages/mcp-server/dist
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: release-build
path: |
packages/*/dist
packages/*/package.json
apps/api/dist
publish-npm:
name: Publish to npm
runs-on: ubuntu-latest
needs: [build]
strategy:
fail-fast: true
max-parallel: 1
matrix:
package:
- packages/shared
- packages/core
- packages/x402-compliance
- packages/mcp-server
- packages/sdk
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: pnpm
registry-url: "https://registry.npmjs.org"
- run: pnpm install --frozen-lockfile
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: release-build
- name: Set package version
working-directory: ${{ matrix.package }}
run: npm version ${{ needs.build.outputs.version || github.ref_name }} --no-git-tag-version --allow-same-version 2>/dev/null || true
- name: Publish
working-directory: ${{ matrix.package }}
run: pnpm publish --access public --no-git-checks
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
docker:
name: Build & Push Docker Image
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,value=latest
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
target: production
platforms: linux/amd64,linux/arm64
github-release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: [publish-npm, docker]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate changelog
id: changelog
run: |
PREV_TAG=$(git tag --sort=-v:refname | head -2 | tail -1)
if [ -z "$PREV_TAG" ]; then
CHANGELOG=$(git log --pretty=format:"- %s (%h)" HEAD)
else
CHANGELOG=$(git log --pretty=format:"- %s (%h)" "${PREV_TAG}..HEAD")
fi
echo "changelog<<EOF" >> "$GITHUB_OUTPUT"
echo "$CHANGELOG" >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
- name: Create release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
body: |
## What's Changed
${{ steps.changelog.outputs.changelog }}
## Packages Published
| Package | Version |
|---------|---------|
| `@prooflink/shared` | ${{ github.ref_name }} |
| `@prooflink/core` | ${{ github.ref_name }} |
| `@prooflink/x402-compliance` | ${{ github.ref_name }} |
| `@prooflink/mcp-server` | ${{ github.ref_name }} |
| `@prooflink/sdk` | ${{ github.ref_name }} |
## Docker Image
```
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}
```
prerelease: ${{ contains(github.ref_name, '-') }}