mirror of
https://github.com/oneclickvirt/backtrace.git
synced 2026-11-24 23:39:41 +08:00
ci: preserve verified artifacts and recover network operations
This commit is contained in:
1 parent
90693fbf25
commit
2258999848
7 files changed
+429
-277
No files matched your search
@@ -1,78 +1,76 @@
|
||||
name: Prepare and Tag Release
|
||||
|
||||
on:
|
||||
permissions:
|
||||
contents: write
|
||||
concurrency:
|
||||
group: backtrace-release-data
|
||||
cancel-in-progress: false
|
||||
jobs:
|
||||
prepare:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
ref: main
|
||||
fetch-depth: 0
|
||||
fetch-tags: true
|
||||
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
|
||||
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"
|
||||
env:
|
||||
GOPROXY: https://proxy.golang.org|direct
|
||||
'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@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
ref: main
|
||||
fetch-depth: 0
|
||||
fetch-tags: true
|
||||
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
|
||||
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"
|
||||
Reference in new issue
Block a user