添加自动化构建配置
This commit is contained in:
98
.gitea/workflows/autobuild.yml
Normal file
98
.gitea/workflows/autobuild.yml
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
name: Auto Build
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- stable
|
||||||
|
- testing
|
||||||
|
- unstable
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
version:
|
||||||
|
description: Override embedded version
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
targets:
|
||||||
|
description: Space separated build targets, for example "linux-amd64 windows-amd64"
|
||||||
|
required: false
|
||||||
|
default: all
|
||||||
|
type: string
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Build binaries
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Setup Go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: ~1.25.9
|
||||||
|
|
||||||
|
- name: Resolve build metadata
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
version_input="${{ inputs.version }}"
|
||||||
|
targets_input="${{ inputs.targets }}"
|
||||||
|
|
||||||
|
if [[ -n "$version_input" ]]; then
|
||||||
|
version="$version_input"
|
||||||
|
else
|
||||||
|
version="$(go run ./cmd/internal/read_tag)"
|
||||||
|
if [[ -z "$version" || "$version" == "unknown" ]]; then
|
||||||
|
version="$(git describe --tags --always 2>/dev/null || git rev-parse --short HEAD)"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z "$targets_input" ]]; then
|
||||||
|
targets_input="all"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "VERSION=$version" >> "$GITHUB_ENV"
|
||||||
|
echo "BUILD_TARGETS=$targets_input" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
chmod +x ./building-linux.sh
|
||||||
|
rm -rf dist artifacts
|
||||||
|
mkdir -p dist artifacts
|
||||||
|
|
||||||
|
VERSION="$VERSION" DIST_DIR="$PWD/dist" ./building-linux.sh ${BUILD_TARGETS}
|
||||||
|
|
||||||
|
- name: Package artifacts
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
shopt -s nullglob
|
||||||
|
|
||||||
|
for file in dist/*; do
|
||||||
|
name="$(basename "$file")"
|
||||||
|
if [[ "$name" == *.exe ]]; then
|
||||||
|
archive="artifacts/${name%.exe}-${VERSION}.zip"
|
||||||
|
zip -j "$archive" "$file"
|
||||||
|
else
|
||||||
|
archive="artifacts/${name}-${VERSION}.tar.gz"
|
||||||
|
tar -C dist -czf "$archive" "$name"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
(
|
||||||
|
cd artifacts
|
||||||
|
sha256sum * > SHA256SUMS.txt
|
||||||
|
)
|
||||||
|
|
||||||
|
- name: Upload artifacts
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: sing-box-${{ env.VERSION }}
|
||||||
|
path: artifacts
|
||||||
|
if-no-files-found: error
|
||||||
Reference in New Issue
Block a user