Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 1 addition & 23 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,26 +97,4 @@ jobs:

export GITHUB_TOKEN=${{ secrets.CHE_BOT_GITHUB_TOKEN }}
./make-release.sh --version ${{ github.event.inputs.version}}
- name: Publish to npmjs
if: github.event.inputs.publishToNpmJs == 'true'
env:
NODE_AUTH_TOKEN: ${{secrets.CHE_NPM_AUTH_TOKEN}}
run: |
git checkout ${{ github.event.inputs.version}}
pushd tests/e2e >/dev/null || exit
npm ci && npm run tsc && npm publish
popd >/dev/null || exit
#- name: Create failure MM message
#if: ${{ failure() }}
#run: |
#echo "{\"text\":\":no_entry_sign: Che E2E Tests ${{ github.event.inputs.version }} release has failed: https://github.com/eclipse/che/actions/workflows/release.yml\"}" > mattermost.json
#- name: Create success MM message
#run: |
#echo "{\"text\":\":white_check_mark: Che E2E Tests image and generator ${{ github.event.inputs.version }} release job is complete: \n Performed tagging and container build of new image: https://quay.io/eclipse/che-e2e:${{ github.event.inputs.version }}. \n Published package to npmjs https://www.npmjs.com/package/@eclipse-che/che-e2e/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

47 changes: 33 additions & 14 deletions .github/workflows/typescript-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ name: Publish Next Che E2E Tests to npmjs

on:
workflow_dispatch:
inputs:
release:
description: 'set to true if publishing release build (as opposed to dev/next build)'
type: boolean
default: false
push:
branches:
- main
Expand All @@ -31,25 +36,39 @@ jobs:
- name: Clone source code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: publish
env:
NODE_AUTH_TOKEN: ${{secrets.CHE_NPM_AUTH_TOKEN}}
fetch-depth: 0
- name: Evaluate version of published artifacts
run: |
if [[ ${GITHUB_REF##*/} == "7."**".x" ]]; then
echo "[INFO] using ${GITHUB_REF##*/} tag"
DIST_TAG=next-${GITHUB_REF##*/}
if [[ github.event.inputs.release == 'true' ]]; then
echo "[INFO] Publishing release build
DIST_TAG=latest
else
echo "[INFO] using "next" tag"
DIST_TAG=next
"[INFO] Publishing next build:"
if [[ ${GITHUB_REF##*/} == "7."**".x" ]]; then
echo "[INFO] using ${GITHUB_REF##*/} tag"
DIST_TAG=next-${GITHUB_REF##*/}
else
echo "[INFO] using "next" tag"
DIST_TAG=next
fi
fi

if [[ github.event.inputs.release == 'true' ]]; then
VERSION=$(cat VERSION)
else
CURRENT_VERSION=$(sed -r 's/(.*)-next/\1/' ../../VERSION)
SHORT_SHA1=$(git rev-parse --short=7 HEAD)
NEW_VERSION="${VERSION}-next-${SHORT_SHA1}"
sed -i -r -e "s/(\"version\": )(\".*\")/\1\"$NEW_VERSION\"/" package.json
VERSION=$NEW_VERSION
fi

echo "Dist tag: $DIST_TAG, version - $VERSION"


- name: publish
run: |
cd tests/e2e
npm ci && npm run tsc

SHORT_SHA1=$(git rev-parse --short=7 HEAD)
CURRENT_VERSION=$(sed -r 's/(.*)-next/\1/' ../../VERSION)
NEW_VERSION="${CURRENT_VERSION}-next-${SHORT_SHA1}"
sed -i -r -e "s/(\"version\": )(\".*\")/\1\"$NEW_VERSION\"/" package.json

npm publish --tag $DIST_TAG
108 changes: 81 additions & 27 deletions make-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,27 @@ MAIN_BRANCH="main"
TMP=""
ISSUE_TEMPLATE_FILE=".github/ISSUE_TEMPLATE/bug_report.yml"

# Parameters
SET_RELEASE_VERSION=0
SET_NEXT_VERSION=0

UPDATE_ISSUE_TEMPLATE=0

BUILD_E2E_IMAGES=0
PUSH_E2E_IMAGE=0

BUILD_E2E_NPM=0
PUSH_E2E_NPM=0

while [[ "$#" -gt 0 ]]; do
case $1 in
'-v'|'--version') VERSION="$2"; shift 1;;
'-tmp'|'--use-tmp-dir') TMP=$(mktemp -d); shift 0;;
'--build-image') BUILD_E2E_ARTIFACTS=1; shift 0;;
'--push-image') PUSH_E2E_IMAGE=1; shift 0;;
'--build-npm') BUILD_E2E_NPM=1; shift 0;;
'--publish-npm') PUSH_E2E_NPM=1; shift 0;;
'--update-issue-template') UPDATE_ISSUE_TEMPLATE=1; shift 0;;
esac
shift 1
done
Expand All @@ -33,6 +50,23 @@ sed_in_place() {
fi
}

usage ()
{
echo "Usage: $0 --version [VERSION TO RELEASE]"
echo -e "Example: $0 --version v0.1.0\n";
}

resetChanges() {
local branch="$1"

echo "[INFO] Reset changes in ${branch} branch"

git reset --hard
git checkout "${branch}"
git fetch origin --prune
git pull origin "${branch}"
}

# Update the issue template with released version and add current latest as previous item
update_issue_template() {
local -r currentReleaseVersion=$1
Expand Down Expand Up @@ -98,24 +132,34 @@ bump_version () {
git checkout "${PR_BRANCH}"
git pull origin "${PR_BRANCH}"
git push origin "${PR_BRANCH}"
lastCommitComment="$(git log -1 --pretty=%B)"
gh pr create -f -B "${BUMP_BRANCH}" -H "${PR_BRANCH}"
fi
set -e
git checkout "${CURRENT_BRANCH}"
}

usage ()
{
echo "Usage: $0 --version [VERSION TO RELEASE]"
echo -e "Example: $0 --version v0.1.0\n";
bump_next_versions () {
# change VERSION file + commit change into ${BASEBRANCH} branch
if [[ "${BASEBRANCH}" != "${BRANCH}" ]]; then
# bump the y digit, if it is a major release
[[ $BRANCH =~ ^([0-9]+)\.([0-9]+)\.x ]] && BASE=${BASH_REMATCH[1]}; NEXT=${BASH_REMATCH[2]}; (( NEXT=NEXT+1 )) # for BRANCH=0.1.x, get BASE=0, NEXT=2
NEXT_VERSION_Y="${BASE}.${NEXT}.0-next"
bump_version "${NEXT_VERSION_Y}" "${BASEBRANCH}"
fi
# bump the z digit
[[ ${VERSION#v} =~ ^([0-9]+)\.([0-9]+)\.([0-9]+) ]] && BASE="${BASH_REMATCH[1]}.${BASH_REMATCH[2]}"; NEXT="${BASH_REMATCH[3]}"; (( NEXT=NEXT+1 )) # for VERSION=0.1.2, get BASE=0.1, NEXT=3
NEXT_VERSION_Z="${BASE}.${NEXT}-next"
bump_version "${NEXT_VERSION_Z}" "${BRANCH}"
}

if [[ ! ${VERSION} ]]; then
usage
exit 1
fi

set_release_version () {

}

# derive bugfix branch from version
BRANCH=${VERSION#v}
Expand All @@ -137,8 +181,6 @@ if [[ $TMP ]] && [[ -d $TMP ]]; then
cd "${REPO##*/}" || exit 1
fi

git remote show origin

# get sources from ${BASEBRANCH} branch
git fetch origin "${BASEBRANCH}":"${BASEBRANCH}" || true
git checkout "${BASEBRANCH}"
Expand Down Expand Up @@ -167,10 +209,17 @@ npm --no-git-tag-version version --allow-same-version "${VERSION}"
npm run prettier
popd >/dev/null || exit

docker build -t quay.io/eclipse/che-e2e:${VERSION} -f tests/e2e/build/dockerfiles/Dockerfile tests/e2e
docker tag quay.io/eclipse/che-e2e:${VERSION} quay.io/eclipse/che-e2e:latest
docker push quay.io/eclipse/che-e2e:${VERSION}
docker push quay.io/eclipse/che-e2e:latest
build_e2e_image ()
{
docker build -t quay.io/eclipse/che-e2e:${VERSION} -f tests/e2e/build/dockerfiles/Dockerfile tests/e2e
docker tag quay.io/eclipse/che-e2e:${VERSION} quay.io/eclipse/che-e2e:latest
}

push_e2e_image ()
{
docker push quay.io/eclipse/che-e2e:${VERSION}
docker push quay.io/eclipse/che-e2e:latest
}

# update template in the release tag
update_issue_template "${VERSION}" "${ISSUE_TEMPLATE_FILE}"
Expand All @@ -186,22 +235,27 @@ git push origin "${VERSION}"
git checkout "${BASEBRANCH}"

# update template in the branch
update_issue_template "${VERSION}" "${ISSUE_TEMPLATE_FILE}"

# change VERSION file + commit change into ${BASEBRANCH} branch
if [[ "${BASEBRANCH}" != "${BRANCH}" ]]; then
# bump the y digit, if it is a major release
[[ $BRANCH =~ ^([0-9]+)\.([0-9]+)\.x ]] && BASE=${BASH_REMATCH[1]}; NEXT=${BASH_REMATCH[2]}; (( NEXT=NEXT+1 )) # for BRANCH=0.1.x, get BASE=0, NEXT=2
NEXT_VERSION_Y="${BASE}.${NEXT}.0-next"
bump_version "${NEXT_VERSION_Y}" "${BASEBRANCH}"
if [[ ${UPDATE_ISSUE_TEMPLATE} -eq 1 ]]; then
update_issue_template "${VERSION}" "${ISSUE_TEMPLATE_FILE}"
fi
# bump the z digit
[[ ${VERSION#v} =~ ^([0-9]+)\.([0-9]+)\.([0-9]+) ]] && BASE="${BASH_REMATCH[1]}.${BASH_REMATCH[2]}"; NEXT="${BASH_REMATCH[3]}"; (( NEXT=NEXT+1 )) # for VERSION=0.1.2, get BASE=0.1, NEXT=3
NEXT_VERSION_Z="${BASE}.${NEXT}-next"
bump_version "${NEXT_VERSION_Z}" "${BRANCH}"

# cleanup tmp dir
if [[ $TMP ]] && [[ -d $TMP ]]; then
popd > /dev/null || exit
rm -fr "$TMP"
if [[ ${BUMP_NEXT_VERSION} -eq 1 ]]; then
bump_next_versions
fi

cleanup_tmp_dir ()
{
# cleanup tmp dir
if [[ $TMP ]] && [[ -d $TMP ]]; then
popd > /dev/null || exit
rm -fr "$TMP"
fi
}

set_release_branch
set_release_version
build_e2e_artifacts
push_e2e_artifacts
build_npm_artifacts
bump_next_versions
cleanup_tmp_dir
Loading