build platform #7
This file contains 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: Release | |
on: | |
push: | |
branches: [ "main" ] | |
tags: | |
- '*' | |
jobs: | |
go-unit-test: | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: 1.22.2 | |
- name: Test | |
run: make test | |
- uses: codecov/[email protected] | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos | |
files: ./cover.out # optional | |
flags: unittests # optional | |
name: codecov-umbrella # optional | |
fail_ci_if_error: true # optional (default = false) | |
verbose: true # optional (default = false) | |
docker-build: | |
runs-on: ubuntu-latest | |
needs: [go-unit-test] | |
if: startsWith(github.ref, 'refs/tags/v') | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login Github Container registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Docker meta Controller | |
id: controller_meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
ghcr.io/baizeai/kcover-controller | |
tags: | | |
type=semver,pattern={{raw}} | |
- name: Docker meta Agent | |
id: agent_meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
ghcr.io/baizeai/kcover-agent | |
tags: | | |
type=semver,pattern={{raw}} | |
- name: Build Image Controller | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
provenance: false | |
tags: ${{ steps.controller_meta.outputs.tags }} | |
labels: ${{ steps.controller_meta.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
file: docker/controller.Dockerfile | |
- name: Build Image Agent | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
provenance: false | |
tags: ${{ steps.agent_meta.outputs.tags }} | |
labels: ${{ steps.agent_meta.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
file: docker/agent.Dockerfile | |
publish-chart: | |
if: startsWith(github.ref, 'refs/tags/v') | |
needs: [ docker-build ] | |
permissions: | |
contents: write | |
env: | |
HELM_CHARTS_DIR: manifests/kcover | |
HELM_CHART_NAME: kcover | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install Helm | |
uses: azure/setup-helm@v3 | |
- name: Get the version | |
id: get_version | |
run: | | |
VERSION=${GITHUB_REF#refs/tags/} | |
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT | |
- name: Tag helm chart image | |
run: | | |
image_tag=${{ steps.get_version.outputs.VERSION }} | |
chart_version=${{ steps.get_version.outputs.VERSION }} | |
sed -i "s/latest/${image_tag}/g" $HELM_CHARTS_DIR/values.yaml | |
chart_smever=${chart_version#"v"} | |
sed -i "s/0.1.0/${chart_smever}/g" $HELM_CHARTS_DIR/Chart.yaml | |
- uses: getsentry/action-github-app-token@v2 | |
id: get_app_token | |
with: | |
app_id: ${{ secrets.APP_ID }} | |
private_key: ${{ secrets.APP_PRIVATE_KEY }} | |
- name: Sync Chart Repo | |
run: | | |
git config --global user.email "baize.ai[bot]@users.noreply.github.com" | |
git config --global user.name "baize.ai[bot]" | |
git clone https://x-access-token:${{ steps.get_app_token.outputs.token }}@github.com/BaizeAI/charts.git baize-charts | |
helm package $HELM_CHARTS_DIR --destination ./baize-charts/docs/ | |
helm repo index --url https://baizeai.github.io/charts ./baize-charts/docs/ | |
cd baize-charts/ | |
git add docs/ | |
chart_version=${{ steps.get_version.outputs.VERSION }} | |
chart_smever=${chart_version#"v"} | |
git commit -m "update kcover chart ${chart_smever}" | |
git push https://x-access-token:${{ steps.get_app_token.outputs.token }}@github.com/BaizeAI/charts.git |