增加底部控制栏桌面歌词开关(#219) #95
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
permissions: | |
contents: write | |
jobs: | |
# 创建版本号 | |
increment-version: | |
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && contains(github.event.head_commit.message, 'release')) | |
name: Increment Version | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.set-version.outputs.NEW_VERSION }} | |
body: ${{ steps.create-release.outputs.RELEASE_BODY }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Increment version | |
id: set-version | |
run: | | |
VERSION=$(git describe --tags --abbrev=0 2>/dev/null || echo "v1.2.0") | |
MAJOR=$(echo $VERSION | awk -F. '{print $1}' | sed 's/v//') | |
MINOR=$(echo $VERSION | awk -F. '{print $2}') | |
PATCH=$(echo $VERSION | awk -F. '{print $3}') | |
PATCH=$((PATCH + 1)) | |
if [ "$PATCH" -gt 9 ]; then | |
PATCH=0 | |
MINOR=$((MINOR + 1)) | |
fi | |
NEW_VERSION="v$MAJOR.$MINOR.$PATCH" | |
echo "::set-output name=NEW_VERSION::$NEW_VERSION" | |
- name: Create release body | |
id: create-release | |
run: | | |
# 获取上一个tag | |
PREV_TAG=$(git describe --tags --abbrev=0) | |
# 获取最后一个tag到现在的所有commit信息 | |
COMMITS=$(git log ${PREV_TAG}..HEAD --pretty=format:"* %s") | |
# 如果没有commit信息,使用默认消息 | |
if [ -z "$COMMITS" ]; then | |
COMMITS="* Regular update and bug fixes" | |
fi | |
# 创建changelog链接 | |
CHANGELOG_LINK="https://github.com/${GITHUB_REPOSITORY}/compare/${PREV_TAG}...v${NEW_VERSION}" | |
# 创建release body | |
RELEASE_BODY="## What's Changed\n\n${COMMITS}\n\n**Full Changelog**: [${PREV_TAG}...v${NEW_VERSION}](${CHANGELOG_LINK})" | |
# 将release body转义后输出 | |
echo "RELEASE_BODY<<EOF" >> $GITHUB_OUTPUT | |
echo -e "$RELEASE_BODY" >> $GITHUB_OUTPUT | |
echo "EOF" >> $GITHUB_OUTPUT | |
- name: Create GitHub Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: ${{ steps.set-version.outputs.NEW_VERSION }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
name: "Release ${{ steps.set-version.outputs.NEW_VERSION }}" | |
body: ${{ steps.create-release.outputs.RELEASE_BODY }} | |
prerelease: false | |
draft: true | |
# Windows 端打包并上传到 GitHub Release | |
build-windows: | |
name: Build for Windows | |
runs-on: windows-latest | |
needs: increment-version | |
timeout-minutes: 30 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '18' | |
- name: Install dependencies | |
run: npm run install-all | |
- name: Run common build | |
run: npm run build | |
- name: Run Windows build | |
run: npm run electron:build:win | |
- name: Rename Windows artifact | |
run: | | |
mv "./dist_electron/MoeKoe Music.exe" "./MoeKoe_Music_Setup_${{ needs.increment-version.outputs.version }}.exe" | |
- name: Upload Windows artifact to GitHub Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: ${{ needs.increment-version.outputs.version }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
name: "Release ${{ needs.increment-version.outputs.version }}" | |
files: "./MoeKoe_Music_Setup_${{ needs.increment-version.outputs.version }}.exe" | |
# macOS 端打包并上传到 GitHub Release | |
build-macos: | |
name: Build for macOS | |
runs-on: macos-latest | |
needs: increment-version | |
timeout-minutes: 30 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '18' | |
- name: Install dependencies | |
run: npm run install-all | |
- name: Run common build | |
run: npm run build | |
- name: Run macOS build | |
run: npm run electron:build:macos | |
- name: Rename macOS artifacts | |
run: | | |
mv "./dist_electron/MoeKoe Music.dmg" "./MoeKoe_Music_${{ needs.increment-version.outputs.version }}-arm64.dmg" | |
mv "./dist_electron/MoeKoe Music.zip" "./MoeKoe_Music_${{ needs.increment-version.outputs.version }}-arm64-mac.zip" | |
- name: List files after renaming | |
run: ls -al ./dist_electron | |
- name: Upload macOS artifacts to GitHub Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: ${{ needs.increment-version.outputs.version }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
name: "Release ${{ needs.increment-version.outputs.version }}" | |
files: | | |
./MoeKoe_Music_${{ needs.increment-version.outputs.version }}-arm64.dmg | |
./MoeKoe_Music_${{ needs.increment-version.outputs.version }}-arm64-mac.zip | |
# Linux 端打包并上传到 GitHub Release | |
build-linux: | |
name: Build for Linux | |
runs-on: ubuntu-latest | |
needs: increment-version | |
timeout-minutes: 30 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '18' | |
- name: Install dependencies | |
run: npm run install-all | |
- name: Run common build | |
run: npm run build | |
- name: Run Linux build | |
run: npm run electron:build:linux | |
- name: Rename Linux artifacts | |
run: | | |
mv "./dist_electron/MoeKoe Music.AppImage" "./MoeKoe_Music_${{ needs.increment-version.outputs.version }}.AppImage" | |
mv "./dist_electron/MoeKoe Music.deb" "./MoeKoe Music_${{ needs.increment-version.outputs.version }}_amd64.deb" | |
- name: Upload Linux artifacts to GitHub Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: ${{ needs.increment-version.outputs.version }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
name: "Release ${{ needs.increment-version.outputs.version }}" | |
files: | | |
./MoeKoe_Music_${{ needs.increment-version.outputs.version }}.AppImage | |
./MoeKoe Music_${{ needs.increment-version.outputs.version }}_amd64.deb | |