Skip to content

Commit

Permalink
Test release
Browse files Browse the repository at this point in the history
  • Loading branch information
JayaShakthi97 committed Oct 29, 2023
1 parent 008e356 commit c323b8a
Show file tree
Hide file tree
Showing 2 changed files with 172 additions and 116 deletions.
229 changes: 113 additions & 116 deletions .github/workflows/release-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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/[email protected]
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 '<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>nexus-releases</id>
<username>${{ secrets.NEXUS_USERNAME }}</username>
<password>${{ secrets.NEXUS_PASSWORD }}</password>
</server>
<server>
<id>wso2.releases</id>
<username>${{ secrets.NEXUS_USERNAME }}</username>
<password>${{ secrets.NEXUS_PASSWORD }}</password>
</server>
<server>
<id>wso2.snapshots</id>
<username>${{ secrets.NEXUS_USERNAME }}</username>
<password>${{ secrets.NEXUS_PASSWORD }}</password>
</server>
</servers>
<profiles>
<profile>
<id>include-sources</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</settings>' > ~/.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/[email protected]
# 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 '<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
# xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
# xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
# http://maven.apache.org/xsd/settings-1.0.0.xsd">
# <servers>
# <server>
# <id>nexus-releases</id>
# <username>${{ secrets.NEXUS_USERNAME }}</username>
# <password>${{ secrets.NEXUS_PASSWORD }}</password>
# </server>

# <server>
# <id>wso2.releases</id>
# <username>${{ secrets.NEXUS_USERNAME }}</username>
# <password>${{ secrets.NEXUS_PASSWORD }}</password>
# </server>

# <server>
# <id>wso2.snapshots</id>
# <username>${{ secrets.NEXUS_USERNAME }}</username>
# <password>${{ secrets.NEXUS_PASSWORD }}</password>
# </server>
# </servers>

# <profiles>
# <profile>
# <id>include-sources</id>
# <build>
# <plugins>
# <plugin>
# <groupId>org.apache.maven.plugins</groupId>
# <artifactId>maven-source-plugin</artifactId>
# <version>3.2.1</version>
# <executions>
# <execution>
# <id>attach-sources</id>
# <goals>
# <goal>jar-no-fork</goal>
# </goals>
# </execution>
# </executions>
# </plugin>
# </plugins>
# </build>
# </profile>
# </profiles>
# </settings>' > ~/.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 }}
59 changes: 59 additions & 0 deletions .github/workflows/scripts/release-test.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit c323b8a

Please sign in to comment.