Skip to content

Commit

Permalink
ADD v2raypool.service for systemd
Browse files Browse the repository at this point in the history
  • Loading branch information
iotames committed Apr 9, 2024
1 parent cc276ec commit 57f68f1
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 83 deletions.
168 changes: 85 additions & 83 deletions .github/workflows/release_tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,19 @@ on:
types:
- prereleased
- released
# push:
# tags:
# - "v*"
push:
tags:
- "v*"

jobs:
build:
strategy:
matrix:
goos: [linux, darwin, windows]
goarch: [amd64, 386]
# filesuf: ['.exe', '']
exclude:
- goarch: 386
goos: darwin
# - filesuf: ''
# goos: windows
# - filesuf: '.exe'
# goos: [linux, darwin]

permissions: # 需要设置写权限才能自动发布
contents: write
Expand All @@ -36,87 +31,94 @@ jobs:
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 0
steps:
- uses: actions/checkout@master
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22.x'
- name: Checkout Code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22.x'

- name: Install dependencies
run: |
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,direct
go mod tidy
- name: Get File Name
id: get_filename
run: |
export _NAME=v2raypool-${{ matrix.goos }}-${{ matrix.goarch }}
echo "GOOS: $GOOS, GOARCH: $GOARCH, RELEASE_NAME: $_NAME"
echo "ASSET_NAME=$_NAME" >> $GITHUB_OUTPUT
echo "ASSET_NAME=$_NAME" >> $GITHUB_ENV
- name: Install dependencies
run: |
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,direct
go mod tidy
- name: Get File Name
id: get_filename
run: |
export _NAME=v2raypool-${{ matrix.goos }}-${{ matrix.goarch }}
echo "GOOS: $GOOS, GOARCH: $GOARCH, RELEASE_NAME: $_NAME"
echo "ASSET_NAME=$_NAME" >> $GITHUB_OUTPUT
echo "ASSET_NAME=$_NAME" >> $GITHUB_ENV
- name: Build
run: |
mkdir -p build_assets
go build -v -o build_assets/v2raypool -trimpath -ldflags "-s -w -buildid=" ./main
- name: Build
run: |
mkdir -p build_assets
go build -v -o build_assets/v2raypool -trimpath -ldflags "-s -w -buildid=" ./main
- name: Rename Windows File
if: matrix.goos == 'windows'
run: |
cd ./build_assets || exit 1
mv v2raypool v2raypool.exe
- name: Rename Windows File
if: matrix.goos == 'windows'
run: |
cd ./build_assets || exit 1
mv v2raypool v2raypool.exe
- name: Download geo files
run: |
wget -O main/bin/geoip.dat "https://raw.githubusercontent.com/v2fly/geoip/release/geoip.dat"
wget -O main/bin/geoip-only-cn-private.dat "https://raw.githubusercontent.com/v2fly/geoip/release/geoip-only-cn-private.dat"
wget -O main/bin/geosite.dat "https://raw.githubusercontent.com/v2fly/domain-list-community/release/dlc.dat"
- name: Download geo files
run: |
wget -O main/bin/geoip.dat "https://raw.githubusercontent.com/v2fly/geoip/release/geoip.dat"
wget -O main/bin/geoip-only-cn-private.dat "https://raw.githubusercontent.com/v2fly/geoip/release/geoip-only-cn-private.dat"
wget -O main/bin/geosite.dat "https://raw.githubusercontent.com/v2fly/domain-list-community/release/dlc.dat"
- name: Prepare package
run: |
cp -rv ./main/resource ./build_assets/
cp -rv ./main/bin ./build_assets/
touch ./build_assets/subscribe_data.txt
- name: Prepare package
run: |
cp -rv ./main/resource ./build_assets/
cp -rv ./main/bin ./build_assets/
touch ./build_assets/subscribe_data.txt
- name: Package
run: tar zcvf ${{ steps.get_filename.outputs.ASSET_NAME }}.tar.gz ./build_assets
- name: Prepare package for Linux
if: matrix.goos == 'linux'
run: cp -rv ./release/config/systemd ./build_assets/

- name: Package
run: tar zcvf ${{ steps.get_filename.outputs.ASSET_NAME }}.tar.gz ./build_assets

# 上传附件
- name: Upload file to Artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ steps.get_filename.outputs.ASSET_NAME }}.tar.gz
path: ${{ steps.get_filename.outputs.ASSET_NAME }}.tar.gz
# 上传附件
- name: Upload file to Artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ steps.get_filename.outputs.ASSET_NAME }}.tar.gz
path: ${{ steps.get_filename.outputs.ASSET_NAME }}.tar.gz

# - name: Create Release
# id: create_release
# uses: actions/create-release@v1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# tag_name: ${{ github.event.release.tag_name }}
# release_name: Release ${{ github.ref }}
# body: Please refer to [CHANGELOG.md](https://github.com/iotames/v2raypool/blob/master/CHANGELOG.md) for details.
# draft: false
# prerelease: false
- name: Create Release
id: create_release
uses: actions/create-release@v1
if: github.event_name == 'push'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref_name }}
body: Please refer to [CHANGELOG.md](https://github.com/iotames/v2raypool/blob/master/CHANGELOG.md) for details.
draft: false
prerelease: false

- name: Upload files to GitHub release
uses: svenstaro/upload-release-action@v2
if: github.event_name == 'release'
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file_glob: true
file: ./${{ steps.get_filename.outputs.ASSET_NAME }}.tar.gz
tag: ${{ github.ref }}
overwrite: true
- name: Upload files to GitHub release
uses: svenstaro/upload-release-action@v2
if: github.event_name == 'release'
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file_glob: true
file: ./${{ steps.get_filename.outputs.ASSET_NAME }}.tar.gz
tag: ${{ github.ref }}
overwrite: true

# - name: Upload Release Asset
# uses: actions/upload-release-asset@v1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# upload_url: ${{ steps.create_release.outputs.upload_url }}
# asset_path: ${{ steps.get_filename.outputs.ASSET_NAME }}.tar.gz
# asset_name: ${{ steps.get_filename.outputs.ASSET_NAME }}.tar.gz
# asset_content_type: application/zip
# - name: Upload Release Asset
# uses: actions/upload-release-asset@v1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# upload_url: ${{ steps.create_release.outputs.upload_url }}
# asset_path: ${{ steps.get_filename.outputs.ASSET_NAME }}.tar.gz
# asset_name: ${{ steps.get_filename.outputs.ASSET_NAME }}.tar.gz
# asset_content_type: application/zip
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## 升级日志

### v1.3.4

添加Linux平台systemd系统服务示例文件

### v1.3.3

1. 升级v2ray核心兼容至v5.14.1
Expand Down
17 changes: 17 additions & 0 deletions release/config/systemd/system/v2raypool.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[Unit]
Description=V2ray ProxyPool
Documentation=https://github.com/iotames/v2raypool
After=network.target

[Service]
User=root
WorkingDirectory=/root/v2raypool/main
ExecStart=/root/v2raypool/main/v2raypool
Restart=on-failure
RestartSec=300
TimeoutStopSec=10
StandardOutput=file:/root/v2raypool/main/output.log
StandardError=file:/root/v2raypool/main/output.err.log

[Install]
WantedBy=multi-user.target

0 comments on commit 57f68f1

Please sign in to comment.