mirror of
https://github.com/oneclickvirt/ecs.git
synced 2025-09-26 19:31:18 +08:00
75 lines
2.4 KiB
YAML
75 lines
2.4 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: Set up Go
|
|
uses: actions/setup-go@v4
|
|
with:
|
|
go-version: 1.24.5
|
|
|
|
- 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: Run GoReleaser
|
|
uses: goreleaser/goreleaser-action@v6
|
|
with:
|
|
distribution: goreleaser
|
|
# version: latest
|
|
version: '~> v2'
|
|
args: release
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GHT }}
|
|
GOPRIVATE: github.com/oneclickvirt/security
|
|
|
|
- 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 }}
|