Release Che Dashboard #139
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
# | |
# Copyright (c) 2020-2024 Red Hat, Inc. | |
# This program and the accompanying materials are made | |
# available under the terms of the Eclipse Public License 2.0 | |
# which is available at https://www.eclipse.org/legal/epl-2.0/ | |
# | |
# SPDX-License-Identifier: EPL-2.0 | |
# | |
# Contributors: | |
# Red Hat, Inc. - initial API and implementation | |
# | |
name: Release Che Dashboard | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'The version that is going to be released. Should be in format 7.y.z' | |
required: true | |
default: '7.y.z' | |
forceRecreateTags: | |
description: If true, tags will be recreated. Use with caution | |
required: false | |
default: 'false' | |
env: | |
IMAGE: quay.io/eclipse/che-dashboard | |
jobs: | |
tag-release: | |
runs-on: ubuntu-22.04 | |
steps: | |
- | |
name: "Checkout Che Dashboard source code" | |
uses: actions/checkout@v4 | |
- | |
name: "Setup Node" | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "18" | |
- | |
name: "Install npm & lerna" | |
run: "npm install --global lerna" | |
- | |
name: Check existing tags | |
run: | | |
set +e | |
RECREATE_TAGS=${{ github.event.inputs.forceRecreateTags }} | |
VERSION=${{ github.event.inputs.version }} | |
EXISTING_TAG=$(git ls-remote --exit-code origin refs/tags/${VERSION}) | |
if [[ -n ${EXISTING_TAG} ]]; then | |
if [[ ${RECREATE_TAGS} == "true" ]]; then | |
echo "[INFO] Removing tag for ${VERSION} version. New tag will be recreated during release." | |
git push origin :$VERSION | |
else | |
echo "[ERROR] Cannot proceed with release - tag ${EXISTING_TAG} already exists." | |
exit 1 | |
fi | |
else | |
echo "[INFO] No existing tags detected for $VERSION" | |
fi | |
- | |
name: "Tag release" | |
run: | | |
git config --global user.name "Mykhailo Kuznietsov" | |
git config --global user.email "mkuznets@redhat.com" | |
git config --global pull.rebase true | |
export GITHUB_TOKEN=${{ secrets.CHE_BOT_GITHUB_TOKEN }} | |
/bin/bash make-release.sh --version ${{ github.event.inputs.version }} --tag-release | |
#- name: Create failure MM message | |
#if: ${{ failure() }} | |
#run: | | |
#echo "{\"text\":\":no_entry_sign: Che Dashboard ${{ github.event.inputs.version }} release has failed: https://github.com/eclipse/che-dashboard/actions/workflows/release.yml\"}" > mattermost.json | |
#- name: Create success MM message | |
#run: | | |
#echo "{\"text\":\":white_check_mark: Che Dashboard ${{ github.event.inputs.version }} has been released: https://quay.io/eclipse/che-dashboard:${{ github.event.inputs.version }}\"}" > mattermost.json | |
#- name: Send MM message | |
#if: ${{ success() }} || ${{ failure() }} | |
#uses: mattermost/action-mattermost-notify@1.1.0 | |
#env: | |
#MATTERMOST_WEBHOOK_URL: ${{ secrets.MATTERMOST_WEBHOOK_URL }} | |
#MATTERMOST_CHANNEL: eclipse-che-releases | |
#MATTERMOST_USERNAME: che-bot | |
build-images: | |
runs-on: ubuntu-22.04 | |
needs: tag-release | |
strategy: | |
fail-fast: false | |
matrix: | |
arch: [amd64,arm64] | |
outputs: | |
amd64: ${{ steps.result.outputs.amd64 }} | |
arm64: ${{ steps.result.outputs.arm64 }} | |
steps: | |
- | |
name: "Checkout Che Dashboard source code" | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.inputs.version }} | |
- | |
name: "Set up QEMU" | |
uses: docker/setup-qemu-action@v3 | |
- | |
name: "Set up Docker Buildx ${{ matrix.arch }}" | |
uses: docker/setup-buildx-action@v3 | |
- | |
name: "Docker quay.io Login" | |
uses: docker/login-action@v3 | |
with: | |
registry: quay.io | |
username: ${{ secrets.QUAY_USERNAME }} | |
password: ${{ secrets.QUAY_PASSWORD }} | |
- | |
name: "Build and push ${{ matrix.arch }}" | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./build/dockerfiles/Dockerfile | |
platforms: linux/${{ matrix.arch }} | |
push: true | |
provenance: false | |
tags: ${{ env.IMAGE }}:${{ github.event.inputs.version }}-${{ matrix.arch }} | |
- | |
id: result | |
name: "Build result outputs version" | |
if: ${{ success() }} | |
run: echo "${{ matrix.arch }}=${{ github.event.inputs.version }}-${{ matrix.arch }}" >> $GITHUB_OUTPUT | |
create-manifest: | |
needs: build-images | |
runs-on: ubuntu-22.04 | |
steps: | |
- | |
name: "Docker quay.io Login" | |
uses: docker/login-action@v3 | |
with: | |
registry: quay.io | |
username: ${{ secrets.QUAY_USERNAME }} | |
password: ${{ secrets.QUAY_PASSWORD }} | |
- | |
name: "Create and push manifest" | |
run: | | |
AMD64_VERSION="${{ needs['build-images'].outputs.amd64 }}" | |
ARM64_VERSION="${{ needs['build-images'].outputs.arm64 }}" | |
if [[ -z "$AMD64_VERSION" || \ | |
-z "$ARM64_VERSION" ]]; then | |
echo "[!] The job 'build-images' fails on some of the architectures. Can't create complete manifest."; | |
exit 1; | |
fi | |
AMEND="" | |
AMEND+=" --amend ${{ env.IMAGE }}:$AMD64_VERSION"; | |
AMEND+=" --amend ${{ env.IMAGE }}:$ARM64_VERSION"; | |
docker manifest create ${{ env.IMAGE }}:${{ github.event.inputs.version }} $AMEND | |
docker manifest push ${{ env.IMAGE }}:${{ github.event.inputs.version }} | |
- | |
id: result | |
name: "Manifest result" | |
if: ${{ success() }} | |
run: echo "Manifest was created and pushed successfully" | |