mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-09-28 05:46:36 +08:00
[新增] 添加预览预发布标签清理工作流
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
name: Preview prerelease tag cleanup
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
cleanup:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Resolve version metadata
|
||||
id: version
|
||||
run: |
|
||||
SHOULD_RUN=true
|
||||
VERSION="all-prerelease-tags"
|
||||
|
||||
echo "should_run=$SHOULD_RUN" >> "$GITHUB_OUTPUT"
|
||||
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
||||
if [[ "$VERSION" =~ ^v[0-9]+(\.[0-9]+)*$ ]]; then
|
||||
echo "is_prerelease=false" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "is_prerelease=true" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
- name: Preview prerelease releases and tags
|
||||
if: steps.version.outputs.should_run == 'true'
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
mapfile -t TAGS < <(git tag --list 'v*' | sort -V)
|
||||
MATCHED=0
|
||||
|
||||
for TAG in "${TAGS[@]}"; do
|
||||
if [[ "$TAG" =~ ^v[0-9]+(\.[0-9]+)*$ ]]; then
|
||||
echo "Keep formal release tag: $TAG"
|
||||
continue
|
||||
fi
|
||||
|
||||
if gh release view "$TAG" >/dev/null 2>&1; then
|
||||
echo "Would delete prerelease tag and release: $TAG"
|
||||
else
|
||||
echo "Would delete prerelease tag only: $TAG (no GitHub Release found)"
|
||||
fi
|
||||
|
||||
MATCHED=$((MATCHED + 1))
|
||||
done
|
||||
|
||||
echo "Found $MATCHED prerelease tag(s) that would be deleted."
|
||||
Reference in New Issue
Block a user