264 lines
8.9 KiB
YAML
264 lines
8.9 KiB
YAML
name: Release Build
|
||
|
||
on:
|
||
push:
|
||
branches: ["**"]
|
||
tags: ["*"]
|
||
pull_request:
|
||
branches: ["**"]
|
||
|
||
jobs:
|
||
populate-darwin-sysroot:
|
||
runs-on: macos-latest
|
||
steps:
|
||
- name: Check out code
|
||
uses: actions/checkout@v5
|
||
- name: Restore Darwin sysroot cache
|
||
id: cache-darwin-sysroot
|
||
uses: actions/cache/restore@v4
|
||
with:
|
||
path: .sysroot/darwin.tar.gz
|
||
key: darwin-sysroot-${{ hashFiles('.github/workflows/populate_darwin_sysroot.sh') }}-0.0.5
|
||
- name: Populate Darwin sysroot
|
||
if: steps.cache-darwin-sysroot.outputs.cache-hit != 'true'
|
||
run: bash .github/workflows/populate_darwin_sysroot.sh
|
||
- name: Create Darwin sysroot tarball
|
||
if: steps.cache-darwin-sysroot.outputs.cache-hit != 'true'
|
||
run: tar -czvf .sysroot/darwin.tar.gz -C .sysroot darwin
|
||
- name: Save Darwin sysroot cache
|
||
# if: steps.cache-darwin-sysroot.outputs.cache-hit != 'true'
|
||
uses: actions/cache/save@v4
|
||
with:
|
||
path: .sysroot/darwin.tar.gz
|
||
key: darwin-sysroot-${{ hashFiles('.github/workflows/populate_darwin_sysroot.sh') }}-0.0.5
|
||
populate-linux-sysroot:
|
||
runs-on: ubuntu-latest
|
||
steps:
|
||
- name: Check out code
|
||
uses: actions/checkout@v5
|
||
- name: Restore Linux sysroot cache
|
||
id: cache-linux-sysroot
|
||
uses: actions/cache/restore@v4
|
||
with:
|
||
path: .sysroot/linux.tar.gz
|
||
key: linux-sysroot-${{ hashFiles('.github/workflows/populate_linux_sysroot.sh') }}-0.0.7
|
||
- name: Set up QEMU
|
||
uses: docker/setup-qemu-action@v3
|
||
if: steps.cache-linux-sysroot.outputs.cache-hit != 'true'
|
||
with:
|
||
image: tonistiigi/binfmt:qemu-v7.0.0-28
|
||
- name: Populate Linux sysroot
|
||
if: steps.cache-linux-sysroot.outputs.cache-hit != 'true'
|
||
run: bash .github/workflows/populate_linux_sysroot.sh
|
||
- name: Create Linux sysroot tarball
|
||
if: steps.cache-linux-sysroot.outputs.cache-hit != 'true'
|
||
run: tar -czvf .sysroot/linux.tar.gz -C .sysroot linux
|
||
- name: Verify Linux sysroot contents
|
||
if: steps.cache-linux-sysroot.outputs.cache-hit != 'true'
|
||
run: |
|
||
echo "验证 AMD64 sysroot..."
|
||
if [ ! -d ".sysroot/linux/amd64/usr/include/llvm-19" ]; then
|
||
echo "错误:AMD64 sysroot 缺少 LLVM 头文件"
|
||
exit 1
|
||
fi
|
||
|
||
echo "验证 ARM64 sysroot..."
|
||
if [ ! -d ".sysroot/linux/arm64/usr/include/llvm-19" ]; then
|
||
echo "错误:ARM64 sysroot 缺少 LLVM 头文件"
|
||
exit 1
|
||
fi
|
||
|
||
echo "检查关键文件..."
|
||
ls -la .sysroot/linux/amd64/usr/include/llvm-c/Core.h || echo "AMD64 Core.h 缺失"
|
||
ls -la .sysroot/linux/arm64/usr/include/llvm-c/Core.h || echo "ARM64 Core.h 缺失"
|
||
|
||
echo "sysroot 验证通过!"
|
||
- name: Save Linux sysroot cache
|
||
if: steps.cache-linux-sysroot.outputs.cache-hit != 'true'
|
||
uses: actions/cache/save@v4
|
||
with:
|
||
path: .sysroot/linux.tar.gz
|
||
key: linux-sysroot-${{ hashFiles('.github/workflows/populate_linux_sysroot.sh') }}-0.0.7
|
||
build:
|
||
runs-on: ubuntu-latest
|
||
needs: [populate-darwin-sysroot, populate-linux-sysroot]
|
||
steps:
|
||
- name: Check out code
|
||
uses: actions/checkout@v5
|
||
with:
|
||
fetch-depth: 0
|
||
- name: Set up Go
|
||
uses: actions/setup-go@v5
|
||
with:
|
||
go-version: 1.24.x
|
||
- name: Set up QEMU
|
||
uses: docker/setup-qemu-action@v3
|
||
with:
|
||
image: tonistiigi/binfmt:qemu-v7.0.0-28
|
||
- name: Restore Darwin sysroot cache
|
||
id: cache-darwin-sysroot
|
||
uses: actions/cache/restore@v4
|
||
with:
|
||
path: .sysroot/darwin.tar.gz
|
||
key: darwin-sysroot-${{ hashFiles('.github/workflows/populate_darwin_sysroot.sh') }}-0.0.5
|
||
- name: Restore Linux sysroot cache
|
||
id: cache-linux-sysroot
|
||
uses: actions/cache/restore@v4
|
||
with:
|
||
path: .sysroot/linux.tar.gz
|
||
key: linux-sysroot-${{ hashFiles('.github/workflows/populate_linux_sysroot.sh') }}-0.0.7
|
||
- name: Populate Darwin sysroot
|
||
run: tar -xzvf .sysroot/darwin.tar.gz -C .sysroot
|
||
- name: Populate Linux sysroot
|
||
run: tar -xzvf .sysroot/linux.tar.gz -C .sysroot
|
||
- name: Check file
|
||
run: tree .sysroot
|
||
- name: Run GoReleaser (Build & Test)
|
||
env:
|
||
GITHUB_TOKEN: ${{github.token}}
|
||
run: |
|
||
docker run \
|
||
--rm \
|
||
-e GITHUB_TOKEN=${GITHUB_TOKEN} \
|
||
-v /var/run/docker.sock:/var/run/docker.sock \
|
||
-v $(pwd):/go/src/llgo \
|
||
-w /go/src/llgo \
|
||
ghcr.io/goreleaser/goreleaser-cross:v1.22 \
|
||
release --skip=publish,nfpm,snapcraft --snapshot --clean
|
||
|
||
- name: Upload Darwin AMD64 Artifacts
|
||
uses: actions/upload-artifact@v4
|
||
with:
|
||
name: llgo-darwin-amd64
|
||
path: .dist/*darwin-amd64.tar.gz
|
||
retention-days: 3
|
||
include-hidden-files: true
|
||
|
||
- name: Upload Darwin ARM64 Artifacts
|
||
uses: actions/upload-artifact@v4
|
||
with:
|
||
name: llgo-darwin-arm64
|
||
path: .dist/*darwin-arm64.tar.gz
|
||
retention-days: 3
|
||
include-hidden-files: true
|
||
|
||
- name: Upload Linux AMD64 Artifacts
|
||
uses: actions/upload-artifact@v4
|
||
with:
|
||
name: llgo-linux-amd64
|
||
path: .dist/*linux-amd64.tar.gz
|
||
retention-days: 3
|
||
include-hidden-files: true
|
||
|
||
- name: Upload Linux ARM64 Artifacts
|
||
uses: actions/upload-artifact@v4
|
||
with:
|
||
name: llgo-linux-arm64
|
||
path: .dist/*linux-arm64.tar.gz
|
||
retention-days: 3
|
||
include-hidden-files: true
|
||
|
||
- name: Upload Checksums
|
||
uses: actions/upload-artifact@v4
|
||
with:
|
||
name: llgo-checksums
|
||
path: .dist/*checksums.txt
|
||
retention-days: 3
|
||
include-hidden-files: true
|
||
|
||
test-artifacts:
|
||
needs: build
|
||
strategy:
|
||
matrix:
|
||
include:
|
||
- os: macos-13
|
||
goos: darwin
|
||
goarch: amd64
|
||
go-version: "1.24.2"
|
||
go-mod-version: "1.24"
|
||
- os: macos-latest
|
||
goos: darwin
|
||
goarch: arm64
|
||
go-version: "1.24.2"
|
||
go-mod-version: "1.24"
|
||
- os: ubuntu-latest
|
||
goos: linux
|
||
goarch: amd64
|
||
go-version: "1.24.2"
|
||
go-mod-version: "1.24"
|
||
- os: ubuntu-24.04-arm
|
||
goos: linux
|
||
goarch: arm64
|
||
go-version: "1.24.2"
|
||
go-mod-version: "1.24"
|
||
runs-on: ${{ matrix.os }}
|
||
steps:
|
||
- uses: actions/checkout@v5
|
||
- name: Install dependencies
|
||
uses: ./.github/actions/setup-deps
|
||
- name: Set up Go
|
||
uses: actions/setup-go@v5
|
||
with:
|
||
go-version: ${{ matrix.go-version }}
|
||
- name: Download Platform Artifact
|
||
uses: actions/download-artifact@v5
|
||
with:
|
||
name: llgo-${{ matrix.goos }}-${{ matrix.goarch }}
|
||
path: .
|
||
|
||
- name: Extract LLGO Archive
|
||
run: |
|
||
echo "Looking for ${{ matrix.goos }}_${{ matrix.goarch }} archive..."
|
||
ARCHIVE=$(ls *.tar.gz | head -n1)
|
||
mkdir -p release-llgo
|
||
tar -xzf "$ARCHIVE" -C release-llgo
|
||
ls -la release-llgo/
|
||
echo "${{ github.workspace }}/release-llgo/bin/" >> $GITHUB_PATH
|
||
|
||
- name: Test Hello World with go.mod 1.21
|
||
uses: ./.github/actions/test-helloworld
|
||
with:
|
||
go-version: ${{matrix.go-version}}
|
||
mod-version: ${{ matrix.go-mod-version }}
|
||
|
||
release:
|
||
needs: [build, test-artifacts]
|
||
runs-on: ubuntu-latest
|
||
if: startsWith(github.ref, 'refs/tags/')
|
||
steps:
|
||
- name: Check out code
|
||
uses: actions/checkout@v5
|
||
with:
|
||
fetch-depth: 0
|
||
- name: Set up Go
|
||
uses: actions/setup-go@v5
|
||
with:
|
||
go-version: 1.24.x
|
||
- name: Set up QEMU
|
||
uses: docker/setup-qemu-action@v3
|
||
with:
|
||
image: tonistiigi/binfmt:qemu-v7.0.0-28
|
||
- name: Download Darwin sysroot tarball
|
||
uses: actions/download-artifact@v5
|
||
with:
|
||
name: darwin-sysroot-tarball
|
||
path: .sysroot
|
||
- name: Populate Darwin sysroot
|
||
run: tar -xzvf .sysroot/darwin.tar.gz -C .sysroot
|
||
- name: Populate Linux sysroot
|
||
run: bash .github/workflows/populate_linux_sysroot.sh
|
||
- name: Run GoReleaser (Release)
|
||
env:
|
||
GITHUB_TOKEN: ${{github.token}}
|
||
run: |
|
||
echo "Publishing release for tag: ${{ github.ref }}"
|
||
echo "All artifact tests passed, proceeding with release..."
|
||
docker run \
|
||
--rm \
|
||
-e GITHUB_TOKEN=${GITHUB_TOKEN} \
|
||
-v /var/run/docker.sock:/var/run/docker.sock \
|
||
-v $(pwd):/go/src/llgo \
|
||
-w /go/src/llgo \
|
||
ghcr.io/goreleaser/goreleaser-cross:v1.22 \
|
||
release --clean --skip nfpm,snapcraft
|