From 8cf025786a67c9fb738148ae8a9c759430ed4627 Mon Sep 17 00:00:00 2001 From: Mykhailo Kuznietsov Date: Tue, 29 Aug 2023 22:30:48 +0300 Subject: [PATCH] feat: Add devworkspace-generator to Che release cycle (#751) Signed-off-by: Mykhailo Kuznietsov --- .../devworkspace-generator-release.yml | 84 +++++++++++++++++++ .github/workflows/release.yml | 6 +- make-release.sh | 14 ++-- tools/devworkspace-generator/package.json | 2 +- 4 files changed, 97 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/devworkspace-generator-release.yml diff --git a/.github/workflows/devworkspace-generator-release.yml b/.github/workflows/devworkspace-generator-release.yml new file mode 100644 index 000000000..dcd6b1f3f --- /dev/null +++ b/.github/workflows/devworkspace-generator-release.yml @@ -0,0 +1,84 @@ +# +# Copyright (c) 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 Devworkspace Generator + +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' + +jobs: + build: + name: Create Che Devfile Registry Release + runs-on: ubuntu-22.04 + steps: + - + name: "Checkout source code" + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - + 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: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT + - uses: actions/cache@v3 + id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: yarn-${{ hashFiles('tools/devworkspace-generator/yarn.lock') }} + restore-keys: yarn- + - name: publish DevWorkspace Generator + env: + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} + run: | + cd tools/devworkspace-generator + sed -i -r -e "s/(\"version\": )(\".*\")/\1\"${thisVERSION}\"/" package.json + yarn + yarn compile + npm publish --tag latest + # che-22407 - mattermost steps are commented out, until we find a replacement for it + # - name: Create failure MM message + # if: ${{ failure() }} + # run: | + # echo "{\"text\":\":no_entry_sign: Che Devworkspace Generator ${{ github.event.inputs.version }} release has failed: https://github.com/eclipse-che/che-devfile-registry/actions/workflows/release.yml\"}" > mattermost.json + # - name: Create success MM message + # run: | + # echo "{\"text\":\":white_check_mark: Che Devworkspace Generator ${{ github.event.inputs.version }} has been released: https://www.npmjs.com/package/@eclipse-che/che-devworkspace-generator/v/${{ 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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5de3f0553..c124d67b2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,5 +1,5 @@ # -# Copyright (c) 2020-2021 Red Hat, Inc. +# 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/ @@ -91,8 +91,8 @@ jobs: export GITHUB_TOKEN=${{ secrets.CHE_BOT_GITHUB_TOKEN }} ./make-release.sh --version ${{ github.event.inputs.version}} --trigger-release - - - name: Generate devfiles with registryUrls and publish to GH pages + - + name: Generate devfiles with registryUrls and publish to GH pages if: github.event.inputs.publishDevfilesToGhPages == 'true' env: GITHUB_TOKEN: ${{ secrets.CHE_BOT_GITHUB_TOKEN }} diff --git a/make-release.sh b/make-release.sh index 3ae589f90..d540a7930 100755 --- a/make-release.sh +++ b/make-release.sh @@ -166,11 +166,13 @@ fetchAndCheckout () git fetch origin "${bBRANCH}:${bBRANCH}"; git checkout "${bBRANCH}" } -# unlike in che-plugin-registry, here we just need to update the VERSION file -updateVersionFile () { +updateVersion () { thisVERSION="$1" - # update VERSION file with VERSION or NEWVERSION + # update main VERSION file of devfile registry echo "${thisVERSION}" > VERSION + # update version of devworkspace-generator in package.json + jq ".\"dependencies\".\"@eclipse-che/che-devworkspace-generator\" = \"${thisVERSION}\"" tools/devworkspace-generator/package.json > tools/devworkspace-generator/package.json.update + mv tools/devworkspace-generator/package.json.update tools/devworkspace-generator/package.json } if [[ ! ${VERSION} ]]; then @@ -240,7 +242,9 @@ commitChangeOrCreatePR() } # bump VERSION file to VERSION -updateVersionFile "${VERSION}" +updateVersion "${VERSION}" +# update build scripts to reference release version of devworkspace generator +sed -i -r -e "s/CHE_DEVWORKSPACE_GENERATOR_VERSION=next/CHE_DEVWORKSPACE_GENERATOR_VERSION=${VERSION}/" build/scripts/generate_devworkspace_templates.sh # commit change into branch commitChangeOrCreatePR "${VERSION}" "${BRANCH}" "pr-${BRANCH}-to-${VERSION}" @@ -271,7 +275,7 @@ else fi # bump VERSION file to NEXTVERSION -updateVersionFile "${NEXTVERSION}" +updateVersion "${NEXTVERSION}" commitChangeOrCreatePR "${NEXTVERSION}" "${BASEBRANCH}" "pr-${BASEBRANCH}-to-${NEXTVERSION}" # cleanup tmp dir diff --git a/tools/devworkspace-generator/package.json b/tools/devworkspace-generator/package.json index ea382d263..8704789ea 100644 --- a/tools/devworkspace-generator/package.json +++ b/tools/devworkspace-generator/package.json @@ -1,6 +1,6 @@ { "name": "@eclipse-che/che-devworkspace-generator", - "version": "0.0.1", + "version": "7.69.0", "private": false, "description": "Generates DevWorkspaces by transforming existing devfiles", "main": "lib/entrypoint.js",