Repository navigation
80 lines (75 loc) · 2.5 KB
/
Copy pathpackage-mod.yml
File metadata and controls
80 lines (75 loc) · 2.5 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
name: Package RimWorld Mod
on:
workflow_call:
inputs:
tag-name:
description: 'The tag for naming the package (e.g. v1.2.3)'
required: true
type: string
exclude-patterns:
description: 'Additional rsync exclude patterns (space-separated)'
required: false
type: string
default: ''
outputs:
artifact-name:
description: 'Name of the uploaded artifact containing the zip'
value: mod-package
zip-filename:
description: 'Filename of the generated zip'
value: ${{ inputs.tag-name }}
permissions:
contents: read
jobs:
package:
name: Package Mod
runs-on: ubuntu-latest
outputs:
mod-safe: ${{ steps.package.outputs.mod_safe }}
steps:
- name: Checkout Caller Repo
uses: actions/checkout@v7
- name: Package Mod
id: package
run: |
TAG="${{ inputs.tag-name }}"
if [ -f "About/About.xml" ]; then
MOD_NAME=$(grep -oP '(?<=<name>)[^<]+' About/About.xml | head -1)
MOD_SAFE=$(echo "$MOD_NAME" | sed 's/[^a-zA-Z0-9 ]//g' | sed 's/ /-/g' | sed 's/-\+/-/g')
else
MOD_SAFE="${{ github.event.repository.name }}"
fi
[ -z "$MOD_SAFE" ] && MOD_SAFE="mod"
echo "mod_safe=$MOD_SAFE" >> $GITHUB_OUTPUT
EXTRA_EXCLUDES=""
if [ -n "${{ inputs.exclude-patterns }}" ]; then
for pattern in ${{ inputs.exclude-patterns }}; do
EXTRA_EXCLUDES="$EXTRA_EXCLUDES --exclude='$pattern'"
done
fi
mkdir -p "/tmp/${MOD_SAFE}"
rsync -av --delete \
--exclude='.git/' \
--exclude='.github/' \
--exclude='Source/' \
--exclude='Tests/' \
--exclude='.claude/' \
--exclude='.trae/' \
--exclude='docs/' \
--exclude='*.csproj' \
--exclude='*.sln' \
--exclude='.gitignore' \
--exclude='.gitattributes' \
--exclude='*.md' \
--exclude='.shared-workflows/' \
$EXTRA_EXCLUDES \
"./" "/tmp/${MOD_SAFE}/"
cd /tmp
zip -r "${MOD_SAFE}-${TAG}.zip" "${MOD_SAFE}/"
echo "::notice::打包完成: ${MOD_SAFE}-${TAG}.zip"
- name: Upload Mod Package
uses: actions/upload-artifact@v7
with:
name: mod-package
path: /tmp/${{ steps.package.outputs.mod_safe }}-${{ inputs.tag-name }}.zip
retention-days: 1