|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + paths: [VERSION] |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + packages: write |
| 11 | + |
| 12 | +jobs: |
| 13 | + release: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v4 |
| 17 | + |
| 18 | + - name: Read version |
| 19 | + id: version |
| 20 | + run: echo "version=$(cat VERSION | tr -d '[:space:]')" >> "$GITHUB_OUTPUT" |
| 21 | + |
| 22 | + - name: Check tag does not exist |
| 23 | + run: | |
| 24 | + if git rev-parse "v${{ steps.version.outputs.version }}" >/dev/null 2>&1; then |
| 25 | + echo "::error::Tag v${{ steps.version.outputs.version }} already exists" |
| 26 | + exit 1 |
| 27 | + fi |
| 28 | +
|
| 29 | + - name: Set up Go |
| 30 | + uses: actions/setup-go@v5 |
| 31 | + with: |
| 32 | + go-version-file: go.mod |
| 33 | + |
| 34 | + - name: Run tests |
| 35 | + run: go test -race ./... |
| 36 | + |
| 37 | + - name: Build sidecar binary for Linux amd64 |
| 38 | + run: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -trimpath -o bin/sidecar-linux ./cmd/sidecar |
| 39 | + |
| 40 | + - name: Set up Docker Buildx |
| 41 | + uses: docker/setup-buildx-action@v3 |
| 42 | + |
| 43 | + - name: Log in to GHCR |
| 44 | + uses: docker/login-action@v3 |
| 45 | + with: |
| 46 | + registry: ghcr.io |
| 47 | + username: ${{ github.actor }} |
| 48 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 49 | + |
| 50 | + - name: Build and push API image |
| 51 | + uses: docker/build-push-action@v6 |
| 52 | + with: |
| 53 | + context: . |
| 54 | + file: build/api/Dockerfile |
| 55 | + push: true |
| 56 | + tags: | |
| 57 | + ghcr.io/helmcode/agentcrew-api:${{ steps.version.outputs.version }} |
| 58 | + ghcr.io/helmcode/agentcrew-api:latest |
| 59 | + cache-from: type=gha |
| 60 | + cache-to: type=gha,mode=max |
| 61 | + |
| 62 | + - name: Prepare agent build context |
| 63 | + run: | |
| 64 | + cp bin/sidecar-linux build/agent/sidecar |
| 65 | +
|
| 66 | + - name: Build and push Agent image |
| 67 | + uses: docker/build-push-action@v6 |
| 68 | + with: |
| 69 | + context: build/agent |
| 70 | + file: build/agent/Dockerfile |
| 71 | + push: true |
| 72 | + tags: | |
| 73 | + ghcr.io/helmcode/agentcrew-agent:${{ steps.version.outputs.version }} |
| 74 | + ghcr.io/helmcode/agentcrew-agent:latest |
| 75 | + cache-from: type=gha |
| 76 | + cache-to: type=gha,mode=max |
| 77 | + |
| 78 | + - name: Create git tag |
| 79 | + run: | |
| 80 | + git tag "v${{ steps.version.outputs.version }}" |
| 81 | + git push origin "v${{ steps.version.outputs.version }}" |
| 82 | +
|
| 83 | + - name: Create GitHub Release |
| 84 | + uses: softprops/action-gh-release@v2 |
| 85 | + with: |
| 86 | + tag_name: v${{ steps.version.outputs.version }} |
| 87 | + name: v${{ steps.version.outputs.version }} |
| 88 | + generate_release_notes: true |
0 commit comments