Skip to content

Release Che Plugin Registry #133

Release Che Plugin Registry

Release Che Plugin Registry #133

Workflow file for this run

#
# Copyright (c) 2020-2023 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
#
name: Release Che Plugin Registry
on:
workflow_dispatch:
inputs:
version:
description: 'release version in format 7.y.z'
required: true
forceRecreateTags:
description: If true, tags will be recreated. Use with caution
required: false
default: 'false'
performRelease:
description: If true, release will be performed. If false, it will pull the release image from quay
required: true
default: 'true'
publishToGhPages:
description: If true, image will be published to Github Pages.
default: 'true'
publishToNpmJs:
description: If true, image will be published to npmjs.
required: false
default: 'true'
jobs:
release-build-publish:
runs-on: ubuntu-22.04
steps:
- name: Clone source code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Set up environment
run: |
python -m pip install --upgrade pip
pip install yq
python --version
pip --version
yq --version
- name: 'setup nodejs'
uses: actions/setup-node@v3
with:
node-version: '16'
registry-url: 'https://registry.npmjs.org'
scope: '@eclipse-che'
- name: Check existing tags
if: ${{ github.event.inputs.performRelease == 'true' }}
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: Login to Quay.io
uses: azure/docker-login@v1
with:
login-server: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Login to Docker Hub
uses: azure/docker-login@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
name: Cache yarn dependencies
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Perform checkout & docker pull
if: ${{ github.event.inputs.performRelease == 'false' }}
run: |
git checkout ${{ github.event.inputs.version}}
docker pull quay.io/eclipse/che-plugin-registry:${{ github.event.inputs.version}}
echo MM_MESSAGE_APPEND='${{ env.MM_MESSAGE_APPEND }} \n Pulled existing image from https://quay.io/eclipse/che-plugin-registry:${{ github.event.inputs.version }}.' >> $GITHUB_ENV
- name: Perform release
if: ${{ github.event.inputs.performRelease == 'true' }}
run: |
git config --global user.name "Mykhailo Kuznietsov"
git config --global user.email "mkuznets@redhat.com"
export GITHUB_TOKEN=${{ secrets.CHE_BOT_GITHUB_TOKEN }}
./make-release.sh --version ${{ github.event.inputs.version}} --trigger-release
echo MM_MESSAGE_APPEND='${{ env.MM_MESSAGE_APPEND }} \n Performed tagging and container build of new image https://quay.io/eclipse/che-plugin-registry:${{ github.event.inputs.version }}.' >> $GITHUB_ENV
- name: Prepare mattermost message
run:
echo "{\"text\":\"Release has been performed\"}" > mattermost.json
- name: Extract content for publishing
run: |
docker create --name pluginRegistry quay.io/eclipse/che-plugin-registry:${{ github.event.inputs.version}} sh
mkdir content
docker cp pluginRegistry:/var/www/html/v3 content/v3
docker rm -f pluginRegistry
cp content/v3/plugins/index.json content/index.json
- name: Publish to gh-pages
if: ${{ github.event.inputs.publishToGhPages == 'true' }}
env:
GITHUB_TOKEN: ${{ secrets.CHE_BOT_GITHUB_TOKEN }}
VERSION_DIR: ${{ github.event.inputs.version}}
run: |
export BUILD_DIR="$PWD/content"
export GH_PAGES_DIR="$PWD/gh-pages"
./build/dev/publish-plugin-registry-to-gh-pages.sh
echo MM_MESSAGE_APPEND='${{ env.MM_MESSAGE_APPEND }} \n Published plugin registry to GitHub Pages https://github.com/eclipse-che/che-plugin-registry/tree/gh-pages/${{ github.event.inputs.version }}.' >> $GITHUB_ENV
- name: publish to npmjs
if: ${{ github.event.inputs.publishToNpmJs == 'true' }}
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
run: |
cd ${GITHUB_WORKSPACE}
BUILDER=docker SKIP_FORMAT=true SKIP_LINT=true SKIP_TEST=true ./build.sh --tag "${{ github.event.inputs.version}}"
cd tools/build
npm publish --tag latest
echo MM_MESSAGE_APPEND='${{ env.MM_MESSAGE_APPEND }} \n Published package to npmjs https://www.npmjs.com/package/@eclipse-che/plugin-registry-generator/v/${{ github.event.inputs.version }}.' >> $GITHUB_ENV
- name: Create failure MM message
if: ${{ failure() }}
run: |
echo "{\"text\":\":no_entry_sign: Che Plugin Registry image and generator ${{ github.event.inputs.version }} release has failed: https://github.com/eclipse-che/che-plugin-registry/actions/workflows/release.yml. ${MM_MESSAGE_APPEND}\"}" > mattermost.json
- name: Create success MM message
run: |
echo "{\"text\":\":white_check_mark: Che Plugin Registry image and generator ${{ github.event.inputs.version }} release job is complete: ${MM_MESSAGE_APPEND}\"}" > 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