-
Notifications
You must be signed in to change notification settings - Fork 53
140 lines (124 loc) · 4.57 KB
/
release.yml
File metadata and controls
140 lines (124 loc) · 4.57 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
name: Release
on:
push:
tags:
- 'v*.*.*'
jobs:
create-release:
name: Create GitHub Release
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.version.outputs.TAG }}
version: ${{ steps.version.outputs.VERSION }}
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract version from tag
id: version
run: |
TAG="${GITHUB_REF#refs/tags/}"
echo "TAG=${TAG}" >> $GITHUB_OUTPUT
echo "VERSION=${TAG#v}" >> $GITHUB_OUTPUT
- name: Extract changelog section
id: changelog
run: |
TAG="${GITHUB_REF#refs/tags/}"
# Extract the section for this version from CHANGELOG.md
BODY=$(awk -v tag="## ${TAG}" '
$0 ~ tag { found=1; next }
found && /^## / { exit }
found && /^---$/ { exit }
found { print }
' CHANGELOG.md)
if [ -z "$BODY" ]; then
BODY="See [CHANGELOG.md](CHANGELOG.md) for details."
fi
# Use delimiter to handle multiline output
echo "body<<CHANGELOG_EOF" >> $GITHUB_OUTPUT
echo "$BODY" >> $GITHUB_OUTPUT
echo "CHANGELOG_EOF" >> $GITHUB_OUTPUT
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.TAG }}
name: Release ${{ steps.version.outputs.TAG }}
body: |
## What's Changed
${{ steps.changelog.outputs.body }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-and-push:
name: Build and Push Release Images
needs: create-release
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
image:
- name: joysafeter-backend
context: ./backend
dockerfile: ./deploy/docker/backend.Dockerfile
push_dockerhub: true
- name: joysafeter-frontend
context: ./frontend
dockerfile: ./deploy/docker/frontend.Dockerfile
push_dockerhub: true
- name: joysafeter-openclaw
context: ./deploy/openclaw
dockerfile: ./deploy/openclaw/Dockerfile
push_dockerhub: false
- name: joysafeter-sandbox
context: ./deploy/docker
dockerfile: ./deploy/docker/sandbox.Dockerfile
push_dockerhub: true
steps:
- name: Checkout code
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: Log in to Docker Hub
if: matrix.image.push_dockerhub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Compute image tags
id: tags
run: |
GHCR_TAGS="ghcr.io/jd-opensource/${{ matrix.image.name }}:${{ needs.create-release.outputs.tag }},ghcr.io/jd-opensource/${{ matrix.image.name }}:${{ needs.create-release.outputs.version }},ghcr.io/jd-opensource/${{ matrix.image.name }}:latest"
if [ "${{ matrix.image.push_dockerhub }}" = "true" ]; then
DOCKER_TAGS="docker.io/jdopensource/${{ matrix.image.name }}:${{ needs.create-release.outputs.tag }},docker.io/jdopensource/${{ matrix.image.name }}:${{ needs.create-release.outputs.version }},docker.io/jdopensource/${{ matrix.image.name }}:latest"
echo "tags=${DOCKER_TAGS},${GHCR_TAGS}" >> $GITHUB_OUTPUT
else
echo "tags=${GHCR_TAGS}" >> $GITHUB_OUTPUT
fi
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ${{ matrix.image.context }}
file: ${{ matrix.image.dockerfile }}
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.tags.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
GIT_COMMIT_SHA=${{ github.sha }}
PIP_INDEX_URL=https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
UV_INDEX_URL=https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple