Skip to content

Release SI Extension #30

Release SI Extension

Release SI Extension #30

Workflow file for this run

name: Release SI Extension
on:
workflow_dispatch:
inputs:
prerelease:
type: boolean
description: 'Create as prerelease'
default: false
prereleaseVersion:
type: string
description: 'Override prerelease base version (e.g., 0.99 for major bump to 1.0.0). Format: major.minor'
required: false
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.WSO2_INTEGRATION_BOT_TOKEN }}
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22.x'
- name: Setup Rush
uses: gigara/setup-rush@v1.2.0
with:
pnpm: 10.11.0
node: 22.x
rush-install: true
- name: Get Release Version
id: version
run: |
cd workspaces/si/si-extension
version=$(node -p "require('./package.json').version")
echo "STABLE_VERSION=$version" >> $GITHUB_ENV
IFS='.' read -r major minor patch <<< "$version"
if [ "${{ inputs.prerelease }}" = "true" ]; then
# Use epoch minutes as patch version (fits within 0-2147483647 limit)
timestamp=$(($(date -u +%s) / 60))
if [ -n "${{ inputs.prereleaseVersion }}" ]; then
# Use the override version (e.g., "0.99" for major bump to 1.0.0)
build_version="${{ inputs.prereleaseVersion }}.$timestamp"
else
# Pre-releases use odd minor (current minor - 1) with timestamp patch
pre_minor=$((minor - 1))
build_version="$major.$pre_minor.$timestamp"
fi
release_tag="v${build_version}"
else
build_version="$version"
release_tag="v${version}"
fi
echo "VERSION=$build_version" >> $GITHUB_ENV
echo "version=$build_version" >> $GITHUB_OUTPUT
echo "RELEASE_TAG=$release_tag" >> $GITHUB_ENV
echo "release_tag=$release_tag" >> $GITHUB_OUTPUT
echo "Release version: $build_version (tag: $release_tag)"
- name: Set build version in package.json
if: ${{ inputs.prerelease }}
run: |
cd workspaces/si/si-extension
npm version "${{ env.VERSION }}" --no-git-tag-version
- name: Build Release Artifacts
run: |
node common/scripts/install-run-rush.js build --verbose
env:
isPreRelease: ${{ inputs.prerelease }}
- name: Upload release artifact
uses: actions/upload-artifact@v4
with:
name: streaming-integrator
path: workspaces/si/si-extension/streaming-integrator-${{ env.VERSION }}.vsix
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.WSO2_INTEGRATION_BOT_TOKEN }}
run: |
cd workspaces/si/si-extension
release_flags="--generate-notes"
if [ "${{ inputs.prerelease }}" = "true" ]; then
release_flags="$release_flags --prerelease"
fi
gh release create "${{ env.RELEASE_TAG }}" \
--repo="$GITHUB_REPOSITORY" \
--title="WSO2 Integrator: SI Extension ${{ env.RELEASE_TAG }}" \
--target="${GITHUB_REF}" \
$release_flags \
streaming-integrator-${{ env.VERSION }}.vsix
- name: Bump to Next Patch Version and Create PR
if: ${{ inputs.prerelease == false }}
env:
GITHUB_TOKEN: ${{ secrets.WSO2_INTEGRATION_BOT_TOKEN }}
run: |
git config --global user.name ${{ secrets.WSO2_INTEGRATION_BOT_USERNAME }}
git config --global user.email ${{ secrets.WSO2_INTEGRATION_BOT_EMAIL }}
# Calculate next stable version (bump minor by 2 to next even minor)
IFS='.' read -r major minor patch <<< "${STABLE_VERSION}"
next_version="$major.$((minor + 2)).0"
# Create version bump branch
branch_name="version-bump/${next_version}"
git checkout -b "$branch_name"
# Update version in package.json
cd workspaces/si/si-extension
npm version "$next_version" --no-git-tag-version
cd ../../..
git add .
git commit -m "Bump version to ${next_version}"
git push origin "$branch_name"
# Create PR back to the source branch
gh pr create \
--base "${GITHUB_REF##*/}" \
--head "$branch_name" \
--title "[Automated] Bump version to ${next_version}" \
--body "
## Version Bump
Bumps the version to **${next_version}** after the **${VERSION}** release.
**Release**: https://github.com/${{ github.repository }}/releases/tag/${{ env.RELEASE_TAG }}
"