1+ name : Build and Release
2+
3+ on :
4+ push :
5+ branches : [main]
6+ paths :
7+ - ' apps/chat/**'
8+ - ' .github/workflows/release.yaml'
9+
10+ jobs :
11+ build-and-release :
12+ runs-on : ubuntu-latest
13+ permissions :
14+ contents : write
15+ packages : write
16+ steps :
17+ - uses : actions/checkout@v4
18+ with :
19+ fetch-depth : 0
20+
21+ # 1. Semantic Release (создает версию)
22+ - name : Semantic Release
23+ id : semantic
24+ uses : cycjimmy/semantic-release-action@v4
25+ with :
26+ semantic_version : 21
27+ env :
28+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
29+
30+ # 1.5. Обновить Chart.yaml и упаковать Helm
31+ - name : Install Helm
32+ if : steps.semantic.outputs.new_release_published == 'true'
33+ uses : azure/setup-helm@v3
34+
35+ - name : Update Chart Version
36+ if : steps.semantic.outputs.new_release_published == 'true'
37+ run : |
38+ VERSION=${{ steps.semantic.outputs.new_release_version }}
39+ sed -i "s/^version:.*/version: $VERSION/" charts/chat/Chart.yaml
40+ sed -i "s/^appVersion:.*/appVersion: \"$VERSION\"/" charts/chat/Chart.yaml
41+
42+ - name : Package Helm Chart
43+ if : steps.semantic.outputs.new_release_published == 'true'
44+ run : helm package charts/chat --destination ./
45+
46+ # 2. Docker build с версией
47+ - name : Log in to GitHub Container Registry
48+ uses : docker/login-action@v2
49+ with :
50+ registry : ghcr.io
51+ username : ${{ github.actor }}
52+ password : ${{ secrets.GITHUB_TOKEN }}
53+
54+ - name : Build and push Docker image
55+ uses : docker/build-push-action@v5
56+ with :
57+ context : ./apps/chat
58+ push : true
59+ tags : |
60+ ghcr.io/justgithubaccount/chat-api:latest
61+ ghcr.io/justgithubaccount/chat-api:${{ github.sha }}
62+ ${{ steps.semantic.outputs.new_release_version && format('ghcr.io/justgithubaccount/chat-api:{0}', steps.semantic.outputs.new_release_version) || '' }}
0 commit comments