Skip to content

Prepare and publish release #1

Prepare and publish release

Prepare and publish release #1

name: Prepare and publish release
on:
workflow_dispatch:
inputs:
version:
description: 'Version for the release, semver, NO "v" prefix'
required: true
type: string
jobs:
release:
name: Prepare and publish release
runs-on: ubuntu-latest
environment:
name: k8s-operator
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Log in to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- 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: 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.opster.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 "$GITHUB_ACTOR@users.noreply.github.com"
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:
RELEASE_VERSION: ${{ inputs.version }}
run: |
cd opensearch-operator
export IMG=ghcr.io/maibornwolff/opensearch-operator:$RELEASE_VERSION
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 helm chart
uses: stefanprodan/helm-gh-pages@master
with:
charts_dir: charts/
token: ${{ secrets.GITHUB_TOKEN }}
- 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