feat: add total bandwidth limit support #10
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
name: Build && Prerelease | |
on: | |
push: | |
jobs: | |
common: | |
runs-on: ubuntu-latest | |
outputs: | |
go-version: ${{ steps.go.outputs.version }} | |
commit-hash: ${{ steps.common.outputs.hash }} | |
commit-message: ${{ steps.common.outputs.message }} | |
steps: | |
- name: get latest go version | |
id: go | |
run: | | |
echo version=$(curl -s https://raw.githubusercontent.com/actions/go-versions/update-versions-manifest-file/versions-manifest.json | grep -oE '"version": "[0-9]{1}.[0-9]{1,}(.[0-9]{1,})?"' | head -1 | cut -d':' -f2 | sed 's/ //g; s/"//g') >> $GITHUB_OUTPUT | |
- uses: actions/[email protected] | |
with: | |
fetch-depth: 0 | |
- name: get short commit id | |
id: common | |
run: | | |
echo hash=$(git rev-parse --short HEAD) >> $GITHUB_OUTPUT | |
echo message=$(git log --pretty=format:%s HEAD -1) >> $GITHUB_OUTPUT | |
build: | |
runs-on: ubuntu-latest | |
needs: | |
- common | |
strategy: | |
matrix: | |
jobs: | |
# android | |
- { goos: android, goarch: 386, goarm: 7, ndk: i686-linux-android34, output: 386 } | |
- { goos: android, goarch: arm, goarm: 7, ndk: armv7a-linux-androideabi34, output: armeabi-v7a } | |
- { goos: android, goarch: arm64, goarm: 7, ndk: aarch64-linux-android34, output: arm64-v8a } | |
- { goos: android, goarch: amd64, goarm: 7, ndk: x86_64-linux-android34, output: amd64 } | |
# darwin | |
- { goos: darwin, goarch: arm64, output: arm64 } | |
- { goos: darwin, goarch: amd64, goamd64: v1, output: amd64 } | |
- { goos: darwin, goarch: amd64, goamd64: v3, output: amd64v3 } | |
# linux | |
- { goos: linux, goarch: 386, output: 386 } | |
- { goos: linux, goarch: s390x, output: s390x } | |
- { goos: linux, goarch: riscv64, output: riscv64 } | |
- { goos: linux, goarch: arm64, output: arm64 } | |
- { goos: linux, goarch: loong64, abi: 1, output: loong64-abi1 } | |
- { goos: linux, goarch: loong64, abi: 2, output: loong64-abi2 } | |
- { goos: linux, goarch: arm, goarm: 5, output: armv5 } | |
- { goos: linux, goarch: arm, goarm: 6, output: armv6 } | |
- { goos: linux, goarch: arm, goarm: 7, output: armv7 } | |
- { goos: linux, goarch: amd64, goamd64: v1, output: amd64 } | |
- { goos: linux, goarch: amd64, goamd64: v3, output: amd64v3 } | |
- { goos: linux, goarch: mips, output: mips } | |
- { goos: linux, goarch: mips, gomips: softfloat, output: mips-softfloat } | |
- { goos: linux, goarch: mips, gomips: hardfloat, output: mips-hardfloat } | |
- { goos: linux, goarch: mipsle, output: mipsle } | |
- { goos: linux, goarch: mips64, output: mips64 } | |
- { goos: linux, goarch: mips64, gomips: softfloat, output: mips64-softfloat } | |
- { goos: linux, goarch: mips64, gomips: hardfloat, output: mips64-hardfloat } | |
- { goos: linux, goarch: mips64le, output: mips64le } | |
# windows | |
- { goos: windows, goarch: 386, output: 386 } | |
- { goos: windows, goarch: arm64, output: arm64 } | |
- { goos: windows, goarch: arm, goarm: 7, output: arm32v7 } | |
- { goos: windows, goarch: amd64, goamd64: v1, output: amd64 } | |
- { goos: windows, goarch: amd64, goamd64: v3, output: amd64v3 } | |
# freebsd | |
- { goos: freebsd, goarch: arm64, output: arm64 } | |
- { goos: freebsd, goarch: amd64, goamd64: v1, output: amd64 } | |
- { goos: freebsd, goarch: amd64, goamd64: v3, output: amd64v3 } | |
env: | |
GOOS: ${{ matrix.jobs.goos }} | |
GOARM: ${{ matrix.jobs.goarm }} | |
GOARCH: ${{ matrix.jobs.goarch }} | |
GOAMD64: ${{ matrix.jobs.goamd64 }} | |
GOMIPS: ${{ matrix.jobs.gomips }} | |
CGO_ENABLED: ${{ matrix.jobs.goos == 'android' && 1 || 0 }} | |
VERSION: ${{ needs.common.outputs.commit-hash }} | |
SUFFIX: ${{ matrix.jobs.goos == 'windows' && '.exe' || '' }} | |
steps: | |
- uses: actions/[email protected] | |
with: | |
fetch-depth: 0 | |
- name: get short commit id | |
id: version | |
run: | | |
echo VERSION=$(git rev-parse --short HEAD) >> $GITHUB_ENV | |
echo message=$(git log --pretty=format:%s HEAD -1) >> $GITHUB_OUTPUT | |
- name: set up go1.23 loongarch abi1 | |
if: ${{ matrix.jobs.goarch == 'loong64' && matrix.jobs.abi == '1' }} | |
run: | | |
wget -q https://github.com/MetaCubeX/loongarch64-golang/releases/download/1.22.4/go1.22.4.linux-amd64-abi${{ matrix.jobs.abi }}.tar.gz -O linux-amd64.tar.gz | |
sudo tar zxf linux-amd64.tar.gz -C /usr/local | |
echo "/usr/local/go/bin" >> $GITHUB_PATH | |
- name: setup go | |
uses: actions/[email protected] | |
if: ${{ matrix.jobs.goarch != 'loong64' || matrix.jobs.abi != '1' }} | |
with: | |
go-version: ${{ needs.common.outputs.go-version }} | |
# modify from https://github.com/restic/restic/issues/4636#issuecomment-1896455557 | |
# this patch file only works on golang1.23.x | |
# that means after golang1.24 release it must be changed | |
# see: https://github.com/MetaCubeX/go/commits/release-branch.go1.23/ | |
# revert: | |
# 693def151adff1af707d82d28f55dba81ceb08e1: "crypto/rand,runtime: switch RtlGenRandom for ProcessPrng" | |
# 7c1157f9544922e96945196b47b95664b1e39108: "net: remove sysSocket fallback for Windows 7" | |
# 48042aa09c2f878c4faa576948b07fe625c4707a: "syscall: remove Windows 7 console handle workaround" | |
# a17d959debdb04cd550016a3501dd09d50cd62e7: "runtime: always use LoadLibraryEx to load system libraries" | |
- name: revert golang1.23 commit for windows7/8 | |
if: ${{ matrix.jobs.goos == 'windows' }} | |
run: | | |
cd $(go env GOROOT) | |
curl https://github.com/MetaCubeX/go/commit/9ac42137ef6730e8b7daca016ece831297a1d75b.diff | patch --verbose -p 1 | |
curl https://github.com/MetaCubeX/go/commit/21290de8a4c91408de7c2b5b68757b1e90af49dd.diff | patch --verbose -p 1 | |
curl https://github.com/MetaCubeX/go/commit/6a31d3fa8e47ddabc10bd97bff10d9a85f4cfb76.diff | patch --verbose -p 1 | |
curl https://github.com/MetaCubeX/go/commit/69e2eed6dd0f6d815ebf15797761c13f31213dd6.diff | patch --verbose -p 1 | |
- name: Setup NDK | |
if: ${{ matrix.jobs.goos == 'android' }} | |
uses: nttld/setup-ndk@v1 | |
id: setup-ndk | |
with: | |
ndk-version: r27 | |
- name: Setup CC ENV | |
if: ${{ matrix.jobs.goos == 'android' }} | |
run: echo "CC=${{ steps.setup-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/bin/${{ matrix.jobs.ndk }}-clang" >> $GITHUB_ENV | |
- name: build | |
run: go build -o git-proxy-${{ env.GOOS }}-${{ matrix.jobs.output }}${{ env.SUFFIX }} -v -trimpath -ldflags "-s -w -buildid=" main.go | |
- name: upload | |
uses: actions/[email protected] | |
with: | |
name: git-proxy-${{ env.VERSION }}-${{ env.GOOS }}-${{ matrix.jobs.output }} | |
path: git-proxy-${{ env.GOOS }}-${{ matrix.jobs.output }}${{ env.SUFFIX }} | |
compression-level: 9 | |
upload-release: | |
permissions: write-all | |
needs: | |
- common | |
- build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download all workflow run artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: bin/ | |
merge-multiple: true | |
- name: Delete current release assets | |
uses: 8Mi-Tech/delete-release-assets-action@main | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
tag: Prerelease | |
deleteOnlyFromDrafts: false | |
- name: Tag Repo | |
uses: richardsimko/update-tag@v1 | |
with: | |
tag_name: Prerelease | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- run: | | |
cat > release.txt << 'EOF' | |
${{ needs.common.outputs.commit-hash }} ${{ needs.common.outputs.commit-message }} | |
EOF | |
- name: Upload Prerelease | |
uses: softprops/action-gh-release@v1 | |
if: ${{ success() }} | |
with: | |
tag_name: Prerelease | |
files: | | |
bin/* | |
prerelease: true | |
generate_release_notes: true | |
body_path: release.txt |