mirror of
http://bgp.hk.skcks.cn:10088/github.com/oneclickvirt/ecs
synced 2026-04-20 12:50:58 +08:00
100 lines
3.2 KiB
YAML
100 lines
3.2 KiB
YAML
name: Build and Release
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
tags:
|
|
- "v*.*.*"
|
|
|
|
jobs:
|
|
goreleaser:
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
# 1.20 是 Windows 7/8 Server 2008/2012 最后一个支持版本
|
|
image: goreleaser/goreleaser-cross:v1.20
|
|
steps:
|
|
- run: |
|
|
git config --global --add safe.directory /__w/ecs/ecs
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Free Disk Space (Ubuntu)
|
|
uses: jlumbroso/free-disk-space@main
|
|
with:
|
|
# this might remove tools that are actually needed,
|
|
# if set to "true" but frees about 6 GB
|
|
tool-cache: false
|
|
|
|
# all of these default to true, but feel free to set to
|
|
# "false" if necessary for your workflow
|
|
android: true
|
|
dotnet: true
|
|
haskell: true
|
|
large-packages: false
|
|
docker-images: false
|
|
swap-storage: false
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v4
|
|
with:
|
|
go-version: 1.25.4
|
|
|
|
# - name: Install UPX
|
|
# run: |
|
|
# apk add --no-cache upx
|
|
|
|
- name: Configure Git for Private Modules
|
|
run: |
|
|
git config --global url."https://${{ secrets.GHT }}@github.com/".insteadOf "https://github.com/"
|
|
git config --global url."git@github.com:".insteadOf "https://github.com/"
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GHT }}
|
|
|
|
- name: Clean Go cache before build
|
|
run: |
|
|
go clean -cache -modcache -testcache
|
|
df -h
|
|
|
|
- name: Run GoReleaser
|
|
uses: goreleaser/goreleaser-action@v6
|
|
with:
|
|
distribution: goreleaser
|
|
# version: latest
|
|
version: '~> v2'
|
|
args: release --clean
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GHT }}
|
|
GOPRIVATE: github.com/oneclickvirt/security,github.com/oneclickvirt/privatespeedtest
|
|
|
|
- name: Update goecs.sh with new version
|
|
run: |
|
|
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
|
|
VERSION="${GITHUB_REF#refs/tags/v}"
|
|
else
|
|
VERSION=$(git describe --tags --abbrev=0 2>/dev/null | sed 's/^v//' || echo "0.1.37")
|
|
fi
|
|
echo "Using version: $VERSION"
|
|
FILE="goecs.sh"
|
|
BRANCH="master"
|
|
git config --global user.name "github-actions[bot]"
|
|
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
|
git config --global --unset url."git@github.com:".insteadOf || true
|
|
git fetch origin $BRANCH
|
|
git checkout $BRANCH
|
|
if [ ! -f "$FILE" ]; then
|
|
echo "Error: $FILE not found"
|
|
exit 1
|
|
fi
|
|
sed -i "s/\(_yellow \"Unable to get version info, using default version \).*\(\".*\)/\1$VERSION\2/" "$FILE"
|
|
sed -i "s/\(ECS_VERSION=\"\).*\(\"\)/\1$VERSION\2/" "$FILE"
|
|
if git diff --quiet "$FILE"; then
|
|
echo "No changes detected in $FILE"
|
|
exit 0
|
|
fi
|
|
git add "$FILE"
|
|
git commit -m "chore: update ECS_VERSION to $VERSION in goecs.sh"
|
|
git push origin $BRANCH
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GHT }}
|