Skip to content

chore: autopublish 2024-11-11T11:19:25Z #79

chore: autopublish 2024-11-11T11:19:25Z

chore: autopublish 2024-11-11T11:19:25Z #79

# This workflow is meant to:
# 1. Create a new git tag
# 2. Create a new release artifact in github repo
# 3. Create a new helm chart package and upload it as a release artifact
#
# This is meant to ONLY happen when VERSION file is updated and pushed to main branch
# and meant to be used as a mechanism to communicate sets of changes to the public.
# Since we deploy in a CD way, the way we release and communicate differs internally from externally
name: Tag and public artifact release
env:
API_VERSION: 1
on:
push:
branches:
- main
paths:
- 'VERSION'
jobs:
release:
name: Tag and release
runs-on: ubuntu-24.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Calculate short sha
id: env-vars
run: |-
HASH=`git rev-parse --short HEAD`
echo "short_sha=$HASH" >> $GITHUB_OUTPUT
- name: Get version
id: version_step
run: |-
VERSION=`cat VERSION`
HASH=`git rev-parse --short HEAD`
echo "version_number=$VERSION" >> $GITHUB_OUTPUT
echo "hash=$HASH" >> $GITHUB_OUTPUT
- name: Update image version
uses: mikefarah/yq@master
with:
cmd: yq -i '.imageVersion = "${{ steps.version_step.outputs.hash }}"' 'charts/nucliadb/values.yaml'
- name: Set chart version
uses: mikefarah/yq@master
with:
cmd: yq -i '.version = "${{ steps.version_step.outputs.version_number }}"' 'charts/nucliadb/Chart.yaml'
- name: Set chart app version
uses: mikefarah/yq@master
with:
cmd: yq -i '.appVersion = "${{ steps.version_step.outputs.version_number }}"' 'charts/nucliadb/Chart.yaml'
- name: Install Helm
uses: azure/setup-helm@v4
with:
version: v3.15.3
- name: Build helm package
run: |-
helm lint charts/nucliadb
helm package charts/nucliadb
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
custom_tag: ${{ steps.version_step.outputs.version_number }}
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.version_step.outputs.version_number }}
release_name: Release ${{ steps.version_step.outputs.version_number }}
draft: false
prerelease: false
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./nucliadb-${{ steps.version_step.outputs.version_number }}.tgz
asset_name: nucliadb-chart.tgz
asset_content_type: application/tar+gzip
tag-stable:
name: Tag current latest as stable
runs-on: ubuntu-24.04
if: github.event_name == 'push'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Get version
id: version_step
run: |-
VERSION=`cat VERSION`
echo "version_number=$VERSION" >> $GITHUB_OUTPUT
- name: Tag it
run: |-
docker pull nuclia/nucliadb:latest
docker tag nuclia/nucliadb:latest nuclia/nucliadb:stable
docker tag nuclia/nucliadb:latest nuclia/nucliadb:${{ steps.version_step.outputs.version_number }}
docker push nuclia/nucliadb:stable
docker push nuclia/nucliadb:${{ steps.version_step.outputs.version_number }}
docs:
name: 'Upload API specs'
runs-on: ubuntu-24.04
if: github.event_name == 'push'
steps:
- name: Generate a token
id: app-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.GHAPP_ID_NUCLIABOT }}
private-key: ${{ secrets.PK_GHAPP_NUCLIABOT }}
owner: nuclia
- name: Checkout
uses: actions/checkout@v4
- name: Set up PDM
uses: pdm-project/setup-pdm@v4
with:
python-version: "3.12.5"
cache: "true"
- name: Install nucliadb
run: pdm sync -d --clean --no-editable
- name: Setup gcloud CLI
uses: google-github-actions/auth@v2
with:
credentials_json: '${{ secrets.GCP_CREDENTIALS }}'
- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v1'
- name: Upload docs
run: |
mkdir -p /tmp/openapi
source .venv/bin/activate
nucliadb-extract-openapi-reader /tmp/openapi/nucliadb-reader.json $API_VERSION $GITHUB_SHA
nucliadb-extract-openapi-writer /tmp/openapi/nucliadb-writer.json $API_VERSION $GITHUB_SHA
nucliadb-extract-openapi-search /tmp/openapi/nucliadb-search.json $API_VERSION $GITHUB_SHA
gsutil copy /tmp/openapi/nucliadb-reader.json gs://stashify-docs/api/nucliadb/v$API_VERSION/nucliadb-reader/spec.json
gsutil copy /tmp/openapi/nucliadb-writer.json gs://stashify-docs/api/nucliadb/v$API_VERSION/nucliadb-writer/spec.json
gsutil copy /tmp/openapi/nucliadb-search.json gs://stashify-docs/api/nucliadb/v$API_VERSION/nucliadb-search/spec.json
- name: Trigger doc update
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ steps.app-token.outputs.token }}
repository: nuclia/docs
event-type: merge