-
Notifications
You must be signed in to change notification settings - Fork 4
215 lines (192 loc) · 6.54 KB
/
release.yml
File metadata and controls
215 lines (192 loc) · 6.54 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
207
208
209
210
211
212
213
214
215
name: Release
on:
push:
branches: [main]
paths: [VERSION]
workflow_dispatch:
permissions:
contents: write
packages: write
jobs:
preflight:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Read version
id: version
run: echo "version=$(cat VERSION | tr -d '[:space:]')" >> "$GITHUB_OUTPUT"
- name: Check tag does not exist
run: |
if git rev-parse "v${{ steps.version.outputs.version }}" >/dev/null 2>&1; then
echo "::error::Tag v${{ steps.version.outputs.version }} already exists"
exit 1
fi
build:
needs: preflight
strategy:
matrix:
include:
- arch: amd64
runner: ubuntu-latest
- arch: arm64
runner: ubuntu-24.04-arm
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push frontend image
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/${{ matrix.arch }}
push: true
provenance: false
build-args: |
VITE_API_URL=
tags: |
ghcr.io/${{ github.repository }}:${{ needs.preflight.outputs.version }}-${{ matrix.arch }}
labels: |
org.opencontainers.image.source=https://github.com/${{ github.repository }}
cache-from: type=gha,scope=${{ matrix.arch }}
cache-to: type=gha,mode=max,scope=${{ matrix.arch }}
manifest:
needs: [build, preflight]
runs-on: ubuntu-latest
steps:
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create multi-arch manifest
run: |
docker buildx imagetools create \
-t ghcr.io/${{ github.repository }}:${{ needs.preflight.outputs.version }} \
-t ghcr.io/${{ github.repository }}:latest \
ghcr.io/${{ github.repository }}:${{ needs.preflight.outputs.version }}-amd64 \
ghcr.io/${{ github.repository }}:${{ needs.preflight.outputs.version }}-arm64
release:
needs: [manifest, preflight]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate release notes
id: notes
run: |
VERSION="v${{ needs.preflight.outputs.version }}"
PREV_TAG=$(git tag --sort=-v:refname | head -1)
if [ -z "$PREV_TAG" ]; then
COMMITS=$(git log --oneline --no-merges)
else
COMMITS=$(git log --oneline --no-merges ${PREV_TAG}..HEAD)
fi
# Categorize commits
FEATURES=$(echo "$COMMITS" | grep -iE '^[a-f0-9]+ feat' | sed 's/^[a-f0-9]* /- /' || true)
FIXES=$(echo "$COMMITS" | grep -iE '^[a-f0-9]+ fix' | sed 's/^[a-f0-9]* /- /' || true)
OTHER=$(echo "$COMMITS" | grep -ivE '^[a-f0-9]+ (feat|fix|release|Revert)' | sed 's/^[a-f0-9]* /- /' || true)
REVERTS=$(echo "$COMMITS" | grep -iE '^[a-f0-9]+ Revert' | sed 's/^[a-f0-9]* /- /' || true)
{
echo "body<<RELEASE_EOF"
echo "## What's Changed"
echo ""
if [ -n "$FEATURES" ]; then
echo "### Features"
echo "$FEATURES"
echo ""
fi
if [ -n "$FIXES" ]; then
echo "### Bug Fixes"
echo "$FIXES"
echo ""
fi
if [ -n "$REVERTS" ]; then
echo "### Reverted"
echo "$REVERTS"
echo ""
fi
if [ -n "$OTHER" ]; then
echo "### Other"
echo "$OTHER"
echo ""
fi
echo "### Docker Images"
echo "\`\`\`"
echo "ghcr.io/helmcode/agent_crew:${VERSION#v}"
echo "\`\`\`"
echo "RELEASE_EOF"
} >> "$GITHUB_OUTPUT"
- name: Create git tag
run: |
git tag "v${{ needs.preflight.outputs.version }}"
git push origin "v${{ needs.preflight.outputs.version }}"
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ needs.preflight.outputs.version }}
name: v${{ needs.preflight.outputs.version }}
body: ${{ steps.notes.outputs.body }}
- name: Notify Slack
if: success()
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_RELEASE_WEBHOOK_URL }}
run: |
VERSION="v${{ needs.preflight.outputs.version }}"
PREV_TAG=$(git tag --sort=-v:refname | grep -v "$VERSION" | head -1)
if [ -z "$PREV_TAG" ]; then
CHANGES=$(git log --oneline --no-merges | head -15)
else
CHANGES=$(git log --oneline --no-merges ${PREV_TAG}..HEAD~1)
fi
# Format changes as bullet list for Slack
BULLET_LIST=$(echo "$CHANGES" | grep -ivE '^[a-f0-9]+ release' | sed 's/^[a-f0-9]* /• /')
RELEASE_URL="https://github.com/${{ github.repository }}/releases/tag/${VERSION}"
# Build Slack payload
PAYLOAD=$(cat <<SLACK_EOF
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":rocket: AgentCrew Frontend ${VERSION} Released"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Changes:*\n${BULLET_LIST}"
}
},
{
"type": "actions",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"text": ":github: View Release"
},
"url": "${RELEASE_URL}"
}
]
}
]
}
SLACK_EOF
)
curl -s -X POST "$SLACK_WEBHOOK_URL" \
-H 'Content-Type: application/json' \
-d "$PAYLOAD"