Skip to content

Commit be33456

Browse files
committed
配置 GitHub 自动发布
1 parent 0e3971f commit be33456

2 files changed

Lines changed: 77 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "*"
7+
workflow_dispatch:
8+
inputs:
9+
tag:
10+
description: "Tag to publish, for example 1.0.0"
11+
required: true
12+
type: string
13+
14+
permissions:
15+
contents: write
16+
17+
jobs:
18+
release:
19+
name: GitHub Release
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
27+
- name: Create or update release
28+
env:
29+
GH_TOKEN: ${{ github.token }}
30+
TAG_NAME: ${{ inputs.tag || github.ref_name }}
31+
run: |
32+
set -euo pipefail
33+
34+
tag="${TAG_NAME}"
35+
if [[ ! "${tag}" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
36+
echo "Skip non-semver tag: ${tag}"
37+
exit 0
38+
fi
39+
40+
git fetch --tags --force
41+
if ! git rev-parse -q --verify "refs/tags/${tag}" >/dev/null; then
42+
echo "Tag does not exist: ${tag}" >&2
43+
exit 1
44+
fi
45+
46+
version="${tag#v}"
47+
notes_file="$(mktemp)"
48+
awk -v version="${version}" '
49+
BEGIN { in_section = 0 }
50+
$0 ~ "^##[[:space:]]+" version "([[:space:]]|-|$)" {
51+
in_section = 1
52+
next
53+
}
54+
in_section && /^##[[:space:]]+/ {
55+
exit
56+
}
57+
in_section {
58+
print
59+
}
60+
' CHANGELOG.md > "${notes_file}"
61+
62+
if [[ ! -s "${notes_file}" ]]; then
63+
printf 'Release %s\n' "${tag}" > "${notes_file}"
64+
fi
65+
66+
if gh release view "${tag}" >/dev/null 2>&1; then
67+
gh release edit "${tag}" --title "${tag}" --notes-file "${notes_file}"
68+
else
69+
gh release create "${tag}" --title "${tag}" --notes-file "${notes_file}" --verify-tag
70+
fi

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# HTTPMediaCache
22

3+
[![CI](https://github.com/sunimp/HTTPMediaCache/actions/workflows/ci.yml/badge.svg)](https://github.com/sunimp/HTTPMediaCache/actions/workflows/ci.yml)
4+
[![Release](https://img.shields.io/github/v/release/sunimp/HTTPMediaCache?include_prereleases&sort=semver)](https://github.com/sunimp/HTTPMediaCache/releases)
5+
[![Swift](https://img.shields.io/badge/Swift-5.10+-orange.svg)](https://swift.org)
6+
[![Platforms](https://img.shields.io/badge/platform-iOS%2015%2B%20%7C%20macOS%2012%2B-lightgrey.svg)](Package.swift)
7+
[![SPM](https://img.shields.io/badge/SPM-compatible-brightgreen.svg)](Package.swift)
8+
[![License](https://img.shields.io/github/license/sunimp/HTTPMediaCache)](LICENSE)
9+
310
HTTPMediaCache 是一个 Swift-only 的本地 HTTP 多媒体缓存库。它通过本地代理承接播放器请求,支持普通文件与 HLS 资源的边播边缓存、Range 请求、预加载、HLS 播放列表改写、缓存查询和缓存清理。
411

512
## 特性

0 commit comments

Comments
 (0)