Skip to content

Create Release

Create Release #889

# GitHub workflow for createing release.
# Trigger release branch should be merge into main
# TODO add e2e/smoke test for autogen configuration
name: Create Release.
on:
pull_request:
types: [ closed ]
workflow_dispatch:
inputs:
version:
description: "Release version (Be sure `Release-branch` is successful):"
required: true
jobs:
create-release:
name: Create Release
if: ${{ (github.event.pull_request.merged == true && startsWith(github.head_ref, 'release/')) || github.event.inputs.version != '' }}
runs-on: ubuntu-latest
env:
IMAGE_REPOSITORY: mongodb/mongodb-atlas-kubernetes-operator
steps:
- name: Print Env and Get version
id: tag
env:
BRANCH: ${{ github.head_ref }}
VERSION: ${{ github.event.inputs.version }}
run: |
version=$VERSION
if [[ "$version" == "" ]]; then
version=$(echo $BRANCH | awk -F '/' '{print $2}')
fi
echo "VERSION:$version"
tag="v${version}"
certified_version="${version}-certified"
echo "version=$version" >> $GITHUB_OUTPUT
echo "tag=$tag" >> $GITHUB_OUTPUT
echo "certified_version=$certified_version" >> $GITHUB_OUTPUT
- name: Trigger helm post release workflow
# Please provide a token with write access to the repository into secrets.HELM_REPO_TOKEN
run: |
curl \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.HELM_REPO_TOKEN }}"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/mongodb/helm-charts/actions/workflows/post-atlas-operator-release.yaml/dispatches \
-d '{"ref":"main","inputs":{"version":"'"${{ steps.tag.outputs.version }}"'"}}'
- name: Check out code
uses: actions/[email protected]
with:
submodules: true
fetch-depth: 0
- name: Build and Push image
uses: ./.github/actions/build-push-image
with:
repository: ${{ env.IMAGE_REPOSITORY }}
version: ${{ steps.tag.outputs.version }}
platforms: linux/amd64,linux/arm64
docker_username: ${{ secrets.DOCKER_USERNAME }}
docker_password: ${{ secrets.DOCKER_PASSWORD }}
push_to_quay: true
quay_username: mongodb+mongodb_atlas_kubernetes
quay_password: ${{ secrets.QUAY_PASSWORD }}
- name: Build and Push certified image
uses: ./.github/actions/build-push-image
with:
repository: ${{ env.IMAGE_REPOSITORY }}
version: ${{ steps.tag.outputs.certified_version }}
platforms: linux/amd64,linux/arm64
docker_username: ${{ secrets.DOCKER_USERNAME }}
docker_password: ${{ secrets.DOCKER_PASSWORD }}
push_to_quay: true
quay_username: mongodb+mongodb_atlas_kubernetes
quay_password: ${{ secrets.QUAY_PASSWORD }}
- name: Certify Openshift images
uses: ./.github/actions/certify-openshift-images
with:
repository: ${{ env.IMAGE_REPOSITORY }}
version: ${{ steps.tag.outputs.certified_version }}
quay_password: ${{ secrets.QUAY_PASSWORD }}
rhcc_token: ${{ secrets.RH_CERTIFICATION_PYXIS_API_TOKEN }}
rhcc_project: ${{ secrets.RH_CERTIFICATION_OSPID }}
- name: Create configuration package
run: |
set -x
tar czvf atlas-operator-all-in-one-${{ steps.tag.outputs.version }}.tar.gz -C deploy all-in-one.yaml
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.tag.outputs.tag }}
release_name: ${{ steps.tag.outputs.tag }}
body_path: docs/release-notes/release-notes.md
draft: true
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: ./atlas-operator-all-in-one-${{ steps.tag.outputs.version }}.tar.gz
asset_name: atlas-operator-all-in-one-${{ steps.tag.outputs.version }}.tar.gz
asset_content_type: application/tgz
# TODO RedHad autopublish does not work. need to push bundles manually for now