添加Windows应用图标和软件信息 #25
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will build a golang project | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go | |
name: CreateRelease | |
on: | |
release: | |
types: | |
- prereleased | |
# - released | |
push: | |
tags: | |
- "v*" | |
jobs: | |
create_release: | |
if: github.event_name == 'push' | |
name: Create Release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- 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: 请移步 [CHANGELOG.md](https://github.com/iotames/v2raypool/blob/master/CHANGELOG.md) 查看更多详情. | |
draft: false | |
prerelease: true | |
build: | |
# if: github.event_name == 'release' | |
# needs: create_release | |
strategy: | |
matrix: | |
goos: [linux, darwin, windows] | |
goarch: [amd64, 386] | |
exclude: | |
- goarch: 386 | |
goos: darwin | |
permissions: # 需要设置写权限才能自动发布 | |
contents: write | |
runs-on: ubuntu-latest | |
env: | |
GOOS: ${{ matrix.goos }} | |
GOARCH: ${{ matrix.goarch }} | |
CGO_ENABLED: 0 | |
steps: | |
- 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 | |
go install github.com/josephspurrier/goversioninfo/cmd/goversioninfo@latest | |
- 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: Prepare Build for Windows | |
if: matrix.goos == 'windows' | |
run: | | |
go env GOPATH | |
go generate ./main || echo "try export PATH ..." && export PATH=$PATH:`go env GOPATH`/bin && go generate ./main | |
- name: Build | |
run: | | |
echo 'hello.ref=${{ github.ref }}' | |
echo 'hello.ref_name=${{ github.ref_name }}' | |
mkdir -p build_assets | |
go build -v -o build_assets/v2raypool -trimpath -ldflags "-s -w -linkmode internal -buildid= -X 'main.AppVersion=${{ github.ref_name }}' -X 'main.GoVersion=`go version`'" ./main | |
- 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: Prepare package | |
run: | | |
cp -rv ./main/resource ./build_assets/ | |
cp -rv ./main/bin ./build_assets/ | |
touch ./build_assets/subscribe_data.txt | |
- 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 files to GitHub release | |
uses: svenstaro/upload-release-action@v2 | |
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 |