Update workflow

This commit is contained in:
世界 2024-01-24 12:13:12 +08:00
parent c8318058bb
commit e478d3c2dc
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
3 changed files with 18 additions and 48 deletions

View file

@ -25,22 +25,10 @@ jobs:
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Get latest go version
id: version
run: |
echo go_version=$(curl -s https://raw.githubusercontent.com/actions/go-versions/main/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
- name: Setup Go - name: Setup Go
uses: actions/setup-go@v5 uses: actions/setup-go@v5
with: with:
go-version: ${{ steps.version.outputs.go_version }} go-version: ^1.21
- name: Add cache to Go proxy
run: |
version=`git rev-parse HEAD`
mkdir build
pushd build
go mod init build
go get -v github.com/sagernet/sing-box@$version
popd
continue-on-error: true continue-on-error: true
- name: Run Test - name: Run Test
run: | run: |
@ -56,7 +44,7 @@ jobs:
- name: Setup Go - name: Setup Go
uses: actions/setup-go@v5 uses: actions/setup-go@v5
with: with:
go-version: 1.18.10 go-version: ~1.18
- name: Cache go module - name: Cache go module
uses: actions/cache@v3 uses: actions/cache@v3
with: with:
@ -76,13 +64,13 @@ jobs:
- name: Setup Go - name: Setup Go
uses: actions/setup-go@v5 uses: actions/setup-go@v5
with: with:
go-version: 1.20.7 go-version: ^1.20
- name: Cache go module - name: Cache go module
uses: actions/cache@v3 uses: actions/cache@v3
with: with:
path: | path: |
~/go/pkg/mod ~/go/pkg/mod
key: go118-${{ hashFiles('**/go.sum') }} key: go120-${{ hashFiles('**/go.sum') }}
- name: Run Test - name: Run Test
run: make ci_build run: make ci_build
cross: cross:
@ -188,8 +176,7 @@ jobs:
- name: freebsd-arm64 - name: freebsd-arm64
goos: freebsd goos: freebsd
goarch: arm64 goarch: arm64
fail-fast: true
fail-fast: false
runs-on: ubuntu-latest runs-on: ubuntu-latest
env: env:
GOOS: ${{ matrix.goos }} GOOS: ${{ matrix.goos }}
@ -204,19 +191,10 @@ jobs:
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Get latest go version
id: version
run: |
echo go_version=$(curl -s https://raw.githubusercontent.com/actions/go-versions/main/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
- name: Setup Go - name: Setup Go
uses: actions/setup-go@v5 uses: actions/setup-go@v5
with: with:
go-version: ${{ steps.version.outputs.go_version }} go-version: ^1.21
- name: Build - name: Build
id: build id: build
run: make run: make
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: sing-box-${{ matrix.name }}
path: sing-box*

View file

@ -1,9 +1,10 @@
name: Build Docker Images name: Build Docker Images
on: on:
workflow_dispatch: release:
inputs: types:
tag: - published
description: "The tag version you want to build"
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -25,15 +26,6 @@ jobs:
uses: docker/metadata-action@v5 uses: docker/metadata-action@v5
with: with:
images: ghcr.io/sagernet/sing-box images: ghcr.io/sagernet/sing-box
- name: Get tag to build
id: tag
run: |
echo "latest=ghcr.io/sagernet/sing-box:latest" >> $GITHUB_OUTPUT
if [[ -z "${{ github.event.inputs.tag }}" ]]; then
echo "versioned=ghcr.io/sagernet/sing-box:${{ github.ref_name }}" >> $GITHUB_OUTPUT
else
echo "versioned=ghcr.io/sagernet/sing-box:${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT
fi
- name: Build and release Docker images - name: Build and release Docker images
uses: docker/build-push-action@v5 uses: docker/build-push-action@v5
with: with:
@ -42,6 +34,6 @@ jobs:
build-args: | build-args: |
BUILDKIT_CONTEXT_KEEP_GIT_DIR=1 BUILDKIT_CONTEXT_KEEP_GIT_DIR=1
tags: | tags: |
${{ steps.tag.outputs.latest }} ghcr.io/sagernet/sing-box:latest
${{ steps.tag.outputs.versioned }} ghcr.io/sagernet/sing-box:${{ github.ref_name }}
push: true push: true

View file

@ -25,10 +25,10 @@ jobs:
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Get latest go version - name: Setup Go
id: version uses: actions/setup-go@v4
run: | with:
echo go_version=$(curl -s https://raw.githubusercontent.com/actions/go-versions/main/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 go-version: ^1.21
- name: Setup Go - name: Setup Go
uses: actions/setup-go@v5 uses: actions/setup-go@v5
with: with: