radar-agent-built #14
  
    
      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: Build and Release Agent | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: redis-field-engineering/radar-agent | |
| permissions: | |
| contents: write | |
| packages: write | |
| on: | |
| repository_dispatch: | |
| types: [radar-agent-built] | |
| jobs: | |
| copy-binaries: | |
| name: Download Binaries from Radar Repo | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout radar-agent repo | |
| uses: actions/checkout@v4 | |
| - name: Download binaries from radar repository workflow | |
| uses: dawidd6/action-download-artifact@v3 | |
| with: | |
| github_token: ${{ secrets.RADAR_AGENT_TOKEN }} | |
| run_id: ${{ github.event.client_payload.workflow_run_id }} | |
| repo: redis-field-engineering/radar | |
| path: ./binaries | |
| - name: Prepare binaries for Docker build and release | |
| run: | | |
| # Copy all binaries to root for consistent access | |
| cp ./binaries/radar-agent-linux/radar-agent-linux ./radar-agent-linux | |
| cp ./binaries/radar-agent-linux-musl/radar-agent-linux-musl ./radar-agent-linux-musl | |
| cp ./binaries/radar-agent-darwin/radar-agent-darwin ./radar-agent-darwin | |
| # Make binaries executable | |
| chmod +x radar-agent-* | |
| # Log what we received | |
| echo "✅ Downloaded binaries for tag: ${{ github.event.client_payload.ref }}" | |
| # Verify binaries | |
| ls -la radar-agent-* | |
| - name: Upload binaries for Docker build and release | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: agent-binaries | |
| path: | | |
| radar-agent-linux | |
| radar-agent-linux-musl | |
| radar-agent-darwin | |
| retention-days: 1 | |
| docker: | |
| name: Build and Push Docker Images | |
| needs: [copy-binaries] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout radar-agent repo | |
| uses: actions/checkout@v4 | |
| - name: Download binaries | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: agent-binaries | |
| path: ./ | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| labels: | | |
| org.opencontainers.image.source=https://github.com/redis-field-engineering/radar-agent | |
| tags: | | |
| type=ref,event=branch | |
| type=ref,event=pr | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{major}}.{{minor}} | |
| type=semver,pattern={{major}} | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| - name: Get tag name | |
| id: tag | |
| run: | | |
| echo "tag_name=${{ github.event.client_payload.ref }}" >> $GITHUB_OUTPUT | |
| - name: Build and push Debian image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ./docker/Dockerfile | |
| build-args: | | |
| BINARY=radar-agent-linux | |
| push: true | |
| tags: | | |
| ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:debian-${{ steps.tag.outputs.tag_name }} | |
| ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:debian-latest | |
| labels: ${{ steps.meta.outputs.labels }} | |
| platforms: linux/amd64 | |
| - name: Build and push Alpine image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ./docker/Dockerfile.alpine | |
| build-args: | | |
| BINARY=radar-agent-linux-musl | |
| push: true | |
| tags: | | |
| ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:alpine-${{ steps.tag.outputs.tag_name }} | |
| ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:alpine-latest | |
| labels: ${{ steps.meta.outputs.labels }} | |
| platforms: linux/amd64 | |
| release: | |
| name: Create Release | |
| needs: [docker] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout radar-agent repo | |
| uses: actions/checkout@v4 | |
| - name: Download binaries | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: agent-binaries | |
| path: ./ | |
| - name: Get tag name | |
| id: tag | |
| run: | | |
| echo "tag_name=${{ github.event.client_payload.ref }}" >> $GITHUB_OUTPUT | |
| - name: Import GPG key | |
| uses: crazy-max/ghaction-import-gpg@v6 | |
| with: | |
| gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} | |
| passphrase: ${{ secrets.GPG_PASSPHRASE }} | |
| git_user_signingkey: true | |
| - name: Create signed tag for this repository | |
| run: | | |
| # Create and explicitly sign the tag with -s flag | |
| git tag -s ${{ steps.tag.outputs.tag_name }} -m "Release ${{ steps.tag.outputs.tag_name }}" --force | |
| # Push the signed tag to the repository | |
| git push origin ${{ steps.tag.outputs.tag_name }} --force | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ steps.tag.outputs.tag_name }} | |
| name: "Radar Agent ${{ steps.tag.outputs.tag_name }}" | |
| files: | | |
| radar-agent-linux | |
| radar-agent-linux-musl | |
| radar-agent-darwin | |
| make_latest: true | |
| body: | | |
| ## Radar Agent Release ${{ steps.tag.outputs.tag_name }} | |
| ### Quick Install | |
| **Linux (glibc):** | |
| ```bash | |
| curl -L "https://github.com/redis-field-engineering/radar-agent/releases/download/${{ steps.tag.outputs.tag_name }}/radar-agent-linux" -o radar-agent | |
| ``` | |
| **Linux (musl):** | |
| ```bash | |
| curl -L "https://github.com/redis-field-engineering/radar-agent/releases/download/${{ steps.tag.outputs.tag_name }}/radar-agent-linux-musl" -o radar-agent | |
| ``` | |
| **macOS:** | |
| ```bash | |
| curl -L "https://github.com/redis-field-engineering/radar-agent/releases/download/${{ steps.tag.outputs.tag_name }}/radar-agent-darwin" -o radar-agent | |
| ``` | |
| **Install binary:** | |
| ```bash | |
| chmod +x radar-agent | |
| sudo cp radar-agent /usr/local/bin/radar-agent | |
| ``` | |
| **Docker:** | |
| ```bash | |
| # Alpine (recommended) | |
| docker pull ghcr.io/redis-field-engineering/radar-agent:alpine-${{ steps.tag.outputs.tag_name }} | |
| # Debian | |
| docker pull ghcr.io/redis-field-engineering/radar-agent:debian-${{ steps.tag.outputs.tag_name }} | |
| ``` | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |