mirror of
https://github.com/hackdiaz-dev/free-turn-proxy.git
synced 2026-10-12 09:41:53 +02:00
cc71a1a938
Fixes the govulncheck findings in net/http, crypto/tls, mime/multipart and x/net
172 lines
5.4 KiB
YAML
172 lines
5.4 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*.*.*'
|
|
|
|
permissions:
|
|
contents: write
|
|
packages: write
|
|
|
|
env:
|
|
GO_VERSION: "1.26.9"
|
|
GORELEASER_VERSION: v2.17.1
|
|
GOMOBILE_VERSION: v0.0.0-20260821190718-4776eadac327
|
|
TASK_VERSION: 3.52.0
|
|
|
|
jobs:
|
|
build-ios:
|
|
name: Build iOS XCFramework
|
|
runs-on: macos-latest
|
|
steps:
|
|
- uses: actions/checkout@v6.0.2
|
|
|
|
- uses: actions/setup-go@v6.4.0
|
|
with:
|
|
go-version: ${{ env.GO_VERSION }}
|
|
cache: true
|
|
|
|
- uses: arduino/setup-task@v2.0.0
|
|
with:
|
|
version: ${{ env.TASK_VERSION }}
|
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Install gomobile
|
|
run: |
|
|
go install golang.org/x/mobile/cmd/gomobile@${{ env.GOMOBILE_VERSION }}
|
|
gomobile init
|
|
|
|
- name: Build XCFramework
|
|
run: task build:ios
|
|
|
|
- name: Zip XCFramework
|
|
run: cd dist && zip -r Mobile.xcframework.zip Mobile.xcframework
|
|
|
|
- uses: actions/upload-artifact@v7.0.1
|
|
with:
|
|
name: ios-xcframework-zip
|
|
path: dist/Mobile.xcframework.zip
|
|
retention-days: 7
|
|
|
|
build-android:
|
|
name: Build Android AAR
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v6.0.2
|
|
|
|
- uses: actions/setup-go@v6.4.0
|
|
with:
|
|
go-version: ${{ env.GO_VERSION }}
|
|
cache: true
|
|
|
|
- uses: arduino/setup-task@v2.0.0
|
|
with:
|
|
version: ${{ env.TASK_VERSION }}
|
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Set up Android NDK
|
|
run: |
|
|
NDK_DIR=$(ls -d $ANDROID_SDK_ROOT/ndk/*/ 2>/dev/null | sort -V | tail -n1)
|
|
echo "ANDROID_NDK_HOME=${NDK_DIR%/}" >> $GITHUB_ENV
|
|
|
|
- name: Install gomobile
|
|
run: |
|
|
go install golang.org/x/mobile/cmd/gomobile@${{ env.GOMOBILE_VERSION }}
|
|
gomobile init
|
|
|
|
- name: Build AAR
|
|
run: task build:android
|
|
|
|
- uses: actions/upload-artifact@v7.0.1
|
|
with:
|
|
name: android-aar
|
|
path: |
|
|
dist/freeturn.aar
|
|
dist/freeturn-sources.jar
|
|
retention-days: 7
|
|
|
|
goreleaser:
|
|
name: GoReleaser
|
|
runs-on: ubuntu-latest
|
|
needs: [build-ios, build-android]
|
|
steps:
|
|
- uses: actions/checkout@v6.0.2
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- uses: actions/setup-go@v6.4.0
|
|
with:
|
|
go-version: ${{ env.GO_VERSION }}
|
|
cache: true
|
|
|
|
- uses: docker/setup-qemu-action@v4.0.0
|
|
|
|
- uses: docker/setup-buildx-action@v4.1.0
|
|
|
|
- name: Log in to GHCR
|
|
uses: docker/login-action@v4.2.0
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Install syft (SBOM)
|
|
uses: anchore/sbom-action/download-syft@v0.24.0
|
|
|
|
- uses: actions/download-artifact@v7.0.0
|
|
with:
|
|
name: ios-xcframework-zip
|
|
path: mobile-dist/
|
|
|
|
- uses: actions/download-artifact@v7.0.0
|
|
with:
|
|
name: android-aar
|
|
path: mobile-dist/
|
|
|
|
- uses: goreleaser/goreleaser-action@v7.2.2
|
|
with:
|
|
distribution: goreleaser
|
|
version: ${{ env.GORELEASER_VERSION }}
|
|
args: release --clean
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
notify-telegram:
|
|
name: Telegram announce
|
|
runs-on: ubuntu-latest
|
|
needs: goreleaser
|
|
steps:
|
|
- name: Send release message
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
|
|
CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
|
|
run: |
|
|
BODY=$(gh release view "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" --json body -q .body | head -c 3000)
|
|
URL=$(gh release view "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" --json url -q .url)
|
|
# GH-markdown -> Telegram-HTML: сначала экранируем HTML, потом размечаем.
|
|
# Хвосты "by @user in <PR-url>" и ссылки на коммит из авто-нотов убираем - в посте это шум.
|
|
HTML=$(printf '%s' "$BODY" \
|
|
| sed 's/&/\&/g; s/</\</g; s/>/\>/g' \
|
|
| sed -E \
|
|
-e 's| by @[[:alnum:]_-]+ in https://[^[:space:]]+||g' \
|
|
-e 's|[[:space:]]*\(\[[0-9a-f]{6,}\]\(https?://[^)]+/commit/[^)]+\)\)||g' \
|
|
-e 's|\[([^]]+)\]\((https?://[^)]+)\)|<a href="\2">\1</a>|g' \
|
|
-e 's|\*\*([^*]+)\*\*|<b>\1</b>|g' \
|
|
-e 's|`([^`]+)`|<code>\1</code>|g' \
|
|
-e 's|^#{1,6}[[:space:]]+(.*)$|<b>\1</b>|' \
|
|
-e 's|^[-*][[:space:]]+([0-9a-f]{7,40}:[[:space:]]+)?|• |' \
|
|
-e 's|\(@([[:alnum:]_-]+)\)|(<a href="https://github.com/\1">\1</a>)|g')
|
|
TEXT=$(printf '🐒💨 <b>FreeTurn (Go) %s</b>\n\n%s\n\n<a href="%s">Релиз на GitHub</a>' "$GITHUB_REF_NAME" "$HTML" "$URL")
|
|
send() {
|
|
curl -fsS -X POST "https://api.telegram.org/bot${BOT_TOKEN}/sendMessage" \
|
|
--data-urlencode "chat_id=${CHAT_ID}" \
|
|
--data-urlencode "text=$1" \
|
|
--data-urlencode "parse_mode=${2:-}" \
|
|
--data-urlencode "disable_web_page_preview=true" \
|
|
-o /dev/null
|
|
}
|
|
# Кривой HTML роняет весь sendMessage - фолбэк plain text, чтобы анонс не пропал
|
|
send "$TEXT" HTML || send "$(printf '🚀 FreeTurn %s\n\n%s\n\n%s' "$GITHUB_REF_NAME" "$BODY" "$URL")"
|