mirror of
https://github.com/bolucat/Archive.git
synced 2025-12-24 13:28:37 +08:00
Update On Wed Sep 11 20:35:31 CEST 2024
This commit is contained in:
50
echo/.github/workflows/nightly.yaml
vendored
50
echo/.github/workflows/nightly.yaml
vendored
@@ -20,38 +20,42 @@ jobs:
|
||||
git config user.name "GitHub Actions"
|
||||
git config user.email "actions@github.com"
|
||||
|
||||
- name: Update 'v0.0.0-nightly' tag
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Get latest version and create nightly tag
|
||||
id: get_version
|
||||
run: |
|
||||
# 删除本地和远程的 'v0.0.0-nightly' 标签(如果存在)
|
||||
git tag -d v0.0.0-nightly || true
|
||||
git push origin :refs/tags/v0.0.0-nightly || true
|
||||
# 创建新的 'v0.0.0-nightly' 标签并推送
|
||||
git tag v0.0.0-nightly
|
||||
git push origin refs/tags/v0.0.0-nightly
|
||||
# 获取最新的非 nightly 版本标签
|
||||
latest_version=$(git describe --tags --abbrev=0 --exclude="*-next")
|
||||
|
||||
- name: Delete previous nightly release
|
||||
# 增加补丁版本号
|
||||
nightly_version=$(echo $latest_version | awk -F. '{$NF = $NF + 1;} 1' | sed 's/ /./g')
|
||||
|
||||
# 创建 nightly 标签
|
||||
nightly_tag="${nightly_version}-next"
|
||||
echo "NIGHTLY_TAG=${nightly_tag}" >> $GITHUB_OUTPUT
|
||||
|
||||
# 删除远程的旧 nightly tag(如果存在)
|
||||
git push origin :refs/tags/*-next || true
|
||||
|
||||
# 删除本地的旧 nightly tag(如果存在)
|
||||
git tag -d $(git tag -l '*-next') || true
|
||||
|
||||
# 创建新的 nightly tag
|
||||
git tag $nightly_tag
|
||||
|
||||
# 强制推送新的 nightly tag
|
||||
git push origin $nightly_tag --force
|
||||
|
||||
- name: Delete Old GitHub Release
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
ISSUE: ${{ github.event.issue.html_url }}
|
||||
NIGHTLY_TAG: ${{ steps.get_version.outputs.NIGHTLY_TAG }}
|
||||
run: |
|
||||
if gh release view v0.0.0-nightly; then
|
||||
gh release delete v0.0.0-nightly -y
|
||||
else
|
||||
echo "Release v0.0.0-nightly not found, skipping delete."
|
||||
fi
|
||||
gh release delete $NIGHTLY_TAG --yes || true
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: "1.21"
|
||||
id: go
|
||||
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: v0.0.0-nightly
|
||||
|
||||
- name: Get dependencies
|
||||
run: go mod download
|
||||
@@ -63,3 +67,5 @@ jobs:
|
||||
args: release --clean
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }}
|
||||
GORELEASER_CURRENT_TAG: ${{ steps.get_version.outputs.NIGHTLY_TAG }}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ builds:
|
||||
- -X github.com/Ehco1996/ehco/internal/constant.GitBranch={{.Branch}}
|
||||
- -X github.com/Ehco1996/ehco/internal/constant.GitRevision={{.ShortCommit}}
|
||||
- -X github.com/Ehco1996/ehco/internal/constant.BuildTime={{.Date}}
|
||||
- -X github.com/Ehco1996/ehco/internal/constant.Version={{.Version}}
|
||||
goarch:
|
||||
- amd64
|
||||
- arm64
|
||||
|
||||
@@ -74,8 +74,8 @@ function _detect_package_manager() {
|
||||
}
|
||||
|
||||
function _install_dependencies() {
|
||||
local pkg_manager=$(_detect_package_manager)
|
||||
|
||||
local pkg_manager
|
||||
pkg_manager=$(_detect_package_manager)
|
||||
case $pkg_manager in
|
||||
apt-get)
|
||||
sudo apt-get update
|
||||
@@ -139,10 +139,18 @@ function _print_warning_msg() {
|
||||
}
|
||||
|
||||
function _set_default_version() {
|
||||
# if version is not specified, set it to latest
|
||||
if [[ -z "$VERSION" ]]; then
|
||||
_print_warning_msg "Version not specified. Using **nightly** as the default version."
|
||||
VERSION="v0.0.0-nightly"
|
||||
_print_warning_msg "Version not specified. Fetching the latest nightly version."
|
||||
local api_url="https://api.github.com/repos/Ehco1996/ehco/releases"
|
||||
local latest_nightly
|
||||
latest_nightly=$(curl "${CURL_FLAGS[@]}" "$api_url" | jq -r '.[] | select(.prerelease == true) | .tag_name' | head -n 1)
|
||||
if [[ -z "$latest_nightly" ]]; then
|
||||
_print_error_msg "Failed to fetch the latest nightly version. Using a fallback version."
|
||||
VERSION="nightly"
|
||||
else
|
||||
VERSION="$latest_nightly"
|
||||
fi
|
||||
_print_warning_msg "Using version: $VERSION"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -154,14 +162,14 @@ function _download_bin() {
|
||||
_assets_json=$(curl "${CURL_FLAGS[@]}" "$api_url")
|
||||
|
||||
# Extract the download URL for the target architecture using jq
|
||||
download_url=$(echo "$_assets_json" | jq -r --arg TARGET_ARCH "$TARGET_ARCH" '.assets[] | select(.name | contains("ehco_" + $TARGET_ARCH)) | .browser_download_url')
|
||||
download_url=$(echo "$_assets_json" | jq -r --arg TARGET_ARCH "$TARGET_ARCH" '.assets[] | select(.name | contains($TARGET_ARCH)) | .browser_download_url')
|
||||
if [ -z "$download_url" ]; then
|
||||
echo "Download URL for architecture $TARGET_ARCH not found."
|
||||
return 1
|
||||
fi
|
||||
|
||||
# replace host to `release.ehco-relay.cc` to use cf-proxy to download
|
||||
if (( "$USE_CF_PROXY" == "true" )); then
|
||||
if [ "$USE_CF_PROXY" = "true" ]; then
|
||||
download_url=$(echo "$download_url" | sed 's|https://github.com|https://release.ehco-relay.cc|')
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user