mirror of
https://github.com/sartoopjj/thefeed.git
synced 2026-05-18 05:24:36 +03:00
180 lines
5.8 KiB
YAML
180 lines
5.8 KiB
YAML
name: Build
|
|
|
|
on:
|
|
push:
|
|
tags: ['v*']
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version: '1.26'
|
|
- name: Test
|
|
run: go test -race -count=1 ./...
|
|
- name: Vet
|
|
run: go vet ./...
|
|
|
|
build:
|
|
needs: test
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
include:
|
|
- goos: linux
|
|
goarch: amd64
|
|
- goos: linux
|
|
goarch: arm64
|
|
- goos: darwin
|
|
goarch: amd64
|
|
- goos: darwin
|
|
goarch: arm64
|
|
- goos: windows
|
|
goarch: amd64
|
|
- goos: android
|
|
goarch: arm64
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version: '1.26'
|
|
|
|
- name: Install UPX
|
|
if: matrix.goos == 'linux' || matrix.goos == 'windows' || matrix.goos == 'android'
|
|
run: sudo apt-get update && sudo apt-get install -y upx-ucl
|
|
|
|
- name: Build Server
|
|
if: matrix.goos != 'android'
|
|
env:
|
|
GOOS: ${{ matrix.goos }}
|
|
GOARCH: ${{ matrix.goarch }}
|
|
CGO_ENABLED: '0'
|
|
run: |
|
|
VERSION=${GITHUB_REF_NAME:-dev}
|
|
COMMIT=$(git rev-parse --short HEAD)
|
|
DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ)
|
|
LDFLAGS="-s -w -X github.com/sartoopjj/thefeed/internal/version.Version=${VERSION} -X github.com/sartoopjj/thefeed/internal/version.Commit=${COMMIT} -X github.com/sartoopjj/thefeed/internal/version.Date=${DATE}"
|
|
ext=""
|
|
if [ "${{ matrix.goos }}" = "windows" ]; then ext=".exe"; fi
|
|
go build -trimpath -ldflags="${LDFLAGS}" -o build/thefeed-server-${{ matrix.goos }}-${{ matrix.goarch }}${ext} ./cmd/server
|
|
|
|
- name: Build Client
|
|
env:
|
|
GOOS: ${{ matrix.goos }}
|
|
GOARCH: ${{ matrix.goarch }}
|
|
CGO_ENABLED: '0'
|
|
run: |
|
|
VERSION=${GITHUB_REF_NAME:-dev}
|
|
COMMIT=$(git rev-parse --short HEAD)
|
|
DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ)
|
|
LDFLAGS="-s -w -X github.com/sartoopjj/thefeed/internal/version.Version=${VERSION} -X github.com/sartoopjj/thefeed/internal/version.Commit=${COMMIT} -X github.com/sartoopjj/thefeed/internal/version.Date=${DATE}"
|
|
ext=""
|
|
if [ "${{ matrix.goos }}" = "windows" ]; then ext=".exe"; fi
|
|
go build -trimpath -ldflags="${LDFLAGS}" -o build/thefeed-client-${{ matrix.goos }}-${{ matrix.goarch }}${ext} ./cmd/client
|
|
|
|
- name: Compress with UPX
|
|
if: matrix.goos == 'linux' || matrix.goos == 'windows' || matrix.goos == 'android'
|
|
run: |
|
|
for f in build/*; do
|
|
if [ -f "$f" ]; then
|
|
upx --best --lzma "$f" || true
|
|
fi
|
|
done
|
|
|
|
- name: Upload artifacts
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: binaries-${{ matrix.goos }}-${{ matrix.goarch }}
|
|
path: build/
|
|
|
|
android-apk:
|
|
needs: build
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Download all artifacts
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
path: artifacts
|
|
merge-multiple: true
|
|
|
|
- name: Stage Android client binary as JNI library
|
|
run: |
|
|
# Package binaries as .so in jniLibs — Android installer extracts only the
|
|
# folder matching the device ABI into nativeLibraryDir (the only exec-safe
|
|
# location under Android's W^X policy). ABI splits in build.gradle ensure
|
|
# the arm64 APK only contains arm64-v8a and universal contains all three.
|
|
mkdir -p android/app/src/main/jniLibs/arm64-v8a
|
|
test -f artifacts/thefeed-client-android-arm64
|
|
cp artifacts/thefeed-client-android-arm64 android/app/src/main/jniLibs/arm64-v8a/libthefeed.so
|
|
|
|
- name: Decode signing keystore
|
|
env:
|
|
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
|
|
run: |
|
|
if [ -n "$KEYSTORE_BASE64" ]; then
|
|
echo "$KEYSTORE_BASE64" | base64 -d > android/app/keystore.jks
|
|
echo "Keystore decoded successfully"
|
|
else
|
|
echo "No KEYSTORE_BASE64 secret set — will use debug signing"
|
|
fi
|
|
|
|
- name: Set up Java
|
|
uses: actions/setup-java@v4
|
|
with:
|
|
distribution: temurin
|
|
java-version: '17'
|
|
|
|
- name: Set up Gradle
|
|
uses: gradle/actions/setup-gradle@v4
|
|
|
|
- name: Build APK
|
|
working-directory: android
|
|
env:
|
|
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
|
|
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
|
|
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
|
|
run: |
|
|
gradle wrapper --gradle-version 8.10.2
|
|
if [ -f app/keystore.jks ]; then
|
|
./gradlew --no-daemon assembleRelease
|
|
else
|
|
./gradlew --no-daemon assembleDebug
|
|
fi
|
|
|
|
- name: Rename APK
|
|
run: |
|
|
if [ -f android/app/keystore.jks ]; then BT=release; SUFFIX=release; else BT=debug; SUFFIX=debug; fi
|
|
APK=$(find android/app/build/outputs/apk/$BT -name "*.apk" | head -1)
|
|
cp "$APK" artifacts/thefeed-android-arm64.apk
|
|
|
|
- name: Upload Android APK artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: thefeed-android-apk
|
|
path: artifacts/thefeed-android-arm64.apk
|
|
|
|
release:
|
|
needs: [build, android-apk]
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Download all artifacts
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
path: artifacts
|
|
merge-multiple: true
|
|
|
|
- name: Create Release
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
files: artifacts/*
|
|
generate_release_notes: true
|
|
prerelease: ${{ contains(github.ref_name, '-') }}
|