-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
224 additions
and
82 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
name: Build and Release | ||
run-name: Build ${{ github.event.inputs.version }} by @${{ github.actor }} | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: '版本号' | ||
required: true | ||
|
||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
|
||
- name: Repository Dispatch | ||
uses: peter-evans/repository-dispatch@v2 | ||
with: | ||
event-type: mrui-release | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.21' | ||
|
||
- name: Install UPX | ||
run: sudo apt-get install upx | ||
|
||
- name: download modules | ||
run: go mod download | ||
|
||
- name: Run build script | ||
run: bash build.sh ${{ github.event.inputs.version }} > temp.txt | ||
|
||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.TOKEN }} | ||
with: | ||
tag_name: ${{ github.event.inputs.version }} | ||
release_name: Release ${{ github.event.inputs.version }} | ||
draft: true | ||
prerelease: false | ||
|
||
- name: Upload Release Assets | ||
run: | | ||
for file in ./build/*; do | ||
if [ -f "$file" ]; then | ||
echo "Uploading $file" | ||
curl \ | ||
-H "Authorization: token ${{ secrets.TOKEN }}" \ | ||
-H "Content-Type: $(file -b --mime-type $file)" \ | ||
--data-binary @"$file" \ | ||
"${{ steps.create_release.outputs.upload_url }}=$(basename $file)" | ||
fi | ||
done | ||
- name: send telegram message on push | ||
uses: appleboy/telegram-action@master | ||
with: | ||
to: ${{ secrets.TELEGRAM_TO }} | ||
token: ${{ secrets.TELEGRAM_TOKEN }} | ||
document: ./temp.txt |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: build-docker | ||
|
||
on: | ||
repository_dispatch: | ||
types: [mrui-release] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v3 | ||
- | ||
name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
- | ||
name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- | ||
name: Login to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
- | ||
name: Build and push | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
platforms: linux/amd64,linux/386,linux/arm64 | ||
push: true | ||
tags: thun888/mirouter-ui:latest |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
FROM golang:1.21.0-alpine3.18 AS builder | ||
|
||
WORKDIR /app | ||
|
||
COPY . . | ||
|
||
RUN go mod download | ||
|
||
RUN go build -o main . | ||
|
||
FROM alpine:3.18 | ||
|
||
WORKDIR /app | ||
|
||
COPY --from=builder /app/main /app/main | ||
|
||
EXPOSE 6789 | ||
|
||
CMD ["./main","--config=/app/data/config.json","--basedirectory=/app/data/"] |
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,60 @@ | ||
read -p "版本号: " VERSION | ||
if [ -z "$1" ] | ||
then | ||
read -p "版本号: " VERSION | ||
else | ||
VERSION=$1 | ||
fi | ||
echo "版本号是:$VERSION" | ||
echo "Building MirouterUI $VERSION..." | ||
echo "Deleting old build..." | ||
rm mirouterui_win_amd64.exe | ||
rm mirouterui_win_386.exe | ||
rm mirouterui_win_arm64.exe | ||
rm mirouterui_linux_amd64 | ||
rm mirouterui_linux_arm64 | ||
rm mirouterui_linux_mipsle | ||
rm mirouterui_linux_mips | ||
rm mirouterui_linux_armv5 | ||
rm mirouterui_linux_armv6 | ||
rm mirouterui_linux_armv7 | ||
rm mirouterui_darwin_amd64 | ||
rm mirouterui_darwin_arm64 | ||
OUTPUT_DIR="./build" | ||
echo "编译生成目录:$OUTPUT_DIR" | ||
mkdir -p $OUTPUT_DIR | ||
|
||
echo "Building win_amd64" | ||
GOOS=windows GOARCH=amd64 go build main.go | ||
mv main.exe mirouterui_win_amd64_noupx_$VERSION.exe | ||
upx --best -o mirouterui_win_amd64_$VERSION.exe mirouterui_win_amd64_noupx_$VERSION.exe | ||
GOOS=windows GOARCH=amd64 go build -o $OUTPUT_DIR/mirouterui_win_amd64_noupx_$VERSION.exe main.go | ||
upx --best -o $OUTPUT_DIR/mirouterui_win_amd64_$VERSION.exe $OUTPUT_DIR/mirouterui_win_amd64_noupx_$VERSION.exe | ||
|
||
echo "Building win_386" | ||
GOOS=windows GOARCH=386 go build main.go | ||
mv main.exe mirouterui_win_386_noupx_$VERSION.exe | ||
upx --best -o mirouterui_win_386_$VERSION.exe mirouterui_win_386_noupx_$VERSION.exe | ||
GOOS=windows GOARCH=386 go build -o $OUTPUT_DIR/mirouterui_win_386_noupx_$VERSION.exe main.go | ||
upx --best -o $OUTPUT_DIR/mirouterui_win_386_$VERSION.exe $OUTPUT_DIR/mirouterui_win_386_noupx_$VERSION.exe | ||
|
||
echo "Building win_arm64" | ||
GOOS=windows GOARCH=arm64 go build main.go | ||
mv main.exe mirouterui_win_arm64_noupx_$VERSION.exe | ||
GOOS=windows GOARCH=arm64 go build -o $OUTPUT_DIR/mirouterui_win_arm64_noupx_$VERSION.exe main.go | ||
# rm main.exe | ||
|
||
echo "Building linux_amd64" | ||
GOOS=linux GOARCH=amd64 go build main.go | ||
mv main mirouterui_linux_amd64_noupx_$VERSION | ||
upx --best -o mirouterui_linux_amd64_$VERSION mirouterui_linux_amd64_noupx_$VERSION | ||
GOOS=linux GOARCH=amd64 go build -o $OUTPUT_DIR/mirouterui_linux_amd64_noupx_$VERSION main.go | ||
upx --best -o $OUTPUT_DIR/mirouterui_linux_amd64_$VERSION $OUTPUT_DIR/mirouterui_linux_amd64_noupx_$VERSION | ||
|
||
echo "Building linux_arm64" | ||
GOOS=linux GOARCH=arm64 go build main.go | ||
mv main mirouterui_linux_arm64_noupx_$VERSION | ||
upx --best -o mirouterui_linux_arm64_$VERSION mirouterui_linux_arm64_noupx_$VERSION | ||
GOOS=linux GOARCH=arm64 go build -o $OUTPUT_DIR/mirouterui_linux_arm64_noupx_$VERSION main.go | ||
upx --best -o $OUTPUT_DIR/mirouterui_linux_arm64_$VERSION $OUTPUT_DIR/mirouterui_linux_arm64_noupx_$VERSION | ||
|
||
echo "Building linux_mipsle" | ||
GOOS=linux GOARCH=mipsle GOMIPS=softfloat go build main.go | ||
mv main mirouterui_linux_mipsle_noupx_$VERSION | ||
upx --best -o mirouterui_linux_mipsle_$VERSION mirouterui_linux_mipsle_noupx_$VERSION | ||
GOOS=linux GOARCH=mipsle GOMIPS=softfloat go build -o $OUTPUT_DIR/mirouterui_linux_mipsle_noupx_$VERSION main.go | ||
upx --best -o $OUTPUT_DIR/mirouterui_linux_mipsle_$VERSION $OUTPUT_DIR/mirouterui_linux_mipsle_noupx_$VERSION | ||
|
||
echo "Building linux_mips" | ||
GOOS=linux GOARCH=mips GOMIPS=softfloat go build main.go | ||
mv main mirouterui_linux_mips_noupx_$VERSION | ||
upx --best -o mirouterui_linux_mips_$VERSION mirouterui_linux_mips_noupx_$VERSION | ||
GOOS=linux GOARCH=mips GOMIPS=softfloat go build -o $OUTPUT_DIR/mirouterui_linux_mips_noupx_$VERSION main.go | ||
upx --best -o $OUTPUT_DIR/mirouterui_linux_mips_$VERSION $OUTPUT_DIR/mirouterui_linux_mips_noupx_$VERSION | ||
|
||
echo "Building linux_armv5" | ||
GOOS=linux GOARCH=arm GOARM=5 GOMIPS=softfloat go build main.go | ||
mv main mirouterui_linux_armv5_noupx_$VERSION | ||
upx --best -o mirouterui_linux_armv5_$VERSION mirouterui_linux_armv5_noupx_$VERSION | ||
echo "Building linux_s390x" | ||
GOOS=linux GOARCH=s390x go build -o $OUTPUT_DIR/mirouterui_linux_s390x_noupx_$VERSION main.go | ||
# upx --best -o $OUTPUT_DIR/mirouterui_linux_s390x_$VERSION $OUTPUT_DIR/mirouterui_linux_s390x_noupx_$VERSION | ||
|
||
echo "Building linux_armv6" | ||
GOOS=linux GOARCH=arm GOARM=6 GOMIPS=softfloat go build main.go | ||
mv main mirouterui_linux_armv6_noupx_$VERSION | ||
upx --best -o mirouterui_linux_armv6_$VERSION mirouterui_linux_armv6_noupx_$VERSION | ||
|
||
echo "Building linux_armv7" | ||
GOOS=linux GOARCH=arm GOARM=7 GOMIPS=softfloat go build main.go | ||
mv main mirouterui_linux_armv7_noupx_$VERSION | ||
upx --best -o mirouterui_linux_armv7_$VERSION mirouterui_linux_armv7_noupx_$VERSION | ||
for version in 5 6 7 | ||
do | ||
echo "Building linux_armv$version" | ||
GOOS=linux GOARCH=arm GOARM=$version GOMIPS=softfloat go build -o $OUTPUT_DIR/mirouterui_linux_armv${version}_noupx_$VERSION main.go | ||
upx --best -o $OUTPUT_DIR/mirouterui_linux_armv${version}_$VERSION $OUTPUT_DIR/mirouterui_linux_armv${version}_noupx_$VERSION | ||
done | ||
|
||
# Building darwin_amd64 | ||
echo "Building darwin_amd64" | ||
GOOS=darwin GOARCH=amd64 go build main.go | ||
mv main mirouterui_darwin_amd64_noupx_$VERSION | ||
upx --best -o mirouterui_darwin_amd64_$VERSION mirouterui_darwin_amd64_noupx_$VERSION | ||
GOOS=darwin GOARCH=amd64 go build -o $OUTPUT_DIR/mirouterui_darwin_amd64_noupx_$VERSION main.go | ||
upx --best -o $OUTPUT_DIR/mirouterui_darwin_amd64_$VERSION $OUTPUT_DIR/mirouterui_darwin_amd64_noupx_$VERSION | ||
|
||
# Building darwin_arm64 | ||
echo "Building darwin_arm64" | ||
GOOS=darwin GOARCH=arm64 go build main.go | ||
mv main mirouterui_darwin_arm64_noupx_$VERSION | ||
upx --best -o mirouterui_darwin_arm64_$VERSION mirouterui_darwin_arm64_noupx_$VERSION | ||
# rm main | ||
|
||
GOOS=darwin GOARCH=arm64 go build -o $OUTPUT_DIR/mirouterui_darwin_arm64_noupx_$VERSION main.go | ||
upx --best -o $OUTPUT_DIR/mirouterui_darwin_arm64_$VERSION $OUTPUT_DIR/mirouterui_darwin_arm64_noupx_$VERSION |
Oops, something went wrong.