73 lines
2.2 KiB
YAML
73 lines
2.2 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
tags: ["v*"]
|
|
|
|
permissions:
|
|
contents: write
|
|
packages: write
|
|
|
|
env:
|
|
BUILDX_NO_DEFAULT_ATTESTATIONS: "1"
|
|
DASH_DOWNLOAD: https://github.com/wangdefaa/oci-portal-dash/releases/latest/download/dist.zip
|
|
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: |
|
|
curl -fsSL -o dist.zip "$DASH_DOWNLOAD"
|
|
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: 构建双架构二进制(artifact stage 导出)
|
|
run: |
|
|
docker buildx build --pull \
|
|
--platform linux/amd64,linux/arm64 \
|
|
--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
|
|
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
|
|
tags: |
|
|
${{ env.IMAGE }}:${{ github.ref_name }}
|
|
${{ env.IMAGE }}:latest
|