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: freebsd goarch: amd64 - goos: freebsd goarch: arm64 - goos: windows goarch: amd64 - goos: android goarch: arm64 - goos: linux goarch: arm goarm: '7' android_arm: true 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' run: sudo apt-get update && sudo apt-get install -y upx-ucl - name: Build Server if: matrix.goos != 'android' && !matrix.android_arm 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 }} GOARM: ${{ matrix.goarm || '' }} 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 if [ "${{ matrix.android_arm }}" = "true" ]; then out="build/thefeed-client-android-arm" else out="build/thefeed-client-${{ matrix.goos }}-${{ matrix.goarch }}${ext}" fi go build -trimpath -ldflags="${LDFLAGS}" -o "$out" ./cmd/client - name: Compress with UPX if: matrix.goos == 'linux' || matrix.goos == 'windows' 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: | mkdir -p android/app/src/main/jniLibs/arm64-v8a mkdir -p android/app/src/main/jniLibs/armeabi-v7a test -f artifacts/thefeed-client-android-arm64 test -f artifacts/thefeed-client-android-arm cp artifacts/thefeed-client-android-arm64 android/app/src/main/jniLibs/arm64-v8a/libthefeed.so cp artifacts/thefeed-client-android-arm android/app/src/main/jniLibs/armeabi-v7a/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 Android 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 BT=release; TASK=assembleRelease; else BT=debug; TASK=assembleDebug; fi ./gradlew --no-daemon clean $TASK APK_DIR=app/build/outputs/apk/$BT cp "$APK_DIR"/app-arm64-v8a-${BT}.apk ../artifacts/thefeed-android-arm64.apk cp "$APK_DIR"/app-armeabi-v7a-${BT}.apk ../artifacts/thefeed-android-arm.apk cp "$APK_DIR"/app-universal-${BT}.apk ../artifacts/thefeed-android-universal.apk - name: Upload Android APK artifacts uses: actions/upload-artifact@v4 with: name: thefeed-android-apk path: | artifacts/thefeed-android-arm64.apk artifacts/thefeed-android-arm.apk artifacts/thefeed-android-universal.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, '-') }} append_body: true body: | ## Downloads | Platform | Architecture | Download | |----------|-------------|----------| | Linux | amd64 | [thefeed-server-linux-amd64](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/thefeed-server-linux-amd64) / [client](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/thefeed-client-linux-amd64) | | Linux | arm64 | [thefeed-server-linux-arm64](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/thefeed-server-linux-arm64) / [client](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/thefeed-client-linux-arm64) | | macOS | amd64 (Intel) | [thefeed-server-darwin-amd64](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/thefeed-server-darwin-amd64) / [client](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/thefeed-client-darwin-amd64) | | macOS | arm64 (Apple Silicon) | [thefeed-server-darwin-arm64](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/thefeed-server-darwin-arm64) / [client](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/thefeed-client-darwin-arm64) | | FreeBSD | amd64 | [thefeed-server-freebsd-amd64](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/thefeed-server-freebsd-amd64) / [client](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/thefeed-client-freebsd-amd64) | | FreeBSD | arm64 | [thefeed-server-freebsd-arm64](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/thefeed-server-freebsd-arm64) / [client](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/thefeed-client-freebsd-arm64) | | Windows | amd64 | [thefeed-server-windows-amd64.exe](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/thefeed-server-windows-amd64.exe) / [client](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/thefeed-client-windows-amd64.exe) | | Android | arm64 (v8a) | [thefeed-android-arm64.apk](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/thefeed-android-arm64.apk) | | Android | arm (v7a) | [thefeed-android-arm.apk](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/thefeed-android-arm.apk) | | Android | Universal | [thefeed-android-universal.apk](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/thefeed-android-universal.apk) |