diff --git a/.github/workflows/build_binary.yaml b/.github/workflows/build_binary.yaml index 54a7201..5990cdd 100644 --- a/.github/workflows/build_binary.yaml +++ b/.github/workflows/build_binary.yaml @@ -32,11 +32,42 @@ jobs: GITHUB_TOKEN: ${{ secrets.GHT }} - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v2 + uses: goreleaser/goreleaser-action@v6 with: distribution: goreleaser version: latest args: release env: GITHUB_TOKEN: ${{ secrets.GHT }} - GOPRIVATE: github.com/oneclickvirt/security \ No newline at end of file + 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 }} \ No newline at end of file