-
Notifications
You must be signed in to change notification settings - Fork 0
66 lines (53 loc) · 2.25 KB
/
tag-release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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: "Install Python"
run: |
sudo apt-get update
sudo apt-get install -y python3 python3-pip git
- name: "Check Version from Tag and Files"
id: check_version
run: |
TAG_VERSION="${GITHUB_REF##*/}"
TAG_VERSION="${TAG_VERSION#v}"
echo "Tag version: $TAG_VERSION"
PLUGIN_VERSION=$(jq -r '.version' mcdreforged.plugin.json)
echo "Plugin version from mcdreforged.plugin.json: $PLUGIN_VERSION"
PYTHON_VERSION=$(python -c "import importlib.util, sys; spec = importlib.util.spec_from_file_location('version', 'salty_qq_chat/version.py'); version = importlib.util.module_from_spec(spec); sys.modules['version'] = version; spec.loader.exec_module(version); print(version.VERSION_STR)")
echo "Python VERSION_STR: $PYTHON_VERSION"
if [ "$TAG_VERSION" != "$PLUGIN_VERSION" ]; then
echo "Version mismatch: Tag version and plugin.json version do not match."
exit 1
elif [ "$TAG_VERSION" != "$PYTHON_VERSION" ]; then
echo "Version mismatch: Tag version and Python VERSION_STR do not match."
exit 1
elif [ "$PLUGIN_VERSION" != "$PYTHON_VERSION" ]; then
echo "Version mismatch: Plugin version and Python VERSION_STR do not match."
exit 1
else
echo "Version match: Proceeding with the build."
fi
- name: "Build and Package the Plugin"
run: |
tar -czf SaltyQQChat-${TAG_VERSION}.mcdr *
- name: "Upload Artifact"
uses: actions/upload-artifact@v4
with:
name: "SaltyQQChat-${TAG_VERSION}.mcdr"
path: 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: |
SaltyQQChat-${TAG_VERSION}.mcdr