diff --git a/.github/scripts/slack-channel-cloud-message.json b/.github/scripts/slack-channel-cloud-message.json new file mode 100644 index 00000000000..235ff2d6cad --- /dev/null +++ b/.github/scripts/slack-channel-cloud-message.json @@ -0,0 +1,42 @@ +{ + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "Hi All :smile:\n\nWe just Published Could release of *Elementor*\n`${{ env.PACKAGE_VERSION }}`" + } + }, + { + "type": "divider" + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "GitHub Release *${{ env.PACKAGE_VERSION }}* \nCreated by ${{ github.actor }}" + }, + "accessory": { + "type": "button", + "text": { + "type": "plain_text", + "text": "Open :point_left:", + "emoji": true + }, + "value": "open-release", + "url": "https://github.com/${{ github.repository }}/releases/tag/${{ env.PACKAGE_VERSION }}", + "action_id": "button-action" + } + }, + { + "type": "divider" + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*v${{ env.PACKAGE_VERSION }} Changelog* \n\n ${{ env.CHANGELOG_CONTENT }}" + } + } + ] +} diff --git a/.github/workflows/bump-channel-version/action.yml b/.github/workflows/bump-channel-version/action.yml index ae739a366f4..81bc5ba2736 100644 --- a/.github/workflows/bump-channel-version/action.yml +++ b/.github/workflows/bump-channel-version/action.yml @@ -8,6 +8,15 @@ inputs: CLEAN_PACKAGE_VERSION: required: true description: 'The current package version, e.g. "3.11.7".' + OVERRIDE_PACKAGE_VERSION: + required: false + default: "false" + description: 'Override the package version in the workflow environment variables.' + POSTFIX: + required: false + default: "" + description: 'The postfix that will be added to the package version -rc / -test' + runs: using: "composite" @@ -28,6 +37,10 @@ runs: echo "ELEMENTOR_CHANNEL_PACKAGE_VERSION=${ELEMENTOR_CHANNEL_PACKAGE_VERSION}" echo "NEW_CHANNEL_VERSION=${NEW_CHANNEL_VERSION}" + if [[ ${{ inputs.OVERRIDE_PACKAGE_VERSION }} == "true" ]]; then + echo "PACKAGE_VERSION=${ELEMENTOR_CHANNEL_PACKAGE_VERSION}${{inputs.POSTFIX}}" >> $GITHUB_ENV + fi + if [[ ${{ inputs.CHANNEL }} == "beta" ]]; then BETA_VERSION=${{ inputs.CLEAN_PACKAGE_VERSION }}-${{ inputs.CHANNEL }}${NEW_CHANNEL_VERSION} echo "BETA_VERSION=$BETA_VERSION" >> $GITHUB_ENV diff --git a/.github/workflows/env-vars-configure/action.yml b/.github/workflows/env-vars-configure/action.yml index fc5a562cfbc..56171c955e6 100644 --- a/.github/workflows/env-vars-configure/action.yml +++ b/.github/workflows/env-vars-configure/action.yml @@ -8,6 +8,10 @@ inputs: REF: required: true description: 'The ref to get the version from.' + POSTFIX: + required: false + default: "-rc" + description: 'The postfix that will be added to the package version -rc / -test' runs: using: "composite" @@ -16,14 +20,21 @@ runs: uses: ./.github/workflows/get-new-package-version with: CHANNEL: ${{ inputs.CHANNEL }} + POSTFIX: ${{ inputs.POSTFIX }} - name: Increment Patch Version if: inputs.CHANNEL == 'ga' uses: ./.github/workflows/increment-patch-version - shell: bash run: | - # This command retrieves the latest tag that matches the specified channel and package version, + # This command retrieves the latest tag that matches the specified channel and package version, # and extracts the version number from the tag name using awk. E.g. retrieves the number 7 from `3.11.0-cloud7`. - CURRENT_CHANNEL_VERSION=$(git ls-remote --tags | grep -v "\-rc" | grep -v "refs/tags/v" | grep "${{ inputs.CHANNEL }}" | grep "${{ env.CLEAN_PACKAGE_VERSION }}" | tail -n1 | awk -F'${{ inputs.CHANNEL }}' '{print $2}' || echo 0) + # If the channel is tagged as a prerelease, than get the latest prerelease version + # If the channel is not tagged as a pre-release, than get the latest version which is not a pre-release or an rc + if [[ "${{ inputs.POSTFIX }}" == "-test" ]]; then + CURRENT_CHANNEL_VERSION=$(git ls-remote --tags | grep "\-test" | grep -v "refs/tags/v" | grep "${{ inputs.CHANNEL }}" | grep "${{ env.CLEAN_PACKAGE_VERSION }}" | tail -n1 | awk -F'${{ inputs.CHANNEL }}' '{print $2}' | awk -F'${{ inputs.POSTFIX }}' '{print $1}' || echo 0) + else + CURRENT_CHANNEL_VERSION=$(git ls-remote --tags | grep -v "\-rc" | grep -v "\-test" | grep -v "refs/tags/v" | grep "${{ inputs.CHANNEL }}" | grep "${{ env.CLEAN_PACKAGE_VERSION }}" | tail -n1 | awk -F'${{ inputs.CHANNEL }}' '{print $2}' || echo 0) + fi # If value is not a number (e.g. empty string) then set it to 0 if ! [[ $CURRENT_CHANNEL_VERSION =~ ^[0-9]+$ ]]; then @@ -38,9 +49,9 @@ runs: CLEAN_REF=${{ inputs.REF }} # e.g. refs/heads/main -> main CLEAN_REF=${CLEAN_REF#refs/heads/} - + echo "CLEAN_REF=${CLEAN_REF}" >> $GITHUB_ENV - + echo "PLUGIN_ZIP_PATH=./elementor/**/*" echo "PLUGIN_ZIP_FILENAME=${PLUGIN_ZIP_FILENAME}" @@ -51,3 +62,4 @@ runs: uses : ./.github/workflows/get-previous-release with: CHANNEL: ${{ inputs.CHANNEL }} + POSTFIX: ${{ inputs.POSTFIX }} diff --git a/.github/workflows/get-new-package-version/action.yml b/.github/workflows/get-new-package-version/action.yml index 21ae56e1268..ff77b7101ae 100644 --- a/.github/workflows/get-new-package-version/action.yml +++ b/.github/workflows/get-new-package-version/action.yml @@ -5,6 +5,10 @@ inputs: CHANNEL: required: true description: 'The channel to get the version to (ga, cloud, beta).' + ADDITION_NAME: + required: false + default: "-rc" + description: 'The addition name to add to the package version.' runs: using: "composite" @@ -12,8 +16,8 @@ runs: - shell: bash run: | CLEAN_PACKAGE_VERSION=$(node -p "require('./package.json').version") - PACKAGE_VERSION=${CLEAN_PACKAGE_VERSION}-${{ inputs.CHANNEL }}-rc + + PACKAGE_VERSION=${CLEAN_PACKAGE_VERSION}-${{ inputs.CHANNEL }}${{ inputs.ADDITION_NAME }} echo "PACKAGE_VERSION=${PACKAGE_VERSION}" >> $GITHUB_ENV echo "CLEAN_PACKAGE_VERSION=${CLEAN_PACKAGE_VERSION}" >> $GITHUB_ENV - diff --git a/.github/workflows/get-previous-release/action.yml b/.github/workflows/get-previous-release/action.yml index 3f5373efae7..bce13ec35f5 100644 --- a/.github/workflows/get-previous-release/action.yml +++ b/.github/workflows/get-previous-release/action.yml @@ -5,6 +5,10 @@ inputs: CHANNEL: required: true description: "The channel to get the version to (ga, cloud, beta)." + POSTFIX: + required: false + default: "-rc" + description: "The postfix that will be added to the package version -rc / -test" runs: using: "composite" @@ -13,8 +17,13 @@ runs: run: | # If the channel is either "cloud" or "beta", fetch all Git tags matching the channel pattern, # excluding any "-rc" tags, and store them in the 'tags' variable. e.g. "refs/tags/v3.11.0-cloud1 , refs/tags/v3.11.0-cloud2" - if [[ ${{ inputs.CHANNEL }} == "cloud" || ${{ inputs.CHANNEL }} == "beta" ]]; then - tags=$(git ls-remote --tags | grep ${{ inputs.CHANNEL }} | grep -v "\-rc" | awk '{print $2}') + if [[ ( ${{ inputs.CHANNEL }} == "cloud" || ${{ inputs.CHANNEL }} == "beta" ) && "${{ inputs.POSTFIX }}" != "-test" ]]; then + tags=$(git ls-remote --tags | grep ${{ inputs.CHANNEL }} | grep -v "\-rc" | grep -v "\-test" | awk '{print $2}') + fi + + # If the channel is "cloud" and the POSTFIX is "-test", fetch all Git tags matching the channel pattern, + if [[ ${{ inputs.CHANNEL }} == "cloud" && "${{ inputs.POSTFIX }}" == "-test" ]]; then + tags=$(git ls-remote --tags | grep ${{ inputs.CHANNEL }} | grep "\-test" | awk '{print $2}') fi # If the channel is "ga", fetch all Git tags matching the semantic versioning pattern "vX.Y.Z" diff --git a/.github/workflows/one-click-hosting-release.yml b/.github/workflows/one-click-hosting-release.yml new file mode 100644 index 00000000000..06cc88e74bd --- /dev/null +++ b/.github/workflows/one-click-hosting-release.yml @@ -0,0 +1,97 @@ +name: One Click Hosting Release + +on: + workflow_dispatch: + inputs: + pre_release: + type: boolean + description: 'Pre-release?' + default: true + required: false + branches: + - main +env: + CHANNEL: 'cloud' + CHANGELOG_FILE: 'temp-changelog.txt' + +jobs: + release: + runs-on: ubuntu-22.04 + steps: + - name: checkout branch + uses: actions/checkout@v3 + with: + ref: ${{ github.ref }} + - name: Get Configuration + id: configuration + uses: maork-elementor/json-to-variables@main + with: + filename: './.github/workflows/config.json' + prefix: config + - name: Test permissions + uses: ./.github/workflows/permissions + with: + ENVIRONMENT: ${{ env.config_deployment_environment }} + DEPLOYMENT_PERMITTED: ${{ env.config_deployment_permitted }} + DEPLOYMENT_REPOSITORY_OWNER: ${{ env.config_deployment_repository_owner }} + - name: Install Node.js 18.x + uses: actions/setup-node@v3 + with: + node-version: 18.x + - name: Is pre-release? + id: is_pre_release + run: | + if [ ${{ github.event.inputs.pre_release }} == true ]; then + POSTFIX="-test" + echo "This is a prerelease execution" + else + POSTFIX="" + echo "This is a release execution" + fi + echo "POSTFIX=${POSTFIX}" >> $GITHUB_ENV + - name: Env Vars Configure + uses: ./.github/workflows/env-vars-configure + with: + CHANNEL: ${{ env.CHANNEL }} + REF: ${{ github.ref }} + POSTFIX: ${{ env.POSTFIX }} + - name: Bump Channel Version + uses: ./.github/workflows/bump-channel-version + with: + CLEAN_PACKAGE_VERSION: ${{ env.CLEAN_PACKAGE_VERSION }} + CHANNEL: ${{ env.CHANNEL }} + OVERRIDE_PACKAGE_VERSION: true + POSTFIX: ${{ env.POSTFIX }} + - name: Install Dependencies + run: npm ci + - name: Build plugin + uses: ./.github/workflows/build-plugin + with: + PACKAGE_VERSION: ${{ env.PACKAGE_VERSION }} + BUILD_SCRIPT_PATH: "./.github/scripts/build-zip.sh" + - name: Generate changelog + uses : ./.github/workflows/generate-changelog + with: + TOKEN: ${{ secrets.MAINTAIN_TOKEN }} + REPOSITORY: ${{ github.repository }} + HEAD_BRANCH_NAME: ${{ github.ref }} + BASE_TAG_NAME: ${{ env.PREVIOUS_TAG_SHA }} + GENERATE_EMPTY_CHANGELOG: true + - name: Create GitHub release + uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ env.PACKAGE_VERSION }} + target_commitish: ${{ env.CLEAN_REF }} + files: | + elementor-*.zip + ${{ env.CHANGELOG_FILE }} + # Will be removed once we see that the release is working + prerelease: ${{ github.event.inputs.pre_release }} + body_path: ${{ env.CHANGELOG_FILE }} + - name: Post To Slack Created Cloud one click Release + if: ${{ github.event.inputs.pre_release }} == false + uses : ./.github/workflows/post-to-slack + with: + SLACK_BOT_TOKEN: ${{ secrets.SLACK_TOKEN }} + SLACK_TAG_CHANNELS: ${{ secrets.SLACK_CHANNEL_RELEASEBOT }} + PAYLOAD: "$(cat ./.github/scripts/slack-channel-cloud-message.json)"