release:upload goreleaser result to artifact & test it

This commit is contained in:
luoliwoshang
2025-09-03 15:35:13 +08:00
parent 77a7d9e549
commit 7f05aa54c2

View File

@@ -61,19 +61,136 @@ jobs:
ghcr.io/goreleaser/goreleaser-cross:v1.22 \
release --skip=publish,nfpm,snapcraft --snapshot --clean
- name: Upload Build Artifacts
- name: Upload Darwin AMD64 Artifacts
uses: actions/upload-artifact@v4
with:
name: llgo-build-artifacts
path: dist
name: llgo-darwin-amd64
path: .dist/*darwin-amd64.tar.gz
retention-days: 3
- name: Upload Darwin ARM64 Artifacts
uses: actions/upload-artifact@v4
with:
name: llgo-darwin-arm64
path: .dist/*darwin-arm64.tar.gz
retention-days: 3
- name: Upload Linux AMD64 Artifacts
uses: actions/upload-artifact@v4
with:
name: llgo-linux-amd64
path: .dist/*linux-amd64.tar.gz
retention-days: 3
- name: Upload Linux ARM64 Artifacts
uses: actions/upload-artifact@v4
with:
name: llgo-linux-arm64
path: .dist/*linux-arm64.tar.gz
retention-days: 3
- name: Upload Checksums
uses: actions/upload-artifact@v4
with:
name: llgo-checksums
path: .dist/checksums.txt
retention-days: 3
test-artifacts:
needs: build
strategy:
matrix:
include:
- os: macos-latest
goos: darwin
goarch: amd64
- os: macos-latest
goos: darwin
goarch: arm64
- os: ubuntu-latest
goos: linux
goarch: amd64
- os: ubuntu-latest
goos: linux
goarch: arm64
runs-on: ${{ matrix.os }}
steps:
- 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..."
ls -la
# Find the tar.gz file (should be only one)
ARCHIVE=$(ls *.tar.gz | head -n1)
if [ -z "$ARCHIVE" ]; then
echo "No archive found for platform ${{ matrix.goos }}_${{ matrix.goarch }}"
exit 1
fi
echo "Found archive: $ARCHIVE"
mkdir -p extracted
tar -xzf "$ARCHIVE" -C extracted
ls -la extracted/
- name: Test LLGO Binary
run: |
# Find the llgo binary in the extracted files
LLGO_BIN=$(find extracted/ -name "llgo" -type f | head -n1)
if [ -z "$LLGO_BIN" ]; then
echo "llgo binary not found"
exit 1
fi
echo "Found llgo binary: $LLGO_BIN"
chmod +x "$LLGO_BIN"
# Test basic functionality
echo "Testing llgo version..."
"$LLGO_BIN" version
echo "Testing llgo help..."
"$LLGO_BIN" --help
echo "LLGO binary test passed for ${{ matrix.goos }}_${{ matrix.goarch }}"
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)
if: startsWith(github.ref, 'refs/tags/')
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} \