Skip to content

Commit

Permalink
feat: GitHub Workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
SALTWOOD committed Jan 4, 2025
1 parent 7d6da49 commit d89874b
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 2 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/tag-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: "Build and Release SaltyQQChat"

on:
push:
tags:
- "v*"

jobs:
build-and-release:
runs-on: ubuntu-latest
name: "Build, Package and Release"
steps:
- name: "Checkout Code"
uses: actions/checkout@v4

- name: "Check Version from Tag"
id: check_version
run: |
# 获取当前推送的tag
TAG_VERSION = "${GITHUB_REF##*/}"
# 从 mcdreforged.plugin.json 中读取 version 字段
PLUGIN_VERSION=$(jq -r '.version' mcdreforged.plugin.json)
echo "Tag version: $TAG_VERSION"
echo "Plugin version from mcdreforged.plugin.json: $PLUGIN_VERSION"
# 比较 tag 和 plugin.json 中的版本
if [ "$TAG_VERSION" != "$PLUGIN_VERSION" ]; then
echo "Version mismatch: Tag version and meta.json version do not match."
exit 1
else
echo "Version match: Proceeding with the build."
fi
- name: "Build and Package the Plugin"
run: |
# 打包源代码为一个压缩包
mkdir -p dist
tar -czf dist/SaltyQQChat-${TAG_VERSION}.mcdr * # 打包所有文件到压缩包
- name: "Upload Artifact"
uses: actions/upload-artifact@v4
with:
name: "SaltyQQChat-${TAG_VERSION}.mcdr"
path: dist/SaltyQQChat-${TAG_VERSION}.mcdr

- name: "Create GitHub Release"
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: ${{ contains(github.ref, 'pre') }}
files: |
dist/SaltyQQChat-${TAG_VERSION}.mcdr
4 changes: 2 additions & 2 deletions mcdreforged.plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"version": "1.0.0",
"name": "SaltyQQChat",
"description": {
"en_us": "Useful Functions with QQ",
"zh_cn": "QQ 相关实用功能"
"en_us": "",
"zh_cn": "Scalable QQ-Bot Built on QQAPI"
},
"author": [
"SALTWOOD"
Expand Down

0 comments on commit d89874b

Please sign in to comment.