From 0d4b76dc369512767d4eba9b397095b64bcf69dd Mon Sep 17 00:00:00 2001 From: Darshit Suratwala Date: Tue, 9 Apr 2024 12:57:44 +0530 Subject: [PATCH] feat: add release workflow with auto trigger --- .../{build-image.yaml => build-docker.yaml} | 24 ++++++- .github/workflows/release_langtrace.yaml | 66 +++++++++++++++++++ Dockerfile | 7 ++ 3 files changed, 94 insertions(+), 3 deletions(-) rename .github/workflows/{build-image.yaml => build-docker.yaml} (69%) create mode 100644 .github/workflows/release_langtrace.yaml diff --git a/.github/workflows/build-image.yaml b/.github/workflows/build-docker.yaml similarity index 69% rename from .github/workflows/build-image.yaml rename to .github/workflows/build-docker.yaml index 157e5781..38aeeed7 100644 --- a/.github/workflows/build-image.yaml +++ b/.github/workflows/build-docker.yaml @@ -2,12 +2,22 @@ name: "Build Docker Image" run-name: "Version: ${{ inputs.imageTag }} --> Latest: ${{ inputs.isLatest }}" on: + workflow_call: + inputs: + imageTag: + description: Release version + type: string + required: true + isLatest: + description: Is this the latest version? + type: boolean + required: true workflow_dispatch: inputs: imageTag: description: Release version + type: string required: true - default: example isLatest: description: Is this the latest version? type: boolean @@ -18,12 +28,17 @@ jobs: docker-build: runs-on: ubuntu-latest env: - DOCKER_REGISTRY: scale3labs/langtrace-client + DOCKER_REGISTRY: ${{ vars.DOCKER_REGISTRY }} steps: - name: Github Checkout # v4.1.1 uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - + - name: Set up QEMU + # v3.0.0 + uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 + - name: Set up Docker Buildx + # v3.2.0 + uses: docker/setup-buildx-action@2b51285047da1547ffb1b2203d8be4c0af6b1f20 - name: Log in to Docker Hub # v3.1.0 uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 @@ -37,6 +52,7 @@ jobs: with: context: . file: ./Dockerfile + platforms: linux/amd64,linux/arm64 push: true tags: | ${{ env.DOCKER_REGISTRY }}:${{ inputs.imageTag }} @@ -50,6 +66,8 @@ jobs: with: context: . file: ./Dockerfile + platforms: linux/amd64,linux/arm64 push: true tags: ${{ env.DOCKER_REGISTRY }}:${{ inputs.imageTag }} + labels: ${{ inputs.imageTag }} if: ${{ !inputs.isLatest }} diff --git a/.github/workflows/release_langtrace.yaml b/.github/workflows/release_langtrace.yaml new file mode 100644 index 00000000..45a914b5 --- /dev/null +++ b/.github/workflows/release_langtrace.yaml @@ -0,0 +1,66 @@ +name: Build & Release +run-name: "Release ${{ github.sha }}" + +on: + pull_request: + branches: + - main + types: + - closed + +jobs: + generate-version: + runs-on: ubuntu-latest + outputs: + new_version: ${{ steps.version.outputs.version }} + steps: + - name: Check labels and set version increment + id: set_increment + run: | + labels=$(echo "${{ toJson(github.event.pull_request.labels.*.name) }}") + if [[ $labels == *"major"* ]]; then + echo "increment=major" >> $GITHUB_OUTPUT + elif [[ $labels == *"minor"* ]]; then + echo "increment=minor" >> $GITHUB_OUTPUT + else + echo "increment=patch" >> $GITHUB_OUTPUT + fi + - name: Get next version + # 2023.10.2 + uses: reecetech/version-increment@71036b212bbdc100b48aae069870f10953433346 + id: version + with: + release_branch: main + use_api: true + scheme: semver + increment: ${{ steps.set_increment.outputs.increment }} + + build-docker: + uses: "./.github/workflows/build-docker.yaml" + secrets: inherit + needs: + - generate-version + with: + isLatest: true + imageTag: ${{ needs.generate-version.outputs.new_version }} + + publish: + runs-on: ubuntu-latest + needs: + - generate-version + - build-docker + permissions: + contents: write + steps: + - name: Github Checkout + # v4.1.1 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + + - name: Release + # v1.14.0 + uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 + with: + artifacts: "docker-compose.yaml" + tag: ${{ needs.generate-version.outputs.new_version }} + generateReleaseNotes: true + draft: false diff --git a/Dockerfile b/Dockerfile index 151f223d..f5aa40ae 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,13 @@ # Debian based node 21.6 image FROM node:21.6-bookworm +LABEL maintainer="Langtrace AI " +LABEL version="1.0" +LABEL description="Open source observability for your LLM applications." +LABEL url="https://langtrace.ai/" +LABEL vendor="Scale3Labs" +LABEL license="AGPL" + WORKDIR /app COPY . .