-
Notifications
You must be signed in to change notification settings - Fork 217
106 lines (100 loc) · 3.45 KB
/
ai-service-release-stable-image.yaml
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
name: AI Service Release stable image
on:
workflow_dispatch:
inputs:
version:
description: Give a version for this release
type: string
required: true
defaults:
run:
working-directory: wren-ai-service
jobs:
upgrade-ai-service-version:
runs-on: ubuntu-latest
steps:
- name: Generate a token
id: generate-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ vars.CI_APP_ID }}
private-key: ${{ secrets.CI_APP_PRIVATE_KEY }}
- uses: actions/checkout@v4
with:
token: ${{ steps.generate-token.outputs.token }}
fetch-depth: 0
- name: Set up Git
run: |
git config --global user.name "wren-ai[bot]"
git config --global user.email "dev@cannerdata.com"
- name: Set up Python 3.12.0
uses: actions/setup-python@v4
with:
python-version: 3.12.0
- name: Install Poetry
uses: abatilo/actions-poetry@v2
with:
poetry-version: 1.8.3
- name: Generate and Save Change Log
id: changelog
run: |
echo "Generating change log..."
PREVIOUS_VERSION=release/ai-service/$(poetry version -s)
echo "Previous version: $PREVIOUS_VERSION"
CHANGE_LOG=$(git log --pretty=format:"%s" $PREVIOUS_VERSION..HEAD | grep wren-ai-service)
# Separate the change log into categories
FEATURES=$(echo "$CHANGE_LOG" | grep "^feat" | sed 's/^/- /')
FIXES_AND_CHORES=$(echo "$CHANGE_LOG" | grep -E "^(fix|chore)" | sed 's/^/- /')
# Create the full change log
FULL_CHANGE_LOG="\nChangelog for the version\n"
if [ -n "$FEATURES" ]; then
FULL_CHANGE_LOG+="\nFeature and Enhancement\n$FEATURES"
fi
if [ -n "$FIXES_AND_CHORES" ]; then
FULL_CHANGE_LOG+="\n\nFixes and Chores\n$FIXES_AND_CHORES"
fi
{
echo "CHANGE_LOG<<EOF"
echo -e "$FULL_CHANGE_LOG"
echo EOF
} >> $GITHUB_ENV
- name: Upgrade AI Service version
run: |
version=${{ github.event.inputs.version }}
poetry version --next-phase $version
git add pyproject.toml
git commit -m "Upgrade AI Service version to $version"
git push
git tag -a "release/ai-service/$version" -m "${{ env.CHANGE_LOG }}"
git push origin "release/ai-service/$version"
build-image:
needs: upgrade-ai-service-version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/canner/wren-ai-service
tags: |
type=raw,${{ github.event.inputs.version }}
type=raw,latest
- name: Build and push
uses: docker/build-push-action@v6
with:
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
context: ./wren-ai-service
file: ./wren-ai-service/docker/Dockerfile