-
Notifications
You must be signed in to change notification settings - Fork 0
101 lines (89 loc) · 3.2 KB
/
Copy pathpack_mission.yml
File metadata and controls
101 lines (89 loc) · 3.2 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
name: Package Mission
on:
push:
branches:
- '**'
paths-ignore:
- 'export/**'
release:
types: [created,edited]
permissions:
contents: write
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout Missions
uses: actions/checkout@v4
- name: Get and Transform Version
if: github.event_name == 'release'
id: version
run: |
TAG=${{ github.event.release.tag_name }}
CLEAN_VERSION=$(echo "$TAG" | sed -E '
s/^v//;
s/([0-9]+)\.([0-9]+)\.([0-9]+)/\1\2\3/;
s/\+.*//;
s/-/_/;
s/^/v/
')
echo "version=$CLEAN_VERSION" >> $GITHUB_OUTPUT
echo "Original tag: $TAG → Clean version: $CLEAN_VERSION"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: robinraju/release-downloader@v1.7
with:
repository: "German-Rangers-MM/PBO-Packer"
latest: true
fileName: "pbo-packer"
- name: Package Missions
run: |
# Remove existing export files to ensure clean replacement
rm -rf export
mkdir -p export
chmod +x ./pbo-packer
./pbo-packer . ./export
# Rename files with version only for releases
if [ "${{ github.event_name }}" = "release" ]; then
for pbo in ./export/*.pbo; do
base=$(basename "$pbo")
mission_name="${base%%.*}"
map_ext="${base#*.}"
map_name="${map_ext%.*}"
ext="${pbo##*.}"
new_name="${mission_name}_${{ steps.version.outputs.version }}.${map_name}.${ext}"
mv "$pbo" "./export/$new_name"
done
fi
# Write to workflow summary
echo "### 🚀 Packed Missions" >> $GITHUB_STEP_SUMMARY
if [ "${{ github.event_name }}" = "release" ]; then
echo "**Version:** ${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
else
echo "**Version:** Latest (Push)" >> $GITHUB_STEP_SUMMARY
fi
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Mission File | Size |" >> $GITHUB_STEP_SUMMARY
echo "|--------------|------|" >> $GITHUB_STEP_SUMMARY
for pbo in ./export/*.pbo; do
size=$(ls -lh $pbo | awk '{print $5}')
filename=$(basename "$pbo")
echo "| \`$filename\` | $size |" >> $GITHUB_STEP_SUMMARY
done
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Total missions:** $(ls ./export/*.pbo | wc -l)" >> $GITHUB_STEP_SUMMARY
echo "Packed and tagged missions:"
ls -lh ./export/
- name: Commit and Push Packaged Files
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add ./export/*.pbo
if git diff --cached --quiet; then
echo "No changes to commit."
else
git commit -m "chore: add packaged mission files [ci skip]"
git push
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}