85 lines
2.7 KiB
YAML
85 lines
2.7 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
tags: ["v*"]
|
|
|
|
permissions:
|
|
contents: write
|
|
packages: write
|
|
|
|
env:
|
|
BUILDX_NO_DEFAULT_ATTESTATIONS: "1"
|
|
DASH_REPO: wangdefaa/oci-portal-dash
|
|
IMAGE: ghcr.io/wangdefaa/oci-portal
|
|
|
|
jobs:
|
|
release:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: docker/setup-buildx-action@v3
|
|
|
|
- name: 下载前端 dist.zip
|
|
run: |
|
|
DASH_TAG=$(head -1 DASH_VERSION)
|
|
BASE="https://github.com/${DASH_REPO}/releases/download/${DASH_TAG}"
|
|
curl -fsSL -o dist.zip "${BASE}/dist.zip"
|
|
curl -fsSL -o dist.zip.sha256 "${BASE}/dist.zip.sha256"
|
|
sha256sum -c dist.zip.sha256
|
|
rm -rf internal/webui/dist && mkdir -p internal/webui/dist
|
|
unzip -q dist.zip -d internal/webui/dist
|
|
test -f internal/webui/dist/index.html
|
|
|
|
- name: 构建双架构二进制
|
|
run: |
|
|
BUILD_TIME=$(date -u +%Y-%m-%dT%H:%M:%SZ)
|
|
echo "BUILD_TIME=${BUILD_TIME}" >> "$GITHUB_ENV"
|
|
docker buildx build --pull \
|
|
--platform linux/amd64,linux/arm64 \
|
|
--build-arg VERSION=${{ github.ref_name }} \
|
|
--build-arg BUILD_TIME=${BUILD_TIME} \
|
|
--target artifact \
|
|
--output type=local,dest=./output .
|
|
mkdir -p assets
|
|
mv output/linux_amd64/oci-portal-server assets/oci-portal-server-linux-amd64
|
|
mv output/linux_arm64/oci-portal-server assets/oci-portal-server-linux-arm64
|
|
(cd assets && sha256sum * > SHA256SUMS)
|
|
ls -lh assets/
|
|
|
|
- name: 提取 CHANGELOG 版本段作为 Release 描述
|
|
env:
|
|
TAG: ${{ github.ref_name }}
|
|
run: |
|
|
VERSION="${TAG#v}"
|
|
awk -v ver="$VERSION" '$0 ~ "^## \\[" ver "\\]" {flag=1; next} /^## \[/ && flag {exit} flag {print}' CHANGELOG.md > release-notes.md
|
|
[ -s release-notes.md ] || echo "Release ${TAG}" > release-notes.md
|
|
|
|
- name: 创建 Release 并上传二进制附件
|
|
uses: softprops/action-gh-release@v3
|
|
with:
|
|
token: ${{ github.token }}
|
|
body_path: release-notes.md
|
|
files: assets/*
|
|
|
|
- uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.repository_owner }}
|
|
password: ${{ github.token }}
|
|
|
|
- name: 构建并推送多平台镜像
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
platforms: linux/amd64,linux/arm64
|
|
push: true
|
|
provenance: false
|
|
build-args: |
|
|
VERSION=${{ github.ref_name }}
|
|
BUILD_TIME=${{ env.BUILD_TIME }}
|
|
tags: |
|
|
${{ env.IMAGE }}:${{ github.ref_name }}
|
|
${{ env.IMAGE }}:latest
|