mirror of
https://github.com/oneclickvirt/backtrace.git
synced 2026-09-03 13:15:52 +08:00
79 lines
2.4 KiB
YAML
79 lines
2.4 KiB
YAML
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"
|