Skip to content

Commit

Permalink
test release
Browse files Browse the repository at this point in the history
  • Loading branch information
AjayJagan committed Sep 26, 2024
1 parent 8d273fd commit 3803b40
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 29 deletions.
65 changes: 45 additions & 20 deletions .github/scripts/get-component-release-notes.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,51 @@
function getModifiedComponentName(name){
let modifiedWord = name.split("-").join(" ").replace(/[^a-zA-Z ]/g, "").trim()
function getModifiedComponentName(name) {
let modifiedWord = name.split("-").join(" ")
modifiedWord = modifiedWord[0].toUpperCase() + modifiedWord.slice(1).toLowerCase()
return modifiedWord.replace("Odh", "ODH")
}
module.exports = ({ github, core }) => {
const { TRACKER_URL } = process.env
module.exports = async ({ github, core, context }) => {
const { TRACKER_URL, VERSION } = process.env
console.log(`The TRACKER_URL is ${TRACKER_URL}`)
const arr = TRACKER_URL.split("/")
const owner = arr[3]
const repo = arr[4]
const issue_number = arr[6]

github.request('GET /repos/{owner}/{repo}/issues/{issue_number}/comments', {
owner,
repo,
issue_number,
headers: {
'X-GitHub-Api-Version': '2022-11-28',
'Accept': 'application/vnd.github.text+json'
}
}).then((result) => {
try {
const latestReleaseResult = await github.rest.repos.getLatestRelease({
owner: context.repo.owner,
repo: context.repo.repo,
headers: {
'X-GitHub-Api-Version': '2022-11-28',
'Accept': 'application/vnd.github+json',
}
})
const latestTag = latestReleaseResult.data["tag_name"]
console.log(`The current tag is: ${latestTag}`)

const releaseNotesResult = await github.rest.repos.generateReleaseNotes({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: VERSION,
previous_tag_name: latestTag,
headers: {
'X-GitHub-Api-Version': '2022-11-28',
'Accept': 'application/vnd.github+json'
}
})
console.log(releaseNotesResult)
const releaseNotesString = releaseNotesResult.data["body"]
const commentsResult = await github.request('GET /repos/{owner}/{repo}/issues/{issue_number}/comments', {
owner,
repo,
issue_number,
headers: {
'X-GitHub-Api-Version': '2022-11-28',
'Accept': 'application/vnd.github.text+json'
}
})
let outputStr = "## Component Release Notes\n"
result.data.forEach((issue) => {
commentsResult.data.forEach((issue) => {
let issueCommentBody = issue.body_text
if (issueCommentBody.includes("#Release#")) {
let components = issueCommentBody.split("\n")
Expand All @@ -31,17 +55,18 @@ module.exports = ({ github, core }) => {
components.forEach(component => {
if (regex.test(component)) {
let [componentName, branchUrl, tagUrl] = component.split("|")
componentName = getModifiedComponentName(componentName.trim())
componentName = componentName.trim()
const releaseNotesUrl = (tagUrl || branchUrl).trim();
if(!outputStr.includes(componentName)) outputStr += `- **${componentName}**: ${releaseNotesUrl}\n`
outputStr += `- **${getModifiedComponentName(componentName)}**: ${releaseNotesUrl}\n`

}
})
}
})
outputStr += releaseNotesString
console.log("Created component release notes successfully...")
core.setOutput('release-notes-body', outputStr);
}).catch(e => {
core.setFailed(`Action failed with error ${e}`);
})
} catch (error) {
core.setFailed(`Action failed with error ${error}`);
}
}
20 changes: 20 additions & 0 deletions .github/scripts/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module.exports = async ({ github, core }) => {
try {
console.log("here2")
const latestReleaseResult = await github.rest.repos.getLatestRelease({
owner: "AjayJagan",
repo: "opendatahub-operator",
headers: {
'X-GitHub-Api-Version': '2022-11-28',
'Accept': 'application/vnd.github+json',
}
})
console.log("here3")
console.log(latestReleaseResult.data["tag_name"])
// const latestTag = latestReleaseResult.data["tag_name"]
// console.log(`The current tag is: ${latestTag}`)
} catch (error) {

core.setFailed(`Action failed with error ${error}`);
}
}
1 change: 1 addition & 0 deletions .github/workflows/pre-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ jobs:
run: |
git checkout -b odh-${{ env.VERSION }}
git push -f origin odh-${{ env.VERSION }}
git log
- uses: ./.github/actions/update-manifest-branches
- name: Create release pr in release branch
uses: ./.github/actions/update-release-version
Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/release-e2e-dry-run.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ on:
type: string
description: The version to update(https://semver.org/).
required: true
previous-tag:
type: string
description: The previous tag in gh
required: true
tracker-url:
type: string
description: The URL to tracker issue(https://github.com/opendatahub-io/opendatahub-community/issues).
Expand All @@ -21,7 +17,6 @@ permissions:
env:
VERSION: ${{ inputs.version }}
TRACKER_URL: ${{ inputs.tracker-url }}
PREV_TAG: ${{ inputs.previous-tag }}
jobs:
dry-run-pr:
runs-on: ubuntu-latest
Expand All @@ -47,6 +42,5 @@ jobs:
#Release#
version=${{ env.VERSION }}
tracker-url=${{ env.TRACKER_URL }}
previous-tag=${{ PREV_TAG }}
:exclamation: DO NOT EDIT THIS COMMENT :exclamation:
pr_number: ${{ steps.cpr-dry-run.outputs.pull-request-number }}
4 changes: 1 addition & 3 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,12 @@ jobs:
with:
script: |
const script = require('./.github/scripts/get-component-release-notes.js')
script({github, core})
await script({github, core, context})
- name: Create GH release
uses: softprops/action-gh-release@v2
with:
body: ${{ steps.release-notes.outputs.release-notes-body }}
tag_name: v${{ env.VERSION }}
generate_release_notes: true
append_body: true
make_latest: true
# To be enabled later.
# create-community-operators-pr:
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: "test release"
on:
workflow_dispatch:
permissions: write-all
jobs:
gh-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get component release notes
id: release-notes
uses: actions/github-script@v7
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
script: |
const script = require('./.github/scripts/test.js')
await script({github, core})

0 comments on commit 3803b40

Please sign in to comment.