|
80 | 80 | args: release --clean |
81 | 81 | env: |
82 | 82 | GITHUB_TOKEN: ${{ secrets.DEPLOY_ACCESS_TOKEN }} |
| 83 | + |
| 84 | + musl-binary: |
| 85 | + needs: binary |
| 86 | + runs-on: ubuntu-latest |
| 87 | + container: golang:1.24-alpine |
| 88 | + steps: |
| 89 | + - name: Git checkout |
| 90 | + uses: actions/checkout@v6 |
| 91 | + |
| 92 | + - name: Install musl dependencies (Alpine container) |
| 93 | + run: | |
| 94 | + apk add --no-cache \ |
| 95 | + musl-dev \ |
| 96 | + gcc \ |
| 97 | + git \ |
| 98 | + make \ |
| 99 | + linux-headers \ |
| 100 | + tar |
| 101 | +
|
| 102 | + - name: Compile KCL (musl static build) |
| 103 | + run: | |
| 104 | + CGO_ENABLED=1 go build -tags="musl netgo static osusergo" -ldflags="-linkmode external -extldflags '-static'" ./cmd/kcl |
| 105 | + env: |
| 106 | + CGO_LDFLAGS: '-static' |
| 107 | + |
| 108 | + - name: Package musl binary with docs |
| 109 | + run: | |
| 110 | + TAG_NAME=${{ github.ref_name }} |
| 111 | + mkdir -p kcl-musl-package |
| 112 | + cp -f ./kcl ./kcl-musl-package/ |
| 113 | + cp -f ./README.md ./kcl-musl-package/ |
| 114 | + cp -f ./LICENSE ./kcl-musl-package/ |
| 115 | + tar -czf kcl-${TAG_NAME}-linux-musl-amd64.tar.gz -C kcl-musl-package . |
| 116 | + ls -lh kcl-${TAG_NAME}-linux-musl-amd64.tar.gz |
| 117 | + echo "PACKAGE_NAME=kcl-${TAG_NAME}-linux-musl-amd64.tar.gz" >> $GITHUB_ENV |
| 118 | +
|
| 119 | + - name: Upload musl package to Artifact |
| 120 | + uses: actions/upload-artifact@v4 |
| 121 | + with: |
| 122 | + name: kcl-musl-package |
| 123 | + path: ./${{ env.PACKAGE_NAME }} |
| 124 | + retention-days: 7 |
| 125 | + |
| 126 | + upload-musl-to-release: |
| 127 | + needs: [binary, musl-binary] |
| 128 | + runs-on: ubuntu-latest |
| 129 | + steps: |
| 130 | + - name: Download musl package from Artifact |
| 131 | + uses: actions/download-artifact@v4 |
| 132 | + with: |
| 133 | + name: kcl-musl-package |
| 134 | + path: ./ |
| 135 | + |
| 136 | + - name: Install GitHub CLI |
| 137 | + run: | |
| 138 | + sudo apt update && sudo apt install -y gh |
| 139 | +
|
| 140 | + - name: Upload to GitHub Release |
| 141 | + run: | |
| 142 | + echo "${{ secrets.DEPLOY_ACCESS_TOKEN }}" | gh auth login --with-token |
| 143 | + PACKAGE_NAME=$(ls ./kcl-*.tar.gz) |
| 144 | + gh release upload "${{ github.ref_name }}" "${PACKAGE_NAME}" --clobber |
| 145 | + env: |
| 146 | + GITHUB_API_URL: https://api.github.com |
0 commit comments