mirror of
https://github.com/octopusYan/alist-gui.git
synced 2024-11-10 06:26:43 +08:00
ci: add action
This commit is contained in:
parent
fb6c854dc0
commit
d4dcbf6e64
74
.github/workflows/auto-alpha-tag.yml
vendored
Normal file
74
.github/workflows/auto-alpha-tag.yml
vendored
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
name: Auto Alpha Tag
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- "dev"
|
||||||
|
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
|
52
.github/workflows/auto-release-tag.yml
vendored
Normal file
52
.github/workflows/auto-release-tag.yml
vendored
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
name: Auto Tag Release PR
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
types:
|
||||||
|
- closed
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
tag:
|
||||||
|
type: string
|
||||||
|
description: Release
|
||||||
|
required: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
auto_tag_release:
|
||||||
|
if: github.event.pull_request.merged == true && (startsWith(github.event.pull_request.title, 'Release v') || startsWith(github.event.pull_request.title, 'release v')) || github.event_name == 'workflow_dispatch'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
token: ${{ secrets.ALISTGUI_RELEASE }}
|
||||||
|
|
||||||
|
- name: Git config
|
||||||
|
run: |
|
||||||
|
git config user.name "$GITHUB_ACTOR"
|
||||||
|
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
|
||||||
|
|
||||||
|
- name: Extract tag name
|
||||||
|
id: extract_tag
|
||||||
|
run: |
|
||||||
|
if ${{ github.event_name != 'workflow_dispatch' }}; then
|
||||||
|
tag_name=$(echo "${{ github.event.pull_request.title }}" | sed -E 's/(Release|release)//' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
|
||||||
|
echo "tag_name=$tag_name" >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
echo "tag_name=${{ inputs.tag }}" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Create release tag and push
|
||||||
|
run: |
|
||||||
|
git tag -a "${{ steps.extract_tag.outputs.tag_name }}" -m "${{ steps.extract_tag.outputs.tag_name }}" -f
|
||||||
|
git push origin "${{ steps.extract_tag.outputs.tag_name }}"
|
||||||
|
|
||||||
|
- name: Merge into dev and push
|
||||||
|
run: |
|
||||||
|
git switch dev
|
||||||
|
git merge "${{ steps.extract_tag.outputs.tag_name }}"
|
||||||
|
git push origin dev
|
154
.github/workflows/release.yml
vendored
Normal file
154
.github/workflows/release.yml
vendored
Normal file
@ -0,0 +1,154 @@
|
|||||||
|
name: Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- "v*"
|
||||||
|
branches-ignore:
|
||||||
|
- "master"
|
||||||
|
paths:
|
||||||
|
- ".github/workflows/*.yml"
|
||||||
|
- "src/**"
|
||||||
|
- "pom.xml"
|
||||||
|
- "!**/*.md"
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- "dev"
|
||||||
|
paths:
|
||||||
|
- ".github/workflows/*.yml"
|
||||||
|
- "src/**"
|
||||||
|
- "pom.xml"
|
||||||
|
- "!**/*.md"
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
meta:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
tag: ${{ steps.set_tag.outputs.tag }}
|
||||||
|
prerelease: ${{ steps.set_pre.outputs.prerelease }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
path: temp
|
||||||
|
show-progress: false
|
||||||
|
|
||||||
|
- name: Fetch history
|
||||||
|
if: ${{ !startsWith(github.ref, 'refs/pull/') }}
|
||||||
|
run: |
|
||||||
|
git init
|
||||||
|
cp $GITHUB_WORKSPACE/temp/.git/config ./.git
|
||||||
|
rm -rf $GITHUB_WORKSPACE/temp
|
||||||
|
# git config remote.origin.fetch '+refs/*:refs/*'
|
||||||
|
git fetch --filter=tree:0 # --update-head-ok
|
||||||
|
git reset --hard origin/$(git branch --show-current) || true
|
||||||
|
git checkout ${{ github.ref_name }}
|
||||||
|
|
||||||
|
- name: Set tag
|
||||||
|
id: set_tag
|
||||||
|
run: |
|
||||||
|
${{ startsWith(github.ref, 'refs/pull/') && 'cd temp' || '' }}
|
||||||
|
echo tag=$(git describe --tags --match "v*" ${{ github.ref }} || git rev-parse --short HEAD) | tee -a $GITHUB_OUTPUT
|
||||||
|
exit ${PIPESTATUS[0]}
|
||||||
|
|
||||||
|
- name: Judge pre-release
|
||||||
|
id: set_pre
|
||||||
|
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
|
||||||
|
run: |
|
||||||
|
if [[ '${{ steps.set_tag.outputs.tag }}' =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||||
|
echo prerelease=false | tee -a $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
echo prerelease=true | tee -a $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
|
||||||
|
# - name: Set up Node.js
|
||||||
|
# uses: actions/setup-node@v4
|
||||||
|
# with:
|
||||||
|
# node-version: 14
|
||||||
|
#
|
||||||
|
# - name: Install dependencies
|
||||||
|
# run: npm install conventional-changelog-cli
|
||||||
|
|
||||||
|
- name: Generate Changelog
|
||||||
|
run: |
|
||||||
|
this_tag=${{ steps.set_tag.outputs.tag }}
|
||||||
|
if [[ '${{ steps.set_pre.outputs.prerelease }}' != 'false' ]]; then
|
||||||
|
last_tag=$(git describe --tags --match "v*" --abbrev=0 --exclude='${{ steps.set_tag.outputs.tag }}')
|
||||||
|
else
|
||||||
|
last_tag=$(git describe --tags --match "v*" --abbrev=0 --exclude='${{ steps.set_tag.outputs.tag }}' --exclude='*-*')
|
||||||
|
fi
|
||||||
|
echo >> CHANGELOG.md
|
||||||
|
echo "**Full Changelog**: [$last_tag -> $this_tag](https://github.com/octopusYan/alist-gui/compare/${last_tag}...${this_tag})" >> CHANGELOG.md
|
||||||
|
|
||||||
|
- name: Upload changelog to Github
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
|
||||||
|
with:
|
||||||
|
name: changelog
|
||||||
|
path: CHANGELOG.md
|
||||||
|
|
||||||
|
windows:
|
||||||
|
needs: meta
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- msbuild_target: x64
|
||||||
|
lowercase_target: x64
|
||||||
|
runs-on: windows-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
show-progress: false
|
||||||
|
|
||||||
|
- name: Set up JDK
|
||||||
|
uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
java-version: 21
|
||||||
|
distribution: 'dragonwell'
|
||||||
|
architecture: x64
|
||||||
|
cache: maven
|
||||||
|
|
||||||
|
- name: Build with Maven
|
||||||
|
run: |
|
||||||
|
mvn clean package -f pom.xml
|
||||||
|
mkdir zipball && cp target/*-windows.zip zipball
|
||||||
|
|
||||||
|
- name: Upload AListGUI to Github
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: AListGUI-windows
|
||||||
|
path: zipball
|
||||||
|
|
||||||
|
release:
|
||||||
|
if: startsWith(github.ref, 'refs/tags/v')
|
||||||
|
needs: [ meta, windows ]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
actions: write
|
||||||
|
steps:
|
||||||
|
- name: Download AListGUI from Github
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
path: assets
|
||||||
|
|
||||||
|
- name: Cleanup files
|
||||||
|
run: |
|
||||||
|
mv -vf assets/changelog/* .
|
||||||
|
cd assets
|
||||||
|
find . -type f | while read f; do mv -fvt . $f; done
|
||||||
|
|
||||||
|
- name: Release to Github
|
||||||
|
uses: softprops/action-gh-release@v2
|
||||||
|
with:
|
||||||
|
body_path: CHANGELOG.md
|
||||||
|
files: |
|
||||||
|
assets/*
|
||||||
|
prerelease: ${{ needs.meta.outputs.prerelease != 'false' }}
|
Loading…
Reference in New Issue
Block a user