mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-04 04:26:38 +08:00
Add release package publishing workflow
This commit is contained in:
@@ -0,0 +1,47 @@
|
|||||||
|
name: Publish release packages
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags: ['v*']
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: '1.25'
|
||||||
|
cache: true
|
||||||
|
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '20'
|
||||||
|
cache: npm
|
||||||
|
cache-dependency-path: web/package-lock.json
|
||||||
|
|
||||||
|
- name: Build release packages
|
||||||
|
run: ./scripts/package-release.sh
|
||||||
|
env:
|
||||||
|
VERSION: ${{ github.ref_name }}
|
||||||
|
|
||||||
|
- name: Generate checksums
|
||||||
|
run: |
|
||||||
|
cd dist-release
|
||||||
|
sha256sum * > SHA256SUMS.txt
|
||||||
|
|
||||||
|
- name: Publish GitHub Release
|
||||||
|
uses: softprops/action-gh-release@v2
|
||||||
|
with:
|
||||||
|
files: |
|
||||||
|
dist-release/*.tar.gz
|
||||||
|
dist-release/*.zip
|
||||||
|
dist-release/SHA256SUMS.txt
|
||||||
|
generate_release_notes: true
|
||||||
Executable
+62
@@ -0,0 +1,62 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
VERSION="${VERSION:-$(git describe --tags --always --dirty 2>/dev/null || echo dev)}"
|
||||||
|
OUT_DIR="${OUT_DIR:-dist-release}"
|
||||||
|
PLATFORMS="${PLATFORMS:-linux/amd64 linux/arm64 windows/amd64 darwin/amd64 darwin/arm64}"
|
||||||
|
|
||||||
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||||
|
cd "$ROOT_DIR"
|
||||||
|
|
||||||
|
if [[ "$VERSION" == *dirty* ]]; then
|
||||||
|
echo "Refusing to package a dirty working tree version: $VERSION" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -rf "$OUT_DIR"
|
||||||
|
mkdir -p "$OUT_DIR"
|
||||||
|
|
||||||
|
echo "Building frontend bundle"
|
||||||
|
(cd web && npm ci && npm run build)
|
||||||
|
|
||||||
|
for target in $PLATFORMS; do
|
||||||
|
os="${target%/*}"
|
||||||
|
arch="${target#*/}"
|
||||||
|
name="MediaStationGo_${VERSION}_${os}_${arch}"
|
||||||
|
work="$OUT_DIR/$name"
|
||||||
|
mkdir -p "$work/web"
|
||||||
|
|
||||||
|
ext=""
|
||||||
|
if [[ "$os" == "windows" ]]; then
|
||||||
|
ext=".exe"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Building $target"
|
||||||
|
CGO_ENABLED=0 GOOS="$os" GOARCH="$arch" go build \
|
||||||
|
-trimpath -ldflags="-s -w" \
|
||||||
|
-o "$work/mediastation-go$ext" ./cmd/server
|
||||||
|
|
||||||
|
cp -R web/dist "$work/web/dist"
|
||||||
|
cp docker-compose.yml config.example.yaml README.md README_EN.md LICENSE "$work/"
|
||||||
|
|
||||||
|
if [[ "$os" == "windows" ]]; then
|
||||||
|
(cd "$OUT_DIR" && python3 - "$name" "$name.zip" <<'PY'
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import zipfile
|
||||||
|
|
||||||
|
root, archive = sys.argv[1], sys.argv[2]
|
||||||
|
with zipfile.ZipFile(archive, "w", zipfile.ZIP_DEFLATED) as zf:
|
||||||
|
for base, _, files in os.walk(root):
|
||||||
|
for filename in files:
|
||||||
|
path = os.path.join(base, filename)
|
||||||
|
zf.write(path, path)
|
||||||
|
PY
|
||||||
|
)
|
||||||
|
else
|
||||||
|
tar -C "$OUT_DIR" -czf "$OUT_DIR/$name.tar.gz" "$name"
|
||||||
|
fi
|
||||||
|
rm -rf "$work"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Release packages written to $OUT_DIR"
|
||||||
Reference in New Issue
Block a user