Skip to content

v1.0.2

v1.0.2 #120

Workflow file for this run

name: build
on:
workflow_dispatch:
release:
types: [published]
env:
GO_VERSION: "~1.26"
MODULE: github.com/mapleafgo/singcast
jobs:
get-release:
runs-on: ubuntu-latest
outputs:
tag_name: ${{ steps.get-release.outputs.tag_name }}
upload_url: ${{ steps.get-release.outputs.upload_url }}
steps:
- name: Get release info
id: get-release
run: |
if [ "${{ github.event_name }}" = "release" ]; then
echo "tag_name=${{ github.event.release.tag_name }}" >> "$GITHUB_OUTPUT"
echo "upload_url=${{ github.event.release.upload_url }}" >> "$GITHUB_OUTPUT"
else
TAG=$(gh release list --limit 1 --json tagName -q '.[0].tagName')
UPLOAD_URL=$(gh release view "$TAG" --json uploadUrl -q '.uploadUrl')
echo "tag_name=$TAG" >> "$GITHUB_OUTPUT"
echo "upload_url=$UPLOAD_URL" >> "$GITHUB_OUTPUT"
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# ── 测试 ────────────────────────────────────────────────
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- uses: actions/setup-go@v6
with:
go-version: ${{ env.GO_VERSION }}
- uses: go-task/setup-task@v2
- name: task test
run: task test
# ── CLI 二进制 ──────────────────────────────────────────
build-cli:
needs: [get-release, test]
strategy:
matrix:
include:
- os: ubuntu-latest
goos: linux
goarch: amd64
- os: ubuntu-latest
goos: linux
goarch: arm64
- os: macos-latest
goos: darwin
goarch: amd64
- os: macos-latest
goos: darwin
goarch: arm64
- os: windows-latest
goos: windows
goarch: amd64
- os: windows-latest
goos: windows
goarch: arm64
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- uses: actions/setup-go@v6
with:
go-version: ${{ env.GO_VERSION }}
- uses: go-task/setup-task@v2
- name: task cli-${{ matrix.goos }}-${{ matrix.goarch }}
run: task cli-${{ matrix.goos }}-${{ matrix.goarch }}
- name: Package
shell: bash
run: |
cd bin
tar -czf singcast-${{ needs.get-release.outputs.tag_name }}-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz *
- name: Upload
uses: shogo82148/actions-upload-release-asset@v1
with:
upload_url: ${{ needs.get-release.outputs.upload_url }}
asset_path: bin/*.tar.gz
overwrite: true
# ── FFI 共享库 (桌面) ───────────────────────────────────
build-ffi-desktop:
needs: [get-release, test]
strategy:
matrix:
include:
- os: ubuntu-latest
goos: linux
goarch: amd64
ext: .so
prefix: lib
- os: ubuntu-latest
goos: linux
goarch: arm64
ext: .so
prefix: lib
- os: macos-latest
goos: darwin
goarch: amd64
ext: .dylib
prefix: lib
- os: macos-latest
goos: darwin
goarch: arm64
ext: .dylib
prefix: lib
- os: windows-latest
goos: windows
goarch: amd64
ext: .dll
prefix: ""
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- uses: actions/setup-go@v6
with:
go-version: ${{ env.GO_VERSION }}
- uses: go-task/setup-task@v2
- name: Install cross-compilation toolchain
if: matrix.goarch == 'arm64' && matrix.goos == 'linux'
run: sudo apt-get update && sudo apt-get install -y gcc-aarch64-linux-gnu
- name: task ffi-${{ matrix.goos }}-${{ matrix.goarch }}
env:
CC: ${{ matrix.goarch == 'arm64' && matrix.goos == 'linux' && 'aarch64-linux-gnu-gcc' || '' }}
run: task ffi-${{ matrix.goos }}-${{ matrix.goarch }}
- name: Package
shell: bash
run: |
cd bin
tar -czf libsingcast-${{ needs.get-release.outputs.tag_name }}-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz *
- name: Upload
uses: shogo82148/actions-upload-release-asset@v1
with:
upload_url: ${{ needs.get-release.outputs.upload_url }}
asset_path: bin/*.tar.gz
overwrite: true
# ── FFI 共享库 (Android) ────────────────────────────────
build-ffi-android:
needs: [get-release, test]
strategy:
matrix:
include:
- goarch: arm64
- goarch: amd64
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- uses: actions/setup-go@v6
with:
go-version: ${{ env.GO_VERSION }}
- uses: go-task/setup-task@v2
- uses: nttld/setup-ndk@v1
with:
ndk-version: r27
add-to-path: false
local-cache: true
- name: Setup gomobile
run: |
go install golang.org/x/mobile/cmd/gomobile@latest
gomobile init
- name: task mobile-android-${{ matrix.goarch }}
run: task mobile-android-${{ matrix.goarch }}
- name: Package
run: |
cd bin
tar -czf libsingcast-${{ needs.get-release.outputs.tag_name }}-android-${{ matrix.goarch }}.tar.gz *
- name: Upload
uses: shogo82148/actions-upload-release-asset@v1
with:
upload_url: ${{ needs.get-release.outputs.upload_url }}
asset_path: bin/*.tar.gz
overwrite: true
# ── FFI 共享库 (iOS) ───────────────────────────────────
build-ffi-ios:
runs-on: macos-latest
needs: [get-release, test]
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- uses: actions/setup-go@v6
with:
go-version: ${{ env.GO_VERSION }}
- uses: go-task/setup-task@v2
- name: Setup gomobile
run: |
go install golang.org/x/mobile/cmd/gomobile@latest
gomobile init
- name: task mobile-ios-arm64
run: task mobile-ios-arm64
- name: Package
run: |
cd bin
tar -czf libsingcast-${{ needs.get-release.outputs.tag_name }}-ios.tar.gz *
- name: Upload
uses: shogo82148/actions-upload-release-asset@v1
with:
upload_url: ${{ needs.get-release.outputs.upload_url }}
asset_path: bin/*.tar.gz
overwrite: true