mirror of
https://github.com/onyx-dot-app/onyx.git
synced 2026-10-22 11:22:49 -05:00
206 lines
7.1 KiB
YAML
206 lines
7.1 KiB
YAML
name: Release CLI
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- "cli/v*.*.*"
|
|
|
|
jobs:
|
|
pypi:
|
|
runs-on: ubuntu-latest
|
|
environment:
|
|
name: release-cli
|
|
permissions:
|
|
id-token: write
|
|
timeout-minutes: 10
|
|
steps:
|
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6
|
|
with:
|
|
persist-credentials: false
|
|
- uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # ratchet:astral-sh/setup-uv@v8.1.0
|
|
with:
|
|
enable-cache: false
|
|
version: "0.9.9"
|
|
- run: |
|
|
for goos in linux windows darwin; do
|
|
for goarch in amd64 arm64; do
|
|
GOOS="$goos" GOARCH="$goarch" uv build --wheel
|
|
done
|
|
done
|
|
working-directory: cli
|
|
- run: uv publish
|
|
working-directory: cli
|
|
|
|
docker-amd64:
|
|
runs-on:
|
|
- runs-on
|
|
- runner=2cpu-linux-x64
|
|
- run-id=${{ github.run_id }}-cli-amd64
|
|
environment: deploy
|
|
permissions:
|
|
id-token: write
|
|
timeout-minutes: 30
|
|
outputs:
|
|
digest: ${{ steps.build.outputs.digest }}
|
|
env:
|
|
REGISTRY_IMAGE: onyxdotapp/onyx-cli
|
|
steps:
|
|
- uses: runs-on/action@d141ef83eb66d096ce8afc767e09115a65c63b60
|
|
|
|
- name: Checkout
|
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Configure AWS credentials
|
|
uses: aws-actions/configure-aws-credentials@ec61189d14ec14c8efccab744f656cffd0e33f37 # ratchet:aws-actions/configure-aws-credentials@v6.1.0
|
|
with:
|
|
role-to-assume: ${{ secrets.AWS_OIDC_ROLE_ARN }}
|
|
aws-region: us-east-2
|
|
|
|
- name: Get AWS Secrets
|
|
uses: aws-actions/aws-secretsmanager-get-secrets@a9a7eb4e2f2871d30dc5b892576fde60a2ecc802 # ratchet:aws-actions/aws-secretsmanager-get-secrets@v2.0.10
|
|
with:
|
|
secret-ids: |
|
|
DOCKER_USERNAME, deploy/docker-username
|
|
DOCKER_TOKEN, deploy/docker-token
|
|
parse-json-secrets: true
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # ratchet:docker/setup-buildx-action@v4
|
|
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121
|
|
with:
|
|
username: ${{ env.DOCKER_USERNAME }}
|
|
password: ${{ env.DOCKER_TOKEN }}
|
|
|
|
- name: Build and push AMD64
|
|
id: build
|
|
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # ratchet:docker/build-push-action@v7
|
|
with:
|
|
context: ./cli
|
|
file: ./cli/Dockerfile
|
|
platforms: linux/amd64
|
|
cache-from: type=registry,ref=${{ env.REGISTRY_IMAGE }}:latest
|
|
cache-to: type=inline
|
|
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
|
|
|
|
docker-arm64:
|
|
runs-on:
|
|
- runs-on
|
|
- runner=2cpu-linux-arm64
|
|
- run-id=${{ github.run_id }}-cli-arm64
|
|
environment: deploy
|
|
permissions:
|
|
id-token: write
|
|
timeout-minutes: 30
|
|
outputs:
|
|
digest: ${{ steps.build.outputs.digest }}
|
|
env:
|
|
REGISTRY_IMAGE: onyxdotapp/onyx-cli
|
|
steps:
|
|
- uses: runs-on/action@d141ef83eb66d096ce8afc767e09115a65c63b60
|
|
|
|
- name: Checkout
|
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Configure AWS credentials
|
|
uses: aws-actions/configure-aws-credentials@ec61189d14ec14c8efccab744f656cffd0e33f37 # ratchet:aws-actions/configure-aws-credentials@v6.1.0
|
|
with:
|
|
role-to-assume: ${{ secrets.AWS_OIDC_ROLE_ARN }}
|
|
aws-region: us-east-2
|
|
|
|
- name: Get AWS Secrets
|
|
uses: aws-actions/aws-secretsmanager-get-secrets@a9a7eb4e2f2871d30dc5b892576fde60a2ecc802 # ratchet:aws-actions/aws-secretsmanager-get-secrets@v2.0.10
|
|
with:
|
|
secret-ids: |
|
|
DOCKER_USERNAME, deploy/docker-username
|
|
DOCKER_TOKEN, deploy/docker-token
|
|
parse-json-secrets: true
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # ratchet:docker/setup-buildx-action@v4
|
|
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121
|
|
with:
|
|
username: ${{ env.DOCKER_USERNAME }}
|
|
password: ${{ env.DOCKER_TOKEN }}
|
|
|
|
- name: Build and push ARM64
|
|
id: build
|
|
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # ratchet:docker/build-push-action@v7
|
|
with:
|
|
context: ./cli
|
|
file: ./cli/Dockerfile
|
|
platforms: linux/arm64
|
|
cache-from: type=registry,ref=${{ env.REGISTRY_IMAGE }}:latest
|
|
cache-to: type=inline
|
|
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
|
|
|
|
merge-docker:
|
|
needs:
|
|
- docker-amd64
|
|
- docker-arm64
|
|
runs-on:
|
|
- runs-on
|
|
- runner=2cpu-linux-x64
|
|
- run-id=${{ github.run_id }}-cli-merge
|
|
environment: deploy
|
|
permissions:
|
|
id-token: write
|
|
timeout-minutes: 10
|
|
env:
|
|
REGISTRY_IMAGE: onyxdotapp/onyx-cli
|
|
steps:
|
|
- uses: runs-on/action@d141ef83eb66d096ce8afc767e09115a65c63b60
|
|
|
|
- name: Configure AWS credentials
|
|
uses: aws-actions/configure-aws-credentials@ec61189d14ec14c8efccab744f656cffd0e33f37 # ratchet:aws-actions/configure-aws-credentials@v6.1.0
|
|
with:
|
|
role-to-assume: ${{ secrets.AWS_OIDC_ROLE_ARN }}
|
|
aws-region: us-east-2
|
|
|
|
- name: Get AWS Secrets
|
|
uses: aws-actions/aws-secretsmanager-get-secrets@a9a7eb4e2f2871d30dc5b892576fde60a2ecc802 # ratchet:aws-actions/aws-secretsmanager-get-secrets@v2.0.10
|
|
with:
|
|
secret-ids: |
|
|
DOCKER_USERNAME, deploy/docker-username
|
|
DOCKER_TOKEN, deploy/docker-token
|
|
parse-json-secrets: true
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # ratchet:docker/setup-buildx-action@v4
|
|
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121
|
|
with:
|
|
username: ${{ env.DOCKER_USERNAME }}
|
|
password: ${{ env.DOCKER_TOKEN }}
|
|
|
|
- name: Create and push manifest
|
|
env:
|
|
AMD64_DIGEST: ${{ needs.docker-amd64.outputs.digest }}
|
|
ARM64_DIGEST: ${{ needs.docker-arm64.outputs.digest }}
|
|
TAG: ${{ github.ref_name }}
|
|
run: |
|
|
SANITIZED_TAG="${TAG#cli/}"
|
|
IMAGES=(
|
|
"${REGISTRY_IMAGE}@${AMD64_DIGEST}"
|
|
"${REGISTRY_IMAGE}@${ARM64_DIGEST}"
|
|
)
|
|
|
|
if [[ "$TAG" =~ ^cli/v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
|
docker buildx imagetools create \
|
|
-t "${REGISTRY_IMAGE}:${SANITIZED_TAG}" \
|
|
-t "${REGISTRY_IMAGE}:latest" \
|
|
"${IMAGES[@]}"
|
|
else
|
|
docker buildx imagetools create \
|
|
-t "${REGISTRY_IMAGE}:${SANITIZED_TAG}" \
|
|
"${IMAGES[@]}"
|
|
fi
|