This repository has been archived by the owner on Jan 31, 2023. It is now read-only.
generated from ShaBaiTianCN/Modpack
-
Notifications
You must be signed in to change notification settings - Fork 4
119 lines (101 loc) · 3.46 KB
/
packer.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
name: Packer
on:
pull_request_target:
workflow_dispatch:
inputs:
version:
description: 'Version'
required: true
type: string
pre_release:
description: 'This is a pre-release'
required: true
type: boolean
default: false
jobs:
pack:
runs-on: ubuntu-latest
name: Pack
outputs:
release_name: ${{ steps.pack.outputs.release_name }}
steps:
- name: Checkout master
uses: actions/checkout@v3
if: github.event_name == 'workflow_dispatch'
- name: Checkout ${{ github.event.pull_request.head.sha }}
uses: actions/checkout@v3
if: github.event_name == 'pull_request_target'
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Pack
id: pack
env:
event_name: ${{ github.event_name }}
event_number: PR-${{ github.event.number }}
version: ${{ github.event.inputs.version }}
run: python Packer.py
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: ${{ steps.pack.outputs.release_name }}
path: ${{ steps.pack.outputs.release_name }}/
create-release:
runs-on: ubuntu-latest
name: Create Release
needs: pack
if: ${{ github.event_name == 'workflow_dispatch' }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download Artifact
uses: actions/download-artifact@v3
with:
name: ${{ needs.pack.outputs.release_name }}
path: ${{ needs.pack.outputs.release_name }}
- name: Zip
run: cd ${{ needs.pack.outputs.release_name }} && zip -r ../${{ needs.pack.outputs.release_name }}.zip ./* && cd ..
- name: Create and Upload
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create ${{ github.event.inputs.version }} ${{ needs.pack.outputs.release_name }}.zip --title ${{ needs.pack.outputs.release_name }}
- name: Mark Prerelease
if: ${{ github.event.inputs.pre_release == 'true' }}
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release edit ${{ github.event.inputs.version }} --prerelease
comment-pr:
runs-on: ubuntu-latest
name: Comment PR
needs: pack
if: ${{ github.event_name == 'pull_request_target' }}
steps:
- name: Find Comment
id: find_comment
uses: peter-evans/find-comment@v2
with:
issue-number: ${{ github.event.number }}
comment-author: github-actions[bot]
direction: first
- name: Create Comment
uses: peter-evans/create-or-update-comment@v2
with:
issue-number: ${{ github.event.number }}
body: 在 [这里](../actions/runs/${{ github.run_id }}) 下载此 PR 的最新打包。
if: steps.find_comment.outputs.comment-id == 0
- name: Update Comment
uses: peter-evans/create-or-update-comment@v2
with:
comment-id: ${{ steps.find_comment.outputs.comment-id }}
body: 在 [这里](../actions/runs/${{ github.run_id }}) 下载此 PR 的最新打包。
edit-mode: replace
if: steps.find_comment.outputs.comment-id != 0