Skip to content

Commit

Permalink
Merge pull request #2200 from zowe/zowe-version-workflow
Browse files Browse the repository at this point in the history
Zowe version workflow
  • Loading branch information
ATorrise authored Jul 29, 2024
2 parents 64930b9 + 1ec04a6 commit 8f32340
Show file tree
Hide file tree
Showing 5 changed files with 320 additions and 1 deletion.
65 changes: 65 additions & 0 deletions .github/updateReleaseMarkdown.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
const fs = require('fs');
const path = require('path');

const mdFilePath = path.join(__dirname, '../RELEASE_HISTORY.md');

// Build the new row to be added
const newRow = `| v${process.env.NEW_VERSION} | ${new Date().toISOString().split('T')[0].slice(0, 7)} | **Active** | [Release Notes](https://docs.zowe.org/stable/whats-new/release-notes/v${process.env.NEW_VERSION.replace(/\./g, '_')}) |`;

// Read, Update and Write to Markdown File
function updateReleaseHistory(newRow) {
fs.readFile(mdFilePath, 'utf8', (err, data) => {
if (err) {
console.error('Error reading the file:', err);
return;
}

// Find the table and insert the new row after the second row
const lines = data.split('\n');
let tableLineCount = 0;
for (let i = 0; i < lines.length; i++) {
if (lines[i].startsWith('|') && lines[i].endsWith('|')) {
tableLineCount++;
if (tableLineCount === 2) {
// Insert the new row after the second row
lines.splice(i + 1, 0, newRow);
break;
}
}
}

fs.writeFile(mdFilePath, lines.join('\n'), 'utf8', (err) => {
if (err) {
console.error('Error writing the file:', err);
return;
}
console.log('Markdown file updated successfully.');
});
});
}

// Update the zoweVersion in package.json
function updatePackageJsonVersion(newVersion) {
const packageJsonPath = path.join(__dirname, '../packages/cli/package.json');
fs.readFile(packageJsonPath, 'utf8', (err, data) => {
if (err) {
console.error('Error reading package.json:', err);
return;
}

let packageJson = JSON.parse(data);
packageJson.zoweVersion = `v${newVersion}`;

fs.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2), 'utf8', (err) => {
if (err) {
console.error('Error writing to package.json:', err);
return;
}
console.log('package.json updated successfully.');
});
});
}

// Execute the functions
updatePackageJsonVersion(process.env.NEW_VERSION);
updateReleaseHistory(newRow);
111 changes: 111 additions & 0 deletions .github/updateReleaseMarkdown_BROKEN.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
const fs = require('fs');
const path = require('path');
const https = require('https');

// This script is attempting to add whatever list of the CLI team is shown in the TSC repo https://raw.githubusercontent.com/zowe/community/master/COMMITTERS.md.
// Despite efforts, this is not working. Adam will always be cut off (possibly just whoever is first in the table).
// Leaving this code present and hoping that the problem with this file can be solved in the future.

// URL of the raw markdown file to be appended to RELEASE_HISTORY.md
const url = 'https://raw.githubusercontent.com/zowe/community/master/COMMITTERS.md';

// Build the new row to be added
const newVersion = process.env.NEW_VERSION;
const newRow = `| v${newVersion} | ${new Date().toISOString().split('T')[0].slice(0, 7)} | **Active** | [Release Notes](https://docs.zowe.org/stable/whats-new/release-notes/v${newVersion.replace(/\./g, '_')}) |`;

const mdFilePath = path.join(__dirname, '../RELEASE_HISTORY.md');

// Function to fetch CLI team from a URL
function fetchCliTeam(url) {
return new Promise((resolve, reject) => {
https.get(url, (res) => {
let data = '';

// A chunk of data has been received
res.on('data', (chunk) => {
data += chunk;
});

// The whole response has been received
res.on('end', () => {
// Extract only the CLI contributors section
const cliSectionMatch = data.match(/### Zowe CLI Squad[\s\S]*?(?=###|$)/);
const cliSection = cliSectionMatch ? cliSectionMatch[0] : '';
resolve(cliSection);
});
}).on('error', (err) => {
reject(err);
});
});
}

// Function to remove existing CLI team section and append new one
function updateCliTeamInMd(cliTeam) {
// Read the current content of the markdown file
fs.readFile(mdFilePath, 'utf8', (err, data) => {
if (err) {
console.error('Error reading the file:', err);
return;
}

// Remove the old CLI squad section and replace it with the new one
const updatedData = data.replace(/### Zowe CLI Squad[\s\S]*?(?=###|$)/, cliTeam + '\n');

// Write the updated data back to the file
fs.writeFile(mdFilePath, updatedData, 'utf8', (err) => {
if (err) {
console.error('Error writing the file:', err);
return;
}
console.log('CLI team has been updated in RELEASE_HISTORY.md successfully.');
});
});
}

// Main function to fetch CLI team and update RELEASE_HISTORY
async function appendCliTeam() {
try {
const cliTeam = await fetchCliTeam(url);
updateCliTeamInMd(cliTeam);
} catch (error) {
console.error('Error fetching CLI team:', error);
}
}

// Read, Update and Write to Markdown File
function updateReleaseHistory(newRow) {
fs.readFile(mdFilePath, 'utf8', (err, data) => {
if (err) {
console.error('Error reading the file:', err);
return;
}

// Find the table and insert the new row after the second row
const lines = data.split('\n');
let tableLineCount = 0;
for (let i = 0; i < lines.length; i++) {
if (lines[i].startsWith('|') && lines[i].endsWith('|')) {
tableLineCount++;
if (tableLineCount === 2) {
// Insert the new row after the second row
lines.splice(i + 1, 0, newRow);
break;
}
}
}

fs.writeFile(mdFilePath, lines.join('\n'), 'utf8', (err) => {
if (err) {
console.error('Error writing the file:', err);
return;
}
console.log('Markdown file updated successfully.');
});
});
}

// Execute the two main functions
(async () => {
await appendCliTeam();
updateReleaseHistory(newRow);
})();
74 changes: 74 additions & 0 deletions .github/workflows/zoweReleaseVersion.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Update Zowe Version and Create PR

on:
workflow_dispatch:
inputs:
major_version:
description: 'Major version (default is 3)'
required: true
default: '3'
minor_version:
description: 'Minor version'
required: true
patch_version:
description: 'Patch version'
required: true

jobs:
update_versions_and_create_pr:
runs-on: ubuntu-latest

steps:
- name: Checkout CLI Repo
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: lts/*

- name: Set Variables and Ensure Increase in Semver
id: get_zowe_versions
run: |
current_version=$(jq -r '.zoweVersion' packages/cli/package.json)
current_version="${current_version#v}" # Strip the 'v' prefix
echo "current_version=$current_version" >> $GITHUB_ENV
new_version="${{ github.event.inputs.major_version }}.${{ github.event.inputs.minor_version }}.${{ github.event.inputs.patch_version }}"
echo "new_version=$new_version" >> $GITHUB_ENV
echo "PACKAGE_JSON_PATH=packages/cli/package.json" >> $GITHUB_ENV
if [[ "$new_version" < "$current_version" ]]; then
echo "Error: New version $new_version is not greater than current version $current_version."
exit 1
fi
- name: Create Branch
run: |
branch_name="update-version-v${{ env.new_version }}"
echo "branch_name=$branch_name" >> $GITHUB_ENV
git checkout -b "$branch_name"
- name: Update Zowe Version in cli/package.json
run: |
jq ".zoweVersion = \"v${{ env.new_version }}\"" ${{ env.PACKAGE_JSON_PATH }} > package.tmp.json && mv package.tmp.json ${{ env.PACKAGE_JSON_PATH }}
- name: Update RELEASE_HISTORY.md
run: node ".github/updateReleaseMarkdown.js"
env:
NEW_VERSION: ${{ env.new_version }}

- name: Commit and Push Changes
run: |
git config --global user.name "${{ secrets.ZOWE_ROBOT_USER }}"
git config --global user.email "${{ secrets.ZOWE_ROBOT_EMAIL }}"
git add "${{ env.PACKAGE_JSON_PATH }}"
git add "RELEASE_HISTORY.md"
git commit -sm "Update version to ${{ env.new_version }}"
git push origin "$branch_name"
- name: Create Pull Request
run: |
pr_title="Update CLI version to ${{ env.new_version }}"
base_branch="${{ github.ref_name }}"
gh pr create -t "$pr_title" -b "$base_branch" --head "$branch_name" --body "Updating Zowe CLI version to ${{ env.new_version }}" --reviewer zFernand0,t1m0thyj,awharn,gejohnston,traeok,jace-roell,ATorrise
env:
GH_TOKEN: ${{ secrets.ZOWE_ROBOT_TOKEN }}
69 changes: 69 additions & 0 deletions RELEASE_HISTORY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Zowe CLI Releases

Zowe follows a regular release schedule with major versions released every two years and minor versions approximately every six weeks. Full details regarding the Zowe release schedule are available on [zowe.org](https://www.zowe.org/download#timeline) and the Zowe Community [Github](https://github.com/zowe/community/blob/master/Technical-Steering-Committee/release.md).

## Zowe Release Schedule

### Zowe v3.x LTS Releases
| Version | Release Date | Status | Release Notes |
|:--------:|:------------:|:----------:|:-------------:|
| v3.0.0-prerelease | 2024-08 | **Under Development** | |

### Major Release Timeline

![Zowe Major Releases](https://raw.githubusercontent.com/zowe/zowe.github.io/master/assets/img/major_releases.webp)

### Version Timeframes

- **Active**: Each major version remains in this phase for 2 years, receiving regular updates and new features.
- **Maintenance**: Following the Active phase, each major version remains in this phase for an additional 2.5 years, receiving only critical fixes and security patches.
- **Under Development**: The pre-Active phase where the next major version is prepared. This phase varies in length and is not available for general consumption.

### Guarantees

- **Critical Defects Fixes**: The community will fix critical defects. The criteria for what constitutes a critical defect can be found [here](https://github.com/zowe/community/blob/master/Technical-Steering-Committee/release.md#active-release).
- **Extender Conformance**: Extenders achieving Zowe conformance for the long-term support version will not need to modify their product to remain functional when Zowe updates are provided within the same major version.

### Recommendations

- **Production**: Use **Active** or **Maintenance** releases for production due to the guaranteed stability and the community’s commitment to fixing critical defects.
- **Nightly Builds**: Available for integration testing. Use at your own risk.

## Zowe Release Process

### Short Summary

1. Code Freeze date is hit.
2. Each [squad](https://github.com/zowe/community/blob/master/Technical-Steering-Committee/squads.md) provides a version of the code to integrate into the Release Candidate (RC).
3. RC is built and tested with an automatic test suite.
4. RC is deployed and tested by squads.
5. RC is approved by the TSC vote.
6. Release is published.
7. Documentation is published.
8. Release retrospective is held.

### Release Numbering

Releases follow [semantic versioning](https://semver.org/) guidelines (MAJOR.MINOR.PATCH).

- **MAJOR**: Incompatible API changes.
- **MINOR**: Backwards-compatible functionality additions.
- **PATCH**: Backwards-compatible bug fixes.

### Release Content

The following [components of the release](https://github.com/zowe/community/blob/master/Technical-Steering-Committee/release.md#release-content) are managed by the CLI squad:

- **CLI Component**
- CLI Core
- CLI Plugins
- **Client SDKs**
- Node.js Client SDK
- Python Client SDK


## Zowe CLI Squad
- https://github.com/zowe/community/blob/master/COMMITTERS.md#zowe-cli-squad
- https://github.com/orgs/zowe/teams/zowe-cli-administrators
- https://github.com/orgs/zowe/teams/zowe-cli-committers
- https://github.com/orgs/zowe/teams/zowe-cli-contributors
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zowe/cli",
"version": "8.0.0-next.202407262216",
"zoweVersion": "V3",
"zoweVersion": "v3.0.0-prerelease",
"description": "Zowe CLI is a command line interface (CLI) that provides a simple and streamlined way to interact with IBM z/OS.",
"author": "Zowe",
"license": "EPL-2.0",
Expand Down

0 comments on commit 8f32340

Please sign in to comment.