|
| 1 | +# ============================================================================= |
| 2 | +# Release — Build Docker image, push to GHCR, create GitHub Release on tag |
| 3 | +# ============================================================================= |
| 4 | +name: Release |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + tags: |
| 9 | + - "v*" |
| 10 | + |
| 11 | +env: |
| 12 | + REGISTRY: ghcr.io |
| 13 | + IMAGE_NAME: epappas/llmtrace-proxy |
| 14 | + |
| 15 | +permissions: |
| 16 | + contents: write |
| 17 | + packages: write |
| 18 | + |
| 19 | +jobs: |
| 20 | + build-and-push: |
| 21 | + name: Build & Push Docker Image |
| 22 | + runs-on: ubuntu-latest |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@v4 |
| 25 | + with: |
| 26 | + fetch-depth: 0 |
| 27 | + |
| 28 | + - name: Extract version from tag |
| 29 | + id: meta |
| 30 | + run: | |
| 31 | + TAG="${GITHUB_REF#refs/tags/}" |
| 32 | + VERSION="${TAG#v}" |
| 33 | + echo "tag=$TAG" >> "$GITHUB_OUTPUT" |
| 34 | + echo "version=$VERSION" >> "$GITHUB_OUTPUT" |
| 35 | + # Generate changelog from last tag |
| 36 | + PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "") |
| 37 | + if [ -n "$PREV_TAG" ]; then |
| 38 | + echo "## Changes since $PREV_TAG" > changelog.md |
| 39 | + git log --pretty=format:"- %s (%h)" "$PREV_TAG"..HEAD >> changelog.md |
| 40 | + else |
| 41 | + echo "## Initial Release" > changelog.md |
| 42 | + git log --pretty=format:"- %s (%h)" >> changelog.md |
| 43 | + fi |
| 44 | +
|
| 45 | + - name: Log in to GHCR |
| 46 | + uses: docker/login-action@v3 |
| 47 | + with: |
| 48 | + registry: ${{ env.REGISTRY }} |
| 49 | + username: ${{ github.actor }} |
| 50 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 51 | + |
| 52 | + - name: Set up Docker Buildx |
| 53 | + uses: docker/setup-buildx-action@v3 |
| 54 | + |
| 55 | + - name: Build and push Docker image |
| 56 | + uses: docker/build-push-action@v6 |
| 57 | + with: |
| 58 | + context: . |
| 59 | + push: true |
| 60 | + tags: | |
| 61 | + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }} |
| 62 | + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest |
| 63 | + labels: | |
| 64 | + org.opencontainers.image.source=https://github.com/${{ github.repository }} |
| 65 | + org.opencontainers.image.revision=${{ github.sha }} |
| 66 | + org.opencontainers.image.version=${{ steps.meta.outputs.version }} |
| 67 | + org.opencontainers.image.created=${{ github.event.head_commit.timestamp }} |
| 68 | + cache-from: type=gha |
| 69 | + cache-to: type=gha,mode=max |
| 70 | + |
| 71 | + - name: Create GitHub Release |
| 72 | + uses: softprops/action-gh-release@v2 |
| 73 | + with: |
| 74 | + tag_name: ${{ steps.meta.outputs.tag }} |
| 75 | + name: "LLMTrace ${{ steps.meta.outputs.tag }}" |
| 76 | + body_path: changelog.md |
| 77 | + draft: false |
| 78 | + prerelease: ${{ contains(steps.meta.outputs.tag, '-') }} |
| 79 | + env: |
| 80 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments