diff --git a/.github/workflows/devworkspace-generator-publish-next.yml b/.github/workflows/devworkspace-generator-publish-next.yml deleted file mode 100644 index dfab93b..0000000 --- a/.github/workflows/devworkspace-generator-publish-next.yml +++ /dev/null @@ -1,57 +0,0 @@ -# -# Copyright (c) 2022-2024 -# 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 next version - -on: - push: - branches: - - main - - 7.**.x - -jobs: - publish: - runs-on: ubuntu-22.04 - steps: - - uses: actions/setup-node@v4 - with: - node-version: '20' - registry-url: 'https://registry.npmjs.org' - scope: '@eclipse-che' - - name: Clone source code - uses: actions/checkout@v4 - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT - - uses: actions/cache@v4 - id: yarn-cache - with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: yarn-${{ hashFiles('yarn.lock') }} - restore-keys: yarn- - - name: publish - env: - NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} - run: | - 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 - - yarn - yarn compile - SHORT_SHA1=$(git rev-parse --short=7 HEAD) - CURRENT_VERSION=$(jq -r '.version' package.json) - NEW_VERSION="${CURRENT_VERSION}-${SHORT_SHA1}" - echo New version is ${NEW_VERSION} - sed -i -r -e "s/(\"version\": )(\".*\")/\1\"$NEW_VERSION\"/" package.json - npm publish --tag $DIST_TAG diff --git a/.github/workflows/devworkspace-generator-release.yml b/.github/workflows/devworkspace-generator-release.yml deleted file mode 100644 index 3508ea6..0000000 --- a/.github/workflows/devworkspace-generator-release.yml +++ /dev/null @@ -1,78 +0,0 @@ -# -# Copyright (c) 2022-2024 -# 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 Devworkspace Generator Release - runs-on: ubuntu-22.04 - steps: - - uses: actions/setup-node@v4 - with: - node-version: '20' - registry-url: 'https://registry.npmjs.org' - scope: '@eclipse-che' - - name: "Checkout source code" - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Set up environment - run: | - sudo apt-get update -y || true - sudo apt-get -y -q install hub - hub --version - - 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: Get yarn cache directory path - id: yarn-cache-dir-path - run: | - echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT - - uses: actions/cache@v4 - id: yarn-cache - with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: yarn-${{ hashFiles('yarn.lock') }} - restore-keys: yarn- - - name: Run make-release.sh script - env: - NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} - GITHUB_TOKEN: ${{secrets.DEVWORKSPACE_GENERATOR_RELEASE_GITHUB_TOKEN}} - run: | - git config --global user.name "Anatolii Bazko" - git config --global user.email "abazko@redhat.com" - - ./make-release.sh --version ${{ github.event.inputs.version }} - diff --git a/.github/workflows/typescript-publish.yml b/.github/workflows/typescript-publish.yml new file mode 100644 index 0000000..b9500ca --- /dev/null +++ b/.github/workflows/typescript-publish.yml @@ -0,0 +1,101 @@ +# +# Copyright (c) 2022-2024 +# 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 +# + +# Main workflow for building and publishing release builds +# Release commit +name: Publish project to npmjs + +on: + workflow_dispatch: + inputs: + release-version: + description: 'release version in format 7.y.z' + required: true + release-remake: + description: 'set to true to recreate existing tags (otherwise release will fail if tags already exist)' + type: boolean + default: false + required: true + push: + branches: + - main + - 7.**.x + +permissions: + id-token: write # Required for publishing to npmjs + contents: write + pull-requests: write + +jobs: + publish: + name: Build and publish DevWorkspace Generator to npmjs + runs-on: ubuntu-22.04 + steps: + - name: Validate parameters and build type + shell: bash + run: | + # check if workflow is triggered manually (release) or via branch push (next build) + if [[ "$GITHUB_EVENT_NAME" == "workflow_dispatch" ]]; then + RELEASE_VERSION=${{ github.event.inputs.release-version }} + if [[ "$RELEASE_VERSION" =~ "^[0-9]+\.[0-9]+\.[0-9]+$" ]]; then + echo "[INFO]" preparing to build and release with version: $RELEASE_VERSION + DIST_TAG=$RELEASE_VERSION + else + echo "[ERROR]" incorrect version "$RELEASE_VERSION". Must be following format .., e.g. 7.111.0 + exit 1 + fi + fi + if [[ "$GITHUB_EVENT_NAME" == "push" ]]; then + 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 + echo "npm_dist_tag=$DIST_TAG" >> $GITHUB_OUTPUT + - uses: actions/setup-node@v4 + with: + node-version: '24' + registry-url: 'https://registry.npmjs.org' + scope: '@eclipse-che' + - name: "Checkout source code" + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up environment + run: | + sudo apt-get update -y || true + sudo apt-get -y -q install hub + hub --version + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: | + echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT + - uses: actions/cache@v4 + id: yarn-cache + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: yarn-${{ hashFiles('yarn.lock') }} + restore-keys: yarn- + - name: Perform release + if: github.event_name == 'workflow_dispatch' + run: | + ./make-release.sh --version ${{ github.event.inputs.release-version }} + - name: Update build version + if: github.event_name == 'push' + run: | + SHORT_SHA1=$(git rev-parse --short=7 HEAD) + CURRENT_VERSION=$(jq -r '.version' package.json) + NEW_VERSION="${CURRENT_VERSION}-${SHORT_SHA1}" + echo New version is ${NEW_VERSION} + sed -i -r -e "s/(\"version\": )(\".*\")/\1\"$NEW_VERSION\"/" package.json + npm publish --tag DIST_TAG + \ No newline at end of file