-
-
Notifications
You must be signed in to change notification settings - Fork 11
225 lines (196 loc) · 6.72 KB
/
Copy pathrelease.yml
File metadata and controls
225 lines (196 loc) · 6.72 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
name: Release
on:
# workflow_dispatch:
push:
tags:
- "v*"
jobs:
build:
strategy:
fail-fast: true
matrix:
goos: [linux, windows]
goarch: [amd64]
include:
- goos: linux
goarch: s390x
- goos: linux
goarch: arm64
name: Build artifacts
runs-on: ubuntu-latest
container:
image: goreleaser/goreleaser-cross:v1.25
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
GOARM: ${{ matrix.goarm }}
outputs:
tag_name: ${{ steps.extract_branch.outputs.tag }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Ensure full repository is checked out
- run: git config --global --add safe.directory /__w/ServerStatus/ServerStatus
- name: Set working directory
run: cd /__w/ServerStatus/ServerStatus
- name: Fetch IPInfo GeoIP Database
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
env:
IPINFO_TOKEN: ${{ secrets.IPINFO_TOKEN }}
run: |
if [ -z "$IPINFO_TOKEN" ]; then
echo "IPINFO_TOKEN is not set. Please add it to your repository secrets."
exit 1
fi
rm -f pkg/geoip/geoip.db
wget --no-check-certificate -qO pkg/geoip/geoip.db "https://ipinfo.io/data/free/country.mmdb?token=${IPINFO_TOKEN}"
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.25.x"
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: "24"
cache: npm
cache-dependency-path: frontend/package-lock.json
- name: Build frontend
run: |
cd frontend
npm ci
npm run build
- name: Build
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: "~> v2"
args: build --single-target --clean --skip=validate
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: server-dash-${{ env.GOOS }}-${{ env.GOARCH }}
path: |
./dist/*/*
- name: Upload frontend artifact
if: matrix.goos == 'linux' && matrix.goarch == 'amd64'
uses: actions/upload-artifact@v4
with:
name: frontend-dist
path: frontend/dist
release:
runs-on: ubuntu-latest
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
needs: build
name: Release
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: ./assets
- name: Archive and compress binaries
run: |
find assets/*/*/* -type f | while read -r file; do
chmod +x $file
dir=$(dirname "$file")
filename=$(basename "$file")
fileWithoutExt="${filename%.*}"
zip -jr "$dir/$fileWithoutExt.zip" "$file"
done
- name: Release
uses: ncipollo/release-action@v1
with:
artifacts: "assets/*/*/*.zip"
generateReleaseNotes: true
release-docker:
runs-on: ubuntu-latest
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
needs: build
name: Release Docker images
steps:
- uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: ./assets
- name: Restore frontend dist
run: |
rm -rf frontend/dist
mkdir -p frontend
if [ -f ./assets/frontend-dist/index.html ]; then
cp -a ./assets/frontend-dist ./frontend/dist
elif [ -d ./assets/frontend-dist/dist ]; then
cp -a ./assets/frontend-dist/dist ./frontend/dist
else
echo "frontend-dist artifact is missing index.html"
find ./assets/frontend-dist -maxdepth 3 -type f -print || true
exit 1
fi
rm -rf ./assets/frontend-dist
- name: Fix permissions
run: |
chmod -R +x ./assets/*
mkdir dist
mv ./assets/*/*/* ./dist
- name: Verify build context
run: |
echo "=== Build context verification ==="
echo "Current directory contents:"
ls -la
echo "Script directory contents:"
ls -la script/
echo "Dist directory contents:"
ls -la dist/
echo "Entrypoint script:"
ls -la script/entrypoint.sh
echo "Dockerfile:"
head -20 Dockerfile
- name: Extract branch name
run: |
export TAG_NAME=$(echo ${GITHUB_REF#refs/tags/})
echo "tag=$TAG_NAME" >> $GITHUB_OUTPUT
id: extract_branch
- name: Log into GHCR
uses: docker/login-action@master
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ github.token }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set up image name
run: |
GHCR_IMAGE_NAME=$(echo "ghcr.io/${{ github.repository_owner }}/server-dash" | tr '[:upper:]' '[:lower:]')
echo "GHCR_IMAGE_NAME=$GHCR_IMAGE_NAME" >> $GITHUB_OUTPUT
id: image-name
- name: Build dashboard image And Push
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64,linux/s390x
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
TZ=Asia/Shanghai
tags: |
${{ steps.image-name.outputs.GHCR_IMAGE_NAME }}:latest
${{ steps.image-name.outputs.GHCR_IMAGE_NAME }}:${{ steps.extract_branch.outputs.tag }}
labels: |
org.opencontainers.image.title=ServerStatus Dashboard
org.opencontainers.image.description=A lightweight server monitoring dashboard
org.opencontainers.image.url=https://github.com/${{ github.repository }}
org.opencontainers.image.source=https://github.com/${{ github.repository }}
org.opencontainers.image.version=${{ steps.extract_branch.outputs.tag }}
org.opencontainers.image.created=${{ steps.date.outputs.date }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.licenses=MIT
- name: Trigger sync
env:
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ github.token }}
GH_DEBUG: api
run: |
gh workflow run sync-release.yml