Skip to content

Commit

Permalink
build and release
Browse files Browse the repository at this point in the history
  • Loading branch information
p4gefau1t committed Apr 26, 2020
1 parent e03c6bc commit 35da055
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 23 deletions.
26 changes: 21 additions & 5 deletions .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
on:
push:
branches:
- master
tags:
- 'v*'
jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -12,10 +12,26 @@ jobs:
go-version: 1.14.x
- name: Checkout code
uses: actions/checkout@v2
- name: Checkout tag
run: |
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
tag_name="${GITHUB_REF##*/}"
echo Tag $tag_name
git checkout $tag_name
- name: Build
run: ./build-all.sh
- name: Upload Binary
run: |
./build-all.sh
set -x
assets=()
for asset in ./release/*; do
assets+=("-a" "$asset")
done
tag_name="${GITHUB_REF##*/}"
hub release create -p -d "${assets[@]}" -m "$tag_name" "$tag_name"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload binary
uses: actions/upload-artifact@v1
with:
name: dist-release
path: ./release
path: ./release
32 changes: 14 additions & 18 deletions build-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,37 +17,33 @@ PLATFORMS="$PLATFORMS linux/s390x"
type setopt >/dev/null 2>&1

rm -rd release
rm -rd temp
rm ./*.dat

mkdir release
mkdir temp

wget https://github.com/v2ray/domain-list-community/raw/release/dlc.dat -O geosite.dat
wget https://raw.githubusercontent.com/v2ray/geoip/release/geoip.dat -O geoip.dat


SCRIPT_NAME=`basename "$0"`
FAILURES=""
CURRENT_DIRECTORY=${PWD##*/}
OUTPUT=release/$CURRENT_DIRECTORY

for PLATFORM in $PLATFORMS; do
GOOS=${PLATFORM%/*}
GOARCH=${PLATFORM#*/}
BIN_FILENAME="${OUTPUT}-${GOOS}-${GOARCH}"
if [[ "${GOOS}" == "windows" ]]; then BIN_FILENAME="${BIN_FILENAME}.exe"; fi
CMD="CGO_ENABLE=0 GOOS=${GOOS} GOARCH=${GOARCH} go build -o ${BIN_FILENAME} $@ -ldflags=\"-s -w\""
ZIP_FILENAME="trojan-go-${GOOS}-${GOARCH}.zip"
CMD="CGO_ENABLE=0 GOOS=${GOOS} GOARCH=${GOARCH} go build -o temp $@ -ldflags=\"-s -w\""
echo "${CMD}"
eval $CMD || FAILURES="${FAILURES} ${PLATFORM}"
zip -j release/$ZIP_FILENAME temp/* data/* ./*.dat
sha1sum release/$ZIP_FILENAME > release/$ZIP_FILENAME.sha1
rm temp/*
done

# eval errors
if [[ "${FAILURES}" != "" ]]; then
echo ""
echo "${SCRIPT_NAME} failed on: ${FAILURES}"
fi

cd release
wget https://github.com/v2ray/domain-list-community/raw/release/dlc.dat -O geosite.dat
wget https://raw.githubusercontent.com/v2ray/geoip/release/geoip.dat -O geoip.dat
cp ../data/* ./

for name in trojan-go-*;do
zip $name.zip client.json server.json trojan-go.service geoip.dat geosite.dat $name
sha1sum $name.zip > $name.zip.sha1
rm $name
done

rm *.json *.service *.dat

0 comments on commit 35da055

Please sign in to comment.