-
Notifications
You must be signed in to change notification settings - Fork 0
124 lines (113 loc) · 4 KB
/
Simple-ResourcePacker.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
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
name: 簡易資源包發布
on:
workflow_call:
inputs:
### Resourcepack Settings
resourcepack_file_name:
required: true
type: string
description: "資源包檔案名稱,需使用英文,GitHub Release 吃不到中文字"
###
### GitHub Release Settings
release_title_name:
required: true
type: string
description: "發布標題名稱"
release_body_path:
required: false
type: string
default: ".github/configs/release_body.md"
description: "發布內容路徑,預設路徑為 ``.github/configs/release_body.md``"
force_include_files:
required: false
type: string
description: "強制將指定檔案包入資源包,如果沒設定 PackSquash 將自動忽略非資源包相關的檔案,例如授權許可檔案"
release_tag:
required: false
type: string
default: "latest"
description: "發布的版本標籤,通常不需要動此數值,預設值為 ``latest``"
release_update:
required: false
type: boolean
default: true
description: "自動更新現有的版本標籤,預設值為 ``true``"
###
### Replacer Settings
git_version_replacer:
required: true
type: boolean
description: "啟用自動轉換變數成該提交的 git hash"
git_version_var:
required: false
type: string
default: "$GIT_VAR"
description: "自動轉換的變數名,預設為``$GIT_VAR``"
generate_time_replacer:
required: true
type: boolean
description: "啟用自動轉換變數成目前資源包產生時間,適合用於發布內容檔案"
generate_time_var:
required: false
type: string
default: "$DATE_TIME"
description: "自動轉換的變數名,預設為``$DATE_TIME``"
###
jobs:
Packer:
name: 打包資源包
runs-on: ubuntu-latest
steps:
- name: 查看專案
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 轉換變數成 Git 版本
if: ${{ inputs.git_version_replacer }}
run: |
sed -i 's/${{ inputs.git_version_var }}/'${GITHUB_SHA::7}'/1' pack.mcmeta
- name: 轉換變數成目前資源包時間
if: ${{ inputs.generate_time_replacer }}
run: |
current_time=$(TZ='Asia/Taipei' date +'%Y 年 %m 月 %d 日 %H 點 %M 分')
sed -i "s/\${{ inputs.generate_time_var }}/$current_time/g" ${{ inputs.release_body_path }}
- name: 產生 Force Include 資料
id: force_include
run: |
{
echo 'data<<EOF'
python <(wget https://raw.githubusercontent.com/TeamKugimiya/reusable-workflows/main/scripts/force_include_generate.py -q -O-)
echo EOF
} >> "$GITHUB_OUTPUT"
env:
force_include_files: ${{ inputs.force_include_files }}
- name: 製作資源包
uses: ComunidadAylas/PackSquash-action@v4
with:
packsquash_version: latest-unstable
options: |
pack_directory = '.'
never_store_squash_times = true
${{ steps.force_include.outputs.data }}
- name: 下載壓縮檔
uses: actions/download-artifact@v4
with:
name: Optimized pack
path: ./
- name: 刪除產生成品
uses: geekyeggo/delete-artifact@v5
with:
name: |
Optimized pack
- name: 重新命名壓縮檔
run: |
mv ./pack.zip ${{ inputs.resourcepack_file_name }}.zip
- name: 自動更新發布
uses: ncipollo/release-action@v1
with:
artifacts: "${{ inputs.resourcepack_file_name }}.zip"
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ inputs.release_tag }}
allowUpdates: ${{ inputs.release_update }}
name: ${{ inputs.release_title_name }}
bodyFile: ${{ inputs.release_body_path }}