feat(dns): prepare backtrace v0.0.21
CI / test (push) Waiting to run
Sync ASN metadata / sync (push) Has been cancelled

This commit is contained in:
spiritlhl committed 2026-08-26 15:37:44 +08:00
1 parent e83eb23302
commit 16e551b631
15 files changed
+461 -373

No files matched your search

-3
View File
@@ -9,9 +9,6 @@ concurrency:
group: backtrace-ipv6-prefix-sync
cancel-in-progress: false
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
permissions:
contents: write
+20 -44
View File
@@ -1,58 +1,34 @@
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
permissions:
contents: read
concurrency:
group: backtrace-ci-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
strategy:
matrix:
go: ['stable']
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Setup Go
uses: actions/setup-go@v7
- uses: actions/checkout@v7
- uses: actions/setup-go@v7
with:
go-version-file: go.mod
check-latest: true
- name: Test
- name: Verify module and test source
shell: bash
run: |
# Run all tests without generating a combined coverage profile
set -euo pipefail
go test ./...
- name: Create Tag
if: success()
run: |
git config --global user.name 'github-actions'
git config --global user.email 'github-actions@github.com'
TAG="v0.0.11-$(date +'%Y%m%d%H%M%S')"
git tag $TAG
git push origin $TAG
echo "TAG=$TAG" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update README.md
if: success()
run: |
sed -i "s|go get github.com/oneclickvirt/backtrace@.*|go get github.com/oneclickvirt/backtrace@${TAG}|" README.md
env:
TAG: ${{ env.TAG }}
- name: Commit and Push README.md
if: success()
run: |
git add README.md
git commit -m "Update README.md with new tag ${TAG}"
git push origin main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
go mod verify
go test -race -count=1 ./...
go vet ./...
go build -o "$RUNNER_TEMP/backtrace" ./cmd
git diff --check
+116 -127
View File
@@ -1,139 +1,128 @@
name: Build and Release
on:
# push:
# branches: [ main ]
# pull_request:
# branches: [ main ]
# release:
# types: [published]
push:
tags: ["v*"]
workflow_dispatch:
inputs:
release_tag:
description: Existing semantic version tag to build and release
required: true
type: string
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
permissions:
contents: write
jobs:
verify:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.release.outputs.tag }}
steps:
- uses: actions/checkout@v7
with:
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.release_tag || github.ref }}
fetch-depth: 0
fetch-tags: true
- id: release
name: Verify release tag and source version
shell: bash
run: |
set -euo pipefail
if [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]]; then
tag="${{ inputs.release_tag }}"
else
tag="${GITHUB_REF#refs/tags/}"
fi
[[ "$tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]
git fetch --force --tags origin
[[ "$(git rev-list -n 1 "$tag")" == "$(git rev-parse HEAD)" ]]
version="$(sed -n 's/^const BackTraceVersion = "\(v[0-9.]*\)"$/\1/p' model/model.go)"
[[ "$version" == "$tag" ]]
echo "tag=$tag" >> "$GITHUB_OUTPUT"
- uses: actions/setup-go@v7
with:
go-version-file: go.mod
check-latest: true
- name: Validate release source
shell: bash
run: |
set -euo pipefail
go mod verify
go test -race -count=1 ./...
go vet ./...
go build -o "$RUNNER_TEMP/backtrace" ./cmd
release:
needs: verify
runs-on: ubuntu-latest
steps:
- name: Create GitHub release
env:
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: ${{ needs.verify.outputs.tag }}
shell: bash
run: |
set -euo pipefail
gh release view "$RELEASE_TAG" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1 || \
gh release create "$RELEASE_TAG" --repo "$GITHUB_REPOSITORY" --verify-tag \
--title "$RELEASE_TAG" --generate-notes
build:
name: Build and Test
needs: [verify, release]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Set up Go
uses: actions/setup-go@v7
with:
go-version-file: go.mod
check-latest: true
- name: Build and Test on Default Platform
run: |
go build -v ./...
go test -v ./...
- name: Delete Existing Release Assets
run: |
release_id=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/oneclickvirt/backtrace/releases/tags/output" | jq -r '.id')
echo "Deleting existing release assets..."
assets=$(curl -s -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/oneclickvirt/backtrace/releases/$release_id/assets" | jq -r '.[] | .id')
for asset in $assets; do
echo "Deleting asset with ID: $asset"
curl -X DELETE -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/oneclickvirt/backtrace/releases/assets/$asset"
done
sleep 30
release-binary:
name: Release Go Binary
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Set up Go
uses: actions/setup-go@v7
with:
go-version-file: go.mod
check-latest: true
- name: Build and Release
run: |
mkdir -p bin
cd cmd
CGO_ENABLED=0 GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} GOARM=${{ matrix.goarm }} go build \
-o ../bin/backtrace-${{ matrix.goos }}-${{ matrix.goarch }} \
-v \
-ldflags="-extldflags=-static -s -w" \
-trimpath \
.
- name: Upload New Assets
run: |
release_id=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/oneclickvirt/backtrace/releases/tags/output" | jq -r '.id')
echo "Uploading new assets to release..."
for file in ./bin/*; do
echo "Uploading $file to release..."
curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/octet-stream" \
--data-binary @"$file" \
"https://uploads.github.com/repos/oneclickvirt/backtrace/releases/$release_id/assets?name=$(basename "$file")"
rm -rf $file
done
strategy:
fail-fast: false
matrix:
goos: [windows, freebsd, openbsd, linux, darwin]
goarch: [amd64, 386]
exclude:
- goarch: 386
goos: darwin
include:
- goos: windows
goarch: 386
- goos: windows
goarch: amd64
- goos: windows
goarch: arm64
- goos: darwin
goarch: arm64
- goos: linux
goarch: arm
goarm: 7
- goos: linux
goarch: arm64
- goos: linux
goarch: riscv64
- goos: linux
goarch: mips64
- goos: linux
goarch: mips64le
- goos: linux
goarch: mipsle
- goos: linux
goarch: mips
- goos: linux
goarch: ppc64
- goos: linux
goarch: ppc64le
- goos: freebsd
goarch: arm64
- goos: freebsd
goarch: arm
goarm: 7
- goos: openbsd
goarch: arm64
- goos: openbsd
goarch: arm
goarm: 7
# - goos: linux
# goarch: mipsle
# gomips: softfloat
# - goos: linux
# goarch: mips
# gomips: softfloat
# - goos: linux
# goarch: arm
# goarm: 6
# - goos: linux
# goarch: arm
# goarm: 5
- {goos: linux, goarch: amd64}
- {goos: linux, goarch: "386"}
- {goos: linux, goarch: arm, goarm: "7"}
- {goos: linux, goarch: arm64}
- {goos: linux, goarch: riscv64}
- {goos: linux, goarch: mips}
- {goos: linux, goarch: mipsle}
- {goos: linux, goarch: mips64}
- {goos: linux, goarch: mips64le}
- {goos: linux, goarch: ppc64}
- {goos: linux, goarch: ppc64le}
- {goos: freebsd, goarch: amd64}
- {goos: freebsd, goarch: "386"}
- {goos: freebsd, goarch: arm, goarm: "7"}
- {goos: freebsd, goarch: arm64}
- {goos: openbsd, goarch: amd64}
- {goos: openbsd, goarch: "386"}
- {goos: openbsd, goarch: arm, goarm: "7"}
- {goos: openbsd, goarch: arm64}
- {goos: darwin, goarch: amd64}
- {goos: darwin, goarch: arm64}
- {goos: windows, goarch: "386"}
- {goos: windows, goarch: amd64}
- {goos: windows, goarch: arm64}
steps:
- uses: actions/checkout@v7
with:
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.release_tag || github.ref }}
- uses: actions/setup-go@v7
with:
go-version-file: go.mod
check-latest: true
- name: Build binary
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
GOARM: ${{ matrix.goarm }}
CGO_ENABLED: "0"
shell: bash
run: |
set -euo pipefail
suffix=""
[[ "$GOOS" == "windows" ]] && suffix=".exe"
artifact="backtrace-${GOOS}-${GOARCH}${suffix}"
go build -trimpath -buildvcs=false -ldflags="-s -w" -o "$artifact" ./cmd
echo "ARTIFACT=$artifact" >> "$GITHUB_ENV"
- name: Upload release asset
env:
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: ${{ needs.verify.outputs.tag }}
run: gh release upload "$RELEASE_TAG" "$ARTIFACT" --repo "$GITHUB_REPOSITORY" --clobber
+78
View File
@@ -0,0 +1,78 @@
name: Prepare and Tag Release
on:
workflow_dispatch:
inputs:
release_tag:
description: Semantic version tag; leave empty to use BackTraceVersion
required: false
type: string
permissions:
contents: write
concurrency:
group: backtrace-release-data
cancel-in-progress: false
jobs:
prepare:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
ref: main
fetch-depth: 0
fetch-tags: true
- uses: actions/setup-go@v7
with:
go-version-file: go.mod
check-latest: true
- id: release
name: Resolve release tag
shell: bash
run: |
set -euo pipefail
version="$(sed -n 's/^const BackTraceVersion = "\(v[0-9.]*\)"$/\1/p' model/model.go)"
tag="${{ inputs.release_tag }}"
[[ -n "$tag" ]] || tag="$version"
[[ "$tag" == "$version" ]]
[[ "$tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]
git fetch --force --tags origin
! git rev-parse --verify --quiet "refs/tags/$tag"
echo "tag=$tag" >> "$GITHUB_OUTPUT"
- name: Refresh embedded routing datasets
shell: bash
run: |
set -euo pipefail
go run ./cmd/update-prefixes -output-dir bk/prefix
go run ./cmd/update-asn-metadata
- name: Validate release source
shell: bash
run: |
set -euo pipefail
go mod verify
go test -race -count=1 ./...
go vet ./...
go build -o "$RUNNER_TEMP/backtrace" ./cmd
git diff --check
- name: Commit refreshed routing datasets
shell: bash
run: |
set -euo pipefail
if [[ -z "$(git status --porcelain -- bk/prefix bgptools/data)" ]]; then
exit 0
fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add bk/prefix bgptools/data
git commit -m "chore(data): refresh routing datasets"
git push origin HEAD:main
- name: Create immutable release tag
env:
RELEASE_TAG: ${{ steps.release.outputs.tag }}
shell: bash
run: |
set -euo pipefail
git tag -a "$RELEASE_TAG" -m "Release $RELEASE_TAG"
git push origin "refs/tags/$RELEASE_TAG"