-
Notifications
You must be signed in to change notification settings - Fork 25
143 lines (126 loc) · 4.32 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
name: "Generator"
on:
workflow_dispatch:
inputs:
# https://github.com/MetaCubeX/Clash.Meta v1.14.1
# net-proxy/clash-meta/clash-meta-1.14.1.ebuild
# release artiface: ${PN}-${PV}-deps.tar.xz: clash-meta-1.14.1-deps.tar.xz
# release tag: ${P}=${PN}-${PV}: clash-meta-1.14.1
LANG:
type: choice
description: "generate golang(go-mod/vendor) or javascript(node_modules) deps"
options:
- golang
- javascript
- javascript(pnpm)
REPO:
description: "github repo name: MetaCubeX/Clash.Meta"
required: true
TAG:
description: "github tag: v1.14.1"
required: true
P:
description: "P in ebuild: clash-meta-1.14.1"
required: true
WORKDIR:
description: "(optional)source directory to perform scripts, default to empty string"
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'
- name: Generate golang deps
if: inputs.LANG == 'golang'
env:
P: ${{ inputs.P }}
WORKDIR: ${{ inputs.WORKDIR }}
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 ]; then
rm -rf go-mod
go mod vendor
tar --create --auto-compress --file /tmp/${P}-vendor.tar.xz 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 goland deps to release artifaces
if: inputs.LANG == 'golang'
uses: softprops/action-gh-release@v2
with:
files: |
/tmp/${{ inputs.P }}-deps.tar.xz
/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 }}