alist-gui/.github/workflows/release.yml

136 lines
3.9 KiB
YAML
Raw Normal View History

2024-09-18 03:38:41 +08:00
name: Release
on:
push:
tags:
- "v*"
branches: [ "main", "test_ci" ]
paths:
2024-09-18 05:21:17 +08:00
- ".github/workflows/*.yml"
2024-09-18 03:38:41 +08:00
- "src/**"
- "pom.xml"
- "!**/*.md"
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
2024-09-18 03:44:50 +08:00
- 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 }}
2024-09-18 03:38:41 +08:00
- 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]}
2024-09-18 03:44:50 +08:00
- 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
2024-09-18 04:03:36 +08:00
# - name: Set up Node.js
# uses: actions/setup-node@v4
# with:
# node-version: 14
#
# - name: Install dependencies
# run: npm install conventional-changelog-cli
2024-09-18 03:38:41 +08:00
- 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
- name: Build with Maven
2024-09-18 03:41:31 +08:00
run: |
mvn --batch-mode --update-snapshots clean package
mkdir zipball && cp target/*-windows.zip zipball
2024-09-18 03:38:41 +08:00
- 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
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
2024-09-18 14:08:12 +08:00
- name: Release to Github
uses: softprops/action-gh-release@v2
with:
body_path: CHANGELOG.md
files: |
assets/*
prerelease: ${{ needs.meta.outputs.prerelease != 'false' }}