build sing-box server for linux #398
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 sing-box server for linux | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 0 * * *" | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
permissions: | |
contents: write | |
jobs: | |
build: | |
name: Debug build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Cancel previous | |
uses: styfle/[email protected] | |
with: | |
access_token: ${{ github.token }} | |
- name: Set variables | |
run: | | |
echo "RELEASE_NAME=Released on $(date +%Y%m%d%H%M)" >> $GITHUB_ENV | |
echo "TAG_NAME=$(date +%Y%m%d%H%M)" >> $GITHUB_ENV | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
repository: SagerNet/sing-box | |
ref: dev-next | |
- name: Setup Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ^1.22 | |
build_go120: | |
name: Debug build (Go 1.22) | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
repository: SagerNet/sing-box | |
ref: dev-next | |
- name: Setup Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ^1.22 | |
cross: | |
strategy: | |
matrix: | |
include: | |
# linux | |
- name: linux-amd64 | |
goos: linux | |
goarch: amd64 | |
goamd64: v1 | |
- name: linux-amd64-v3 | |
goos: linux | |
goarch: amd64 | |
goamd64: v3 | |
- name: linux-arm64 | |
goos: linux | |
goarch: arm64 | |
fail-fast: false | |
runs-on: ubuntu-latest | |
env: | |
GOOS: ${{ matrix.goos }} | |
GOARCH: ${{ matrix.goarch }} | |
GOAMD64: ${{ matrix.goamd64 }} | |
GOARM: ${{ matrix.goarm }} | |
GOMIPS: ${{ matrix.gomips }} | |
CGO_ENABLED: 1 | |
TAGS: osusergo,netgo,with_gvisor,with_quic,with_wireguard,with_reality_server,with_ech,with_utls | |
steps: | |
- name: Set variables | |
run: | | |
echo "RELEASE_NAME=Released on $(date +%Y%m%d%H)" >> $GITHUB_ENV | |
echo "TAG_NAME=$(date +%Y%m%d%H)" >> $GITHUB_ENV | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
repository: SagerNet/sing-box | |
ref: dev-next | |
- name: Setup Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ^1.22 | |
- name: Build | |
id: build | |
run: make | |
- name: Test | |
run: | | |
echo ${{ contains(matrix.name, 'windows') }} | |
echo ${{ matrix.name }} | |
- name: Rename Windows | |
if: ${{ contains(matrix.name, 'windows') }} | |
run: mv sing-box* sing-box-${{ matrix.name }}.exe | |
- name: Rename | |
if: ${{ contains(matrix.name, 'linux') || contains(matrix.name, 'bsd') || contains(matrix.name, 'darwin') || contains(matrix.name, 'android') }} | |
run: mv sing-box* sing-box-${{ matrix.name }} | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: sing-box-${{ matrix.name }} | |
path: sing-box* | |
- name: Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: ${{ env.TAG_NAME }} | |
name: ${{ env.RELEASE_NAME }} | |
files: | | |
sing-box* |