diff --git a/.github/workflows/release-workflow.yml b/.github/workflows/release-workflow.yml index fb10db738fc..6af539ac3ce 100644 --- a/.github/workflows/release-workflow.yml +++ b/.github/workflows/release-workflow.yml @@ -22,15 +22,13 @@ name: Release on: push: - branches: [ master ] + branches: [ fix-release-workflow ] paths-ignore: - "LICENSE" workflow_dispatch: env: GH_TOKEN: ${{ secrets.RELEASE_BOT_TOKEN }} - BOT_USERNAME: ${{ secrets.RELEASE_BOT_USER_NAME }} - BOT_EMAIL: ${{ secrets.RELEASE_BOT_EMAIL }} jobs: release: @@ -50,121 +48,120 @@ jobs: token: ${{ env.GH_TOKEN }} fetch-depth: 0 - - name: 🟢 Setup node - id: setup-node - uses: actions/setup-node@v2 - with: - node-version: ${{ matrix.node-version }} - - - name: ☕ Set up JDK 1.8 - id: jdk-setup - uses: actions/setup-java@v1 - with: - java-version: ${{ matrix.java-version }} - - - name: 🦩 Set up Maven - uses: stCarolas/setup-maven@v4 - id: mvn-setup - with: - maven-version: ${{ matrix.maven-version }} - - - name: 🥡 Setup pnpm - uses: pnpm/action-setup@v2.1.0 - with: - version: ${{ matrix.pnpm-version }} - run_install: false - - - name: 🎈 Get pnpm store directory - id: get-pnpm-cache-dir - run: | - echo "::set-output name=pnpm_cache_dir::$(pnpm store path)" - - - name: 🔆 Cache pnpm modules - uses: actions/cache@v3 - id: pnpm-cache - with: - path: ${{ steps.get-pnpm-cache-dir.outputs.pnpm_cache_dir }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - - name: 🧩 Install Dependencies - id: install-dependencies - run: pnpm install - - - name: 📝 Create settings.xml with Nexus credentials in ~/.m2 - run: | - echo ' - - - nexus-releases - ${{ secrets.NEXUS_USERNAME }} - ${{ secrets.NEXUS_PASSWORD }} - - - - wso2.releases - ${{ secrets.NEXUS_USERNAME }} - ${{ secrets.NEXUS_PASSWORD }} - - - - wso2.snapshots - ${{ secrets.NEXUS_USERNAME }} - ${{ secrets.NEXUS_PASSWORD }} - - - - - - include-sources - - - - org.apache.maven.plugins - maven-source-plugin - 3.2.1 - - - attach-sources - - jar-no-fork - - - - - - - - - ' > ~/.m2/settings.xml - - - name: 💾 Cache local Maven repository - id: cache-maven-m2 - uses: actions/cache@v2 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven- - - - name: 📣 Create Release Pull Request or Publish to npm - id: changesets - uses: changesets/action@v1 - with: - title: "[Release] [GitHub Action] Update package versions" - publish: pnpm publish:packages - version: pnpm version:packages - commit: "[WSO2 Release] [GitHub Action] [Release] [skip ci] update package versions" - env: - GITHUB_TOKEN: ${{ env.GH_TOKEN }} + # - name: 🟢 Setup node + # id: setup-node + # uses: actions/setup-node@v2 + # with: + # node-version: ${{ matrix.node-version }} + + # - name: ☕ Set up JDK 1.8 + # id: jdk-setup + # uses: actions/setup-java@v1 + # with: + # java-version: ${{ matrix.java-version }} + + # - name: 🦩 Set up Maven + # uses: stCarolas/setup-maven@v4 + # id: mvn-setup + # with: + # maven-version: ${{ matrix.maven-version }} + + # - name: 🥡 Setup pnpm + # uses: pnpm/action-setup@v2.1.0 + # with: + # version: ${{ matrix.pnpm-version }} + # run_install: false + + # - name: 🎈 Get pnpm store directory + # id: get-pnpm-cache-dir + # run: | + # echo "::set-output name=pnpm_cache_dir::$(pnpm store path)" + + # - name: 🔆 Cache pnpm modules + # uses: actions/cache@v3 + # id: pnpm-cache + # with: + # path: ${{ steps.get-pnpm-cache-dir.outputs.pnpm_cache_dir }} + # key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + # restore-keys: | + # ${{ runner.os }}-pnpm-store- + + # - name: 🧩 Install Dependencies + # id: install-dependencies + # run: pnpm install + + # - name: 📝 Create settings.xml with Nexus credentials in ~/.m2 + # run: | + # echo ' + # + # + # nexus-releases + # ${{ secrets.NEXUS_USERNAME }} + # ${{ secrets.NEXUS_PASSWORD }} + # + + # + # wso2.releases + # ${{ secrets.NEXUS_USERNAME }} + # ${{ secrets.NEXUS_PASSWORD }} + # + + # + # wso2.snapshots + # ${{ secrets.NEXUS_USERNAME }} + # ${{ secrets.NEXUS_PASSWORD }} + # + # + + # + # + # include-sources + # + # + # + # org.apache.maven.plugins + # maven-source-plugin + # 3.2.1 + # + # + # attach-sources + # + # jar-no-fork + # + # + # + # + # + # + # + # + # ' > ~/.m2/settings.xml + + # - name: 💾 Cache local Maven repository + # id: cache-maven-m2 + # uses: actions/cache@v2 + # with: + # path: ~/.m2/repository + # key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + # restore-keys: | + # ${{ runner.os }}-maven- + + # - name: 📣 Create Release Pull Request or Publish to npm + # id: changesets + # uses: changesets/action@v1 + # with: + # title: "[Release] [GitHub Action] Update package versions" + # publish: pnpm publish:packages + # version: pnpm version:packages + # commit: "[WSO2 Release] [GitHub Action] [Release] [skip ci] update package versions" + # env: + # GITHUB_TOKEN: ${{ env.GH_TOKEN }} - name: 🚀 Perform Release id: perform-release working-directory: .github/workflows run: | - PACKAGES="${{ toJson(steps.changesets.outputs.publishedPackages) }}" - bash ./scripts/release.sh "$PACKAGES" + bash ./scripts/release-test.sh ${{ github.run_number }} diff --git a/.github/workflows/scripts/release-test.sh b/.github/workflows/scripts/release-test.sh new file mode 100644 index 00000000000..e399e7f2ada --- /dev/null +++ b/.github/workflows/scripts/release-test.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash + +# ... [The rest of your copyright header and comments] ... + +# SCRIPT_LOCATION="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)" + +# Retrieve GitHub Action Run Number from arguments +GITHUB_RUN_NUMBER=$1 + +# Create and checkout a new branch for the release +create_and_checkout_release_branch() { + local releaseBranch="release-action-$GITHUB_RUN_NUMBER" + + git checkout -b "$releaseBranch" && + echo "Checked out to the release branch: $releaseBranch" +} + +# Merge the release branch back to master +merge_to_master() { + local releaseBranch="release-action-$GITHUB_RUN_NUMBER" + + git checkout master && + git merge --no-ff "$releaseBranch" -m "Merge release branch $releaseBranch" && + echo "Merged $releaseBranch into master" +} + +dummy_long_running_process() { + local minutes=5 + + for (( i=1; i<=$minutes; i++ )) + do + echo "Minute $i: Running dummy process..." + sleep 60 + done + + # Committing a dummy file to the branch with action number appended to its name + local dummyFileName="dummy_file_$GITHUB_RUN_NUMBER.txt" + echo "This is a dummy file generated during the release process." > "$dummyFileName" + git add "$dummyFileName" + git commit -m "Add dummy file ($dummyFileName) during release process" + echo "Committed $dummyFileName to the branch." +} + +if [ -z "$GITHUB_RUN_NUMBER" ]; then + echo "GitHub Action number not provided. Exiting..." && + exit 1 +fi + +# Create and checkout the release branch +create_and_checkout_release_branch || exit 1 + +# Execute dummy long-running process +dummy_long_running_process || { + echo "Error during the dummy process" + exit 1 +} + +# Merge to master after successful release +#merge_to_master || exit 1