mirror of
https://github.com/octopusYan/alist-gui.git
synced 2024-09-19 23:46:18 +08:00
80 lines
2.4 KiB
YAML
80 lines
2.4 KiB
YAML
name: Auto Alpha Tag
|
||
|
||
on:
|
||
push:
|
||
branches:
|
||
- "dev"
|
||
paths:
|
||
- ".github/workflows/*.yml"
|
||
- "src/**"
|
||
- "pom.xml"
|
||
- "!**/*.md"
|
||
pull_request:
|
||
branches:
|
||
- "dev"
|
||
types:
|
||
- closed
|
||
|
||
jobs:
|
||
auto-tag:
|
||
runs-on: windows-latest
|
||
permissions:
|
||
contents: write
|
||
actions: write
|
||
strategy:
|
||
matrix:
|
||
include:
|
||
- msbuild_target: x64
|
||
lowercase_target: x64
|
||
fail-fast: false
|
||
outputs:
|
||
tag: ${{ steps.set_tag.outputs.tag }}
|
||
pre_version: ${{ steps.set_tag.outputs.pre_version }}
|
||
main_tag_name: ${{ steps.push_main_tag.outputs.main_tag_name }}
|
||
steps:
|
||
- uses: actions/checkout@v4
|
||
with:
|
||
submodules: recursive
|
||
fetch-depth: 0
|
||
token: ${{ secrets.GITHUB_TOKEN }}
|
||
|
||
- name: Install semver
|
||
run: |
|
||
npm install --global --progress semver
|
||
|
||
- name: Set tag
|
||
id: set_tag
|
||
run: |
|
||
# pre_version是上一个公版,这里需要拉上一个tag,避免堆积过多commit
|
||
$latest_tag=$(git describe --tags --abbrev=0)
|
||
echo "latest_tag=$latest_tag" >> $env:GITHUB_OUTPUT
|
||
$described = $(git describe --tags --long --match 'v*')
|
||
$ids = $($described -split "-")
|
||
if ($ids.length -eq 3) {
|
||
$ver = "v$(semver --increment $ids[0].Substring(1))"
|
||
$pre_version = "$($ids[0])"
|
||
$dist = `printf "%03d"` $ids[1]
|
||
echo "tag=$ver-alpha.1.d$($dist).$($ids[2])" >> $env:GITHUB_OUTPUT
|
||
echo "pre_version=$pre_version" >> $env:GITHUB_OUTPUT
|
||
exit 0
|
||
}
|
||
if ($ids.length -eq 4) {
|
||
$dist = `printf "%03d"` $ids[2]
|
||
$pre_version = "$($ids[0])-$($ids[1])"
|
||
echo "pre_version=$pre_version" >> $env:GITHUB_OUTPUT
|
||
echo "tag=$pre_version.d$($dist).$($ids[3])" >> $env:GITHUB_OUTPUT
|
||
exit 0
|
||
}
|
||
exit 1
|
||
|
||
- name: Push tag to main repo
|
||
id: push_main_tag
|
||
run: |
|
||
git config user.name 'github-actions[bot]'
|
||
git config user.email 'github-actions[bot]@users.noreply.github.com'
|
||
|
||
$main_tag_name=$(echo "alpha/${{ steps.set_tag.outputs.tag }}")
|
||
git tag $main_tag_name -f
|
||
git push --tags origin HEAD:refs/tags/$main_tag_name -f
|
||
echo "main_tag_name=$main_tag_name" >> $env:GITHUB_OUTPUT
|