-
Notifications
You must be signed in to change notification settings - Fork 25
156 lines (137 loc) · 4.81 KB
/
generator.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
name: "Generator"
on:
workflow_dispatch:
inputs:
# https://github.com/XTLS/Xray-core v24.11.11
# net-proxy/Xray/Xray-24.11.11.ebuild
# release artiface: ${PN}-${PV}-deps.tar.xz: Xray-24.11.11-deps.tar.xz
# release tag: ${P}=${PN}-${PV}: Xray-24.11.11
LANG:
type: choice
description: "generate golang(go-mod/vendor) or javascript(node_modules) deps"
options:
- golang
- javascript
- javascript(pnpm)
REPO:
description: "github repo name: XTLS/Xray-core"
required: true
TAG:
description: "github tag: v24.11.11"
required: true
P:
description: "P in ebuild: Xray-24.11.11"
required: true
WORKDIR:
description: "(optional) source directory to perform scripts, default to empty string"
default: ''
VENDORDIR:
description: "(optional) generate vendor.tar.xz, input the S in ebuild here: Xray-core-24.11.11, disabled default"
default: ''
jobs:
Generator:
permissions: write-all # required by push tag
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Checkout input repo
uses: actions/checkout@v4
with:
repository: ${{ inputs.REPO }}
ref: ${{ inputs.TAG }}
fetch-depth: 0
path: "input"
- name: delete old tag
env:
P: ${{ inputs.P }}
LANG: ${{ inputs.LANG }}
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git tag --delete ${P} || echo yes
- name: update go version
if: inputs.LANG == 'golang'
uses: actions/setup-go@v5
with:
go-version: 'stable'
cache: false
- name: Generate golang deps
if: inputs.LANG == 'golang'
env:
P: ${{ inputs.P }}
WORKDIR: ${{ inputs.WORKDIR }}
VENDORDIR: ${{ inputs.VENDORDIR }}
run: |
git tag ${P} -m "${P}-deps.tar.xz ${P}-vendor.tar.xz"
cd "input/${WORKDIR}"
GOMODCACHE="${PWD}"/go-mod go mod download -modcacherw
tar --create --auto-compress --file /tmp/${P}-deps.tar.xz go-mod
if [[ ! -f go.work && x"${VENDORDIR}" != x"" ]]; then
rm -rf go-mod
go mod vendor -modcacherw -o ${VENDORDIR}/vendor
tar --create --auto-compress --file /tmp/${P}-vendor.tar.xz ${VENDORDIR}/vendor
fi
- name: Generate javascript node_modules
if: inputs.LANG == 'javascript'
env:
P: ${{ inputs.P }}
WORKDIR: ${{ inputs.WORKDIR }}
run: |
git tag ${P} -m "${P}-node_modules.tar.xz"
cd "input/${WORKDIR}"
npm install --legacy-peer-deps --cache "${PWD}"/npm-cache
tar --create --auto-compress --file /tmp/${P}-node_modules.tar.xz node_modules
rm -rf node_modules
- name: Setup pnpm
if: inputs.LANG == 'javascript(pnpm)'
uses: pnpm/action-setup@v4
with:
version: latest
- name: Generate javascript(pnpm) node_modules
if: inputs.LANG == 'javascript(pnpm)'
env:
P: ${{ inputs.P }}
WORKDIR: ${{ inputs.WORKDIR }}
run: |
git tag ${P} -m "${P}-node_modules-pnpm.tar.xz"
cd "input/${WORKDIR}"
pnpm install
tar --create --auto-compress --file /tmp/${P}-node_modules-pnpm.tar.xz node_modules
rm -rf node_modules
- name: push tag
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
force: true
tags: true
- name: upload golang deps to release artifaces
if: inputs.LANG == 'golang'
uses: softprops/action-gh-release@v2
with:
files: |
/tmp/${{ inputs.P }}-deps.tar.xz
tag_name: ${{ inputs.P }}
- name: upload golang vendor to release artifaces
if: inputs.LANG == 'golang' && inputs.VENDORDIR != ''
uses: softprops/action-gh-release@v2
with:
files: |
/tmp/${{ inputs.P }}-vendor.tar.xz
tag_name: ${{ inputs.P }}
- name: upload javascript deps to release artifaces
if: inputs.LANG == 'javascript'
uses: softprops/action-gh-release@v2
with:
files: |
/tmp/${{ inputs.P }}-node_modules.tar.xz
tag_name: ${{ inputs.P }}
- name: upload javascript(pnpm) deps to release artifaces
if: inputs.LANG == 'javascript(pnpm)'
uses: softprops/action-gh-release@v2
with:
files: |
/tmp/${{ inputs.P }}-node_modules-pnpm.tar.xz
tag_name: ${{ inputs.P }}