v0.3.38 #17
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| release: | |
| types: [created] | |
| jobs: | |
| build: | |
| name: Build Multi-Platform Binaries | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Go | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version: '1.23' | |
| - name: Build multi-platform and package | |
| run: make dist-all | |
| env: | |
| VERSION: ${{ github.event.release.tag_name }} | |
| - name: Upload release assets | |
| uses: actions/github-script@v6 | |
| env: | |
| VERSION: ${{ github.event.release.tag_name }} | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const fs = require('fs'); | |
| const platforms = [ | |
| { os: 'linux', arch: 'amd64', ext: 'tar.gz', contentType: 'application/gzip' }, | |
| { os: 'linux', arch: 'arm64', ext: 'tar.gz', contentType: 'application/gzip' }, | |
| { os: 'darwin', arch: 'amd64', ext: 'tar.gz', contentType: 'application/gzip' }, | |
| { os: 'darwin', arch: 'arm64', ext: 'tar.gz', contentType: 'application/gzip' }, | |
| { os: 'windows', arch: 'amd64', ext: 'zip', contentType: 'application/zip' } | |
| ]; | |
| const version = process.env.VERSION || '${{ github.event.release.tag_name }}'; | |
| const uploadUrl = context.payload.release.upload_url; | |
| for (const platform of platforms) { | |
| const archiveName = `kubectl-sql-${version}-${platform.os}-${platform.arch}.${platform.ext}`; | |
| const checksumName = `${archiveName}.sha256sum`; | |
| // Upload archive | |
| const archiveData = fs.readFileSync(archiveName); | |
| await github.rest.repos.uploadReleaseAsset({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| release_id: context.payload.release.id, | |
| name: archiveName, | |
| data: archiveData, | |
| headers: { | |
| 'content-type': platform.contentType, | |
| 'content-length': archiveData.length | |
| } | |
| }); | |
| // Upload checksum | |
| const checksumData = fs.readFileSync(checksumName); | |
| await github.rest.repos.uploadReleaseAsset({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| release_id: context.payload.release.id, | |
| name: checksumName, | |
| data: checksumData, | |
| headers: { | |
| 'content-type': 'text/plain', | |
| 'content-length': checksumData.length | |
| } | |
| }); | |
| console.log(`Uploaded ${archiveName} and ${checksumName}`); | |
| } | |
| console.log('All release assets uploaded successfully'); | |
| - name: Wait for assets to be available | |
| run: | | |
| echo "Waiting 30 seconds for GitHub to propagate release assets..." | |
| sleep 30 | |
| - name: Verify all assets are available | |
| run: | | |
| VERSION="${{ github.event.release.tag_name }}" | |
| ASSETS=( | |
| "kubectl-sql-${VERSION}-linux-amd64.tar.gz" | |
| "kubectl-sql-${VERSION}-linux-arm64.tar.gz" | |
| "kubectl-sql-${VERSION}-darwin-amd64.tar.gz" | |
| "kubectl-sql-${VERSION}-darwin-arm64.tar.gz" | |
| "kubectl-sql-${VERSION}-windows-amd64.zip" | |
| ) | |
| echo "Verifying release assets are downloadable..." | |
| for asset in "${ASSETS[@]}"; do | |
| url="https://github.com/yaacov/kubectl-sql/releases/download/${VERSION}/${asset}" | |
| echo "Checking: $url" | |
| if curl -sSL --fail -I "$url" > /dev/null; then | |
| echo "✅ $asset is available" | |
| else | |
| echo "❌ $asset is not available" | |
| exit 1 | |
| fi | |
| done | |
| echo "All assets verified successfully!" | |
| - name: Update Krew index | |
| uses: rajatjindal/[email protected] |