Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Prepare and publish release #2

Prepare and publish release

Prepare and publish release #2

name: Prepare and publish release
on:
workflow_dispatch:
inputs:
version:
description: 'Version for the release, semver, NO "v" prefix, semver x.y.z'
required: true
type: string
jobs:
release:
name: Prepare and publish release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup go
uses: actions/setup-go@v3
with:
go-version: "1.19"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Run tests
run: |
# Run test suite to make sure we have a functional commit
cd opensearch-operator
make manifests test
cd ..
- name: Prepare helm chart
run: |
# Copy CRDs to chart to make sure they are identical
cp opensearch-operator/config/crd/bases/opensearch.eliatra.io_*.yaml charts/opensearch-operator/files/
# Set versions in helm chart
sed -i -e 's/^appVersion:.*/appVersion: '$RELEASE_VERSION'/' charts/opensearch-operator/Chart.yaml
sed -i -e 's/^version:.*/version: '$RELEASE_VERSION'/' charts/opensearch-operator/Chart.yaml
sed -i -e 's/^appVersion:.*/appVersion: '$RELEASE_VERSION'/' charts/opensearch-cluster/Chart.yaml
sed -i -e 's/^version:.*/version: '$RELEASE_VERSION'/' charts/opensearch-cluster/Chart.yaml
# Commit changes
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
git add charts
if git commit -m "Prepare for release $RELEASE_VERSION"; then
git push origin main
fi
# Create tag, this will not trigger the other release pipeline
git tag v$RELEASE_VERSION
git push --tags
env:
RELEASE_VERSION: ${{ inputs.version }}
- name: Build and Push docker image
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_VERSION: ${{ inputs.version }}
run: |
cd opensearch-operator
export IMG=docker.io/eliatra/eoko:$RELEASE_VERSION
echo $IMG
docker buildx build -t $IMG --platform="linux/amd64,linux/arm,linux/arm64" . -f Dockerfile --push
cd ..
- name: Install Helm
uses: azure/setup-helm@v1
with:
version: v3.8.1
- name: Publish opensearch-cluster helm chart
uses: appany/[email protected]
with:
name: eoko-cluster
path: charts/opensearch-cluster
repository: ${{ secrets.DOCKERHUB_USERNAME }}
tag: ${{ github.ref }}
registry: docker.io
registry_username: ${{ secrets.DOCKERHUB_USERNAME }}
registry_password: ${{ secrets.DOCKERHUB_TOKEN }}
update_dependencies: 'true' # Defaults to false
- name: Publish opensearch-operator helm chart
uses: appany/[email protected]
with:
name: eoko
path: charts/opensearch-operator
repository: ${{ secrets.DOCKERHUB_USERNAME }}
tag: ${{ github.ref }}
registry: docker.io
registry_username: ${{ secrets.DOCKERHUB_USERNAME }}
registry_password: ${{ secrets.DOCKERHUB_TOKEN }}
update_dependencies: 'true' # Defaults to false
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ inputs.version }}
release_name: ${{ inputs.version }}
draft: true
prerelease: false