forked from dwgx/WindsurfAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
110 lines (97 loc) · 4.1 KB
/
Copy pathrelease.yml
File metadata and controls
110 lines (97 loc) · 4.1 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
name: Release
on:
push:
tags: ['v*']
jobs:
# ──────────────────────────────────────────────
# Job 1: Build & Push Docker Image (GHCR)
# ──────────────────────────────────────────────
docker:
name: Docker Build & Push
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
# github.repository (= dwgx/WindsurfAPI) lowercases to "windsurfapi"
# without the hyphen the package.json npm name uses. Hardcode the
# kebab form so the image name stays "windsurf-api".
images: ghcr.io/${{ github.repository_owner }}/windsurf-api
tags: |
# Only tag as latest for stable releases (no pre-release suffix like -rc, -alpha, -beta)
type=raw,value=latest,enable=${{ !contains(github.ref_name, '-') }}
# v2.0.6 -> 2.0.6
type=semver,pattern={{version}}
# v2.0.6 -> 2.0
type=semver,pattern={{major}}.{{minor}}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Summary
run: |
echo "## 🐳 Docker Image Published" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
echo "**Tags:**" >> "$GITHUB_STEP_SUMMARY"
echo '${{ steps.meta.outputs.tags }}' | tr ',' '\n' | sed 's/^/- `/' | sed 's/$/`/' >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
echo "**Platform:** \`linux/amd64\`" >> "$GITHUB_STEP_SUMMARY"
# ──────────────────────────────────────────────
# Job 2: Create GitHub Release with source code
# ──────────────────────────────────────────────
release:
name: GitHub Release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get version from tag
id: version
run: echo "VERSION=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
- name: Check for release notes
id: notes
run: |
# New layout (docs/releases/) preferred; fall back to repo root
# so historical tags still find their notes if anyone re-cuts an
# old release.
NEW_PATH="docs/releases/RELEASE_NOTES_${{ steps.version.outputs.VERSION }}.md"
OLD_PATH="RELEASE_NOTES_${{ steps.version.outputs.VERSION }}.md"
if [[ -f "$NEW_PATH" ]]; then
echo "file=$NEW_PATH" >> "$GITHUB_OUTPUT"
echo "found=true" >> "$GITHUB_OUTPUT"
elif [[ -f "$OLD_PATH" ]]; then
echo "file=$OLD_PATH" >> "$GITHUB_OUTPUT"
echo "found=true" >> "$GITHUB_OUTPUT"
else
echo "found=false" >> "$GITHUB_OUTPUT"
fi
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
name: v${{ steps.version.outputs.VERSION }}
body_path: ${{ steps.notes.outputs.found == 'true' && steps.notes.outputs.file || '' }}
generate_release_notes: ${{ steps.notes.outputs.found != 'true' }}
draft: false
prerelease: ${{ contains(github.ref_name, '-') }}