Repository navigation
137 lines (112 loc) · 4.44 KB
/
Copy pathrelease.yml
File metadata and controls
137 lines (112 loc) · 4.44 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
name: Release
on:
push:
tags:
- "v*"
env:
DOCKER_REPO: redislabs
DOCKER_IMAGE: client-resp-proxy
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Run linter
run: bun run lint
- name: Run tests
run: bun test
- name: Extract version from tag
id: version
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- 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
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build and push base Docker image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ env.DOCKER_REPO }}/${{ env.DOCKER_IMAGE }}:latest
${{ env.DOCKER_REPO }}/${{ env.DOCKER_IMAGE }}:${{ steps.version.outputs.VERSION }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build and push standalone Docker image
uses: docker/build-push-action@v6
with:
context: .
file: ./standalone.Dockerfile
platforms: linux/amd64,linux/arm64
push: true
build-args: |
BASE_IMAGE=${{ env.DOCKER_REPO }}/${{ env.DOCKER_IMAGE }}:${{ steps.version.outputs.VERSION }}
tags: |
${{ env.DOCKER_REPO }}/${{ env.DOCKER_IMAGE }}:standalone
${{ env.DOCKER_REPO }}/${{ env.DOCKER_IMAGE }}:standalone-${{ steps.version.outputs.VERSION }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Try to generate notes using GitHub's API first
GENERATED_NOTES=$(gh api repos/$GITHUB_REPOSITORY/releases/generate-notes -f tag_name=v${{ steps.version.outputs.VERSION }} --jq .body 2>/dev/null || echo "")
# If GitHub's generation worked and has content beyond just "Full Changelog"
if [[ "$GENERATED_NOTES" != *"**Full Changelog**"* ]] && [[ -n "$GENERATED_NOTES" ]]; then
RELEASE_BODY="## Docker Images
**Base Image (Proxy only):**
\`\`\`bash
docker pull ${{ env.DOCKER_REPO }}/${{ env.DOCKER_IMAGE }}:${{ steps.version.outputs.VERSION }}
\`\`\`
**Standalone Image (Proxy + Embedded Redis):**
\`\`\`bash
docker pull ${{ env.DOCKER_REPO }}/${{ env.DOCKER_IMAGE }}:standalone-${{ steps.version.outputs.VERSION }}
\`\`\`
$GENERATED_NOTES"
else
# Fallback to commit-based notes
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
if [[ -n "$PREV_TAG" ]]; then
COMMIT_NOTES=$(git log ${PREV_TAG}..HEAD --pretty=format:"* %s (%h)" | head -20)
CHANGELOG_LINK="**Full Changelog**: https://github.com/$GITHUB_REPOSITORY/compare/${PREV_TAG}...v${{ steps.version.outputs.VERSION }}"
else
COMMIT_NOTES=$(git log --pretty=format:"* %s (%h)" | head -20)
CHANGELOG_LINK=""
fi
RELEASE_BODY="## Docker Images
**Base Image (Proxy only):**
\`\`\`bash
docker pull ${{ env.DOCKER_REPO }}/${{ env.DOCKER_IMAGE }}:${{ steps.version.outputs.VERSION }}
\`\`\`
**Standalone Image (Proxy + Embedded Redis):**
\`\`\`bash
docker pull ${{ env.DOCKER_REPO }}/${{ env.DOCKER_IMAGE }}:standalone-${{ steps.version.outputs.VERSION }}
\`\`\`
## What's Changed
$COMMIT_NOTES
$CHANGELOG_LINK"
fi
gh release create "v${{ steps.version.outputs.VERSION }}" \
--repo="$GITHUB_REPOSITORY" \
--title="Release ${{ steps.version.outputs.VERSION }}" \
--notes "$RELEASE_BODY" \
--draft