-
Notifications
You must be signed in to change notification settings - Fork 1.7k
51 lines (41 loc) · 1.89 KB
/
build.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
name: Build worker.js
on:
push:
branches: ["main"]
release:
types: ["published"]
jobs:
build:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "latest"
cache: "npm"
- name: Install modules
run: npm i wrangler@latest
- name: Build
run: npx wrangler build
- name: Add Header
run: cp ${{ github.workspace }}/dist/worker.js ${{ github.workspace }}/dist/worker-original.js && echo -e "/*!\r\n * v2ray Subscription Worker (${{ github.sha }})\r\n * Copyright 2024 Vahid Farid (https://twitter.com/vahidfarid)\r\n * Licensed under GPLv3 (https://github.com/vfarid/v2ray-worker/blob/main/Licence.md)\r\n */\r\n\r\n" > ${{ github.workspace }}/dist/worker.js && cat ${{ github.workspace }}/dist/worker-original.js >> ${{ github.workspace }}/dist/worker.js && rm -f ${{ github.workspace }}/dist/worker-original.js
- name: Upload to Artifacts
uses: actions/upload-artifact@v4
with:
name: worker
path: ${{ github.workspace }}/dist/worker.js
- name: Add Release Header
run: echo -e "/*!\n * v2ray Subscription Worker ${{ github.event.release.tag_name }}\n * Copyright 2024 Vahid Farid (https://twitter.com/vahidfarid)\n * Licensed under GPLv3 (https://github.com/vfarid/v2ray-worker/blob/main/Licence.md)\n */\n\n$(cat ${{ github.workspace }}/dist/worker-original.js)" > ${{ github.workspace }}/dist/worker.js
- name: Upload to GitHub Release
uses: svenstaro/upload-release-action@v2
if: github.event_name == 'release'
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ github.workspace }}/dist/worker.js
asset_name: worker.js
tag: ${{ github.ref }}
overwrite: true