mirror of
https://github.com/gl-inet/glkvm-cloud.git
synced 2026-09-12 05:48:57 +00:00
@@ -0,0 +1,60 @@
|
||||
name: release
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-20.04
|
||||
outputs:
|
||||
upload_url: ${{ steps.release.outputs.upload_url }}
|
||||
steps:
|
||||
- id: changelog
|
||||
uses: ardalanamini/auto-changelog@v1.1.0
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- id: release
|
||||
uses: actions/create-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
tag_name: ${{ github.ref }}
|
||||
release_name: ${{ github.ref }}
|
||||
draft: true
|
||||
body: ${{steps.changelog.outputs.changelog}}
|
||||
release-asset:
|
||||
runs-on: ubuntu-20.04
|
||||
needs: release
|
||||
strategy:
|
||||
matrix:
|
||||
target: [ linux.amd64, linux.arm64, darwin.amd64, windows.amd64 ]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: true
|
||||
- id: get-version
|
||||
uses: battila7/get-version-action@v2
|
||||
- uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.15.7
|
||||
- id: release-asset
|
||||
env:
|
||||
target: ${{ matrix.target }}
|
||||
run: |
|
||||
version=${{ steps.get-version.outputs.version-without-v }}
|
||||
os=$(echo $target | awk -F. '{print $1}')
|
||||
arch=$(echo $target | awk -F. '{print $2}')
|
||||
./build.sh $os $arch
|
||||
mv rttys-$os-$arch rttys-$os-$arch-$version
|
||||
tar zcf rttys-$os-$arch-$version.tar.gz rttys-$os-$arch-$version
|
||||
echo "::set-output name=asset-path::./rttys-$os-$arch-$version.tar.gz"
|
||||
echo "::set-output name=asset-name::rttys-$os-$arch-$version.tar.gz"
|
||||
- id: upload-release-asset
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ needs.release.outputs.upload_url }}
|
||||
asset_path: ${{ steps.release-asset.outputs.asset-path }}
|
||||
asset_name: ${{ steps.release-asset.outputs.asset-name }}
|
||||
asset_content_type: application/gzip
|
||||
@@ -4,38 +4,25 @@ VersionPath="github.com/zhaojh329/rttys/version"
|
||||
GitCommit=$(git log --pretty=format:"%h" -1)
|
||||
BuildTime=$(date +%FT%T%z)
|
||||
|
||||
[ $# -lt 2 ] && {
|
||||
echo "Usage: $0 linux amb64"
|
||||
exit 1
|
||||
}
|
||||
|
||||
generate() {
|
||||
local os="$1"
|
||||
local arch="$2"
|
||||
local dir="rttys-$os-$arch"
|
||||
local bin="rttys"
|
||||
|
||||
mkdir output/$dir
|
||||
cp rttys.conf output/$dir
|
||||
mkdir $dir
|
||||
cp rttys.conf $dir
|
||||
|
||||
[ "$os" = "windows" ] && {
|
||||
bin="rttys.exe"
|
||||
}
|
||||
|
||||
GOOS=$os GOARCH=$arch CGO_ENABLED=0 go build -ldflags="-s -w -X $VersionPath.gitCommit=$GitCommit -X $VersionPath.buildTime=$BuildTime" -o output/$dir/$bin
|
||||
|
||||
cd output
|
||||
|
||||
if [ "$os" = "windows" ];
|
||||
then
|
||||
zip -r $dir.zip $dir
|
||||
else
|
||||
tar zcvf $dir.tar.gz $dir
|
||||
fi
|
||||
|
||||
cd ..
|
||||
GOOS=$os GOARCH=$arch CGO_ENABLED=0 go build -ldflags="-s -w -X $VersionPath.gitCommit=$GitCommit -X $VersionPath.buildTime=$BuildTime" -o $dir/$bin
|
||||
}
|
||||
|
||||
rm -rf output
|
||||
mkdir output
|
||||
|
||||
generate linux amd64
|
||||
generate linux arm64
|
||||
generate darwin amd64
|
||||
generate freebsd amd64
|
||||
generate windows amd64
|
||||
generate $1 $2
|
||||
|
||||
Reference in New Issue
Block a user