alist-gui/.github/workflows/auto-alpha-tag.yml
octopus_yan 329c484f4c
Some checks are pending
Auto Alpha Tag / auto-tag (x64, x64) (push) Waiting to run
Release / meta (push) Waiting to run
Release / windows (x64, x64) (push) Blocked by required conditions
Release / release (push) Blocked by required conditions
ci: fix Auto Alpha Tag
2024-09-19 01:13:45 +08:00

80 lines
2.4 KiB
YAML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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