-
Notifications
You must be signed in to change notification settings - Fork 27
oaiFeat: Cli integration test #272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
0c76fd0
abbb4eb
58f9139
6f87cdc
fd95622
b9c525b
cc95efe
c0cca72
c3da8a3
2c31d95
f863733
edb4dcf
085638e
81c2f9b
d533503
27ed812
0cf3aed
b41b8fe
bbe1bf4
83ff1f3
7df7bc9
6b6a6da
b7f11cf
0db9bcc
b9c6d56
1c86537
e314cca
17c7772
24b7575
497c50f
dca4bd6
e9b0814
a323e4a
d502380
4b36741
4360a4e
07dace7
272e8fe
eea9c71
248cb71
f7ef4d9
afe53ae
81084a7
83628ad
f9f03ca
ad3b2ff
77b1742
202266f
5a2cf03
70664b3
f1450ff
f7c3671
cc2a30c
a219728
463d734
80e4979
eccd706
2a29e05
7b65d16
0c4f1cb
2afbdc4
86a57fb
14cb125
04e6097
0a4d330
2358214
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
const core = require('@actions/core'); | ||
const { Octokit } = require("@octokit/core"); | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
|
||
/** | ||
* Functionality from tubone24/update_release. | ||
|
@@ -12,6 +14,13 @@ const updateRelease = async () => { | |
}) | ||
const [owner, repo] = process.env.REPO_NAME ? process.env.REPO_NAME.split('/') : [null, null]; | ||
const tag = process.env.TAG_NAME; | ||
const githubWorkspace = process.env.GITHUB_WORKSPACE; | ||
|
||
console.log("GITHUB_WORKSPACE: ", githubWorkspace); | ||
|
||
if( !process.env.GITHUB_WORKSPACE.includes('twilio-cli-core') ) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the case when workspace is 'twilio-cli' right? Can we check for that here? Since we ultimately want to update the cli core tag in twilio-cli |
||
updatePackageJson(process.env.CLI_CORE_TAG) | ||
} | ||
|
||
//https://docs.github.com/en/rest/releases/releases#get-a-release-by-tag-name | ||
const getReleaseResponse = await octokit.request('GET /repos/{owner}/{repo}/releases/tags/{tag}',{ | ||
|
@@ -54,7 +63,7 @@ const updateRelease = async () => { | |
prerelease = oldPrerelease; | ||
} | ||
|
||
//https://docs.github.com/en/rest/releases/releases#update-a-release | ||
// https://docs.github.com/en/rest/releases/releases#update-a-release | ||
await octokit.request('PATCH /repos/{owner}/{repo}/releases/{release_id}', { | ||
owner, | ||
release_id: oldReleaseId, | ||
|
@@ -71,6 +80,26 @@ const updateRelease = async () => { | |
} | ||
}; | ||
|
||
const updatePackageJson = (value) => { | ||
try { | ||
// Path to package.json | ||
const packageJsonPath = path.resolve(process.cwd(), 'package.json'); | ||
|
||
// Read and parse package.json | ||
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')); | ||
|
||
// Update the desired key | ||
packageJson["dependencies"]["@twilio/cli-core"] = value; | ||
|
||
// Write the updated object back to package.json | ||
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), 'utf8'); | ||
|
||
console.info(`Updated package.json: Set twilio-cli-core to '${value}'`); | ||
} catch (error) { | ||
console.error(`Failed to update package.json: ${error.message}`); | ||
} | ||
}; | ||
|
||
module.exports = { | ||
updateRelease, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,13 +87,13 @@ jobs: | |
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: [14.x, 16.x, 18.x] | ||
node-version: [20.x, 22.x, lts/*] | ||
steps: | ||
- name: Checkout cli-core repo | ||
uses: actions/checkout@v2 | ||
uses: actions/checkout@v4 | ||
- run: make install | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v2 | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: 'npm' | ||
|
@@ -135,7 +135,7 @@ jobs: | |
tag-name: ${{ steps.semantic-release.outputs.TAG_NAME }} | ||
steps: | ||
- name: Checkout cli-core repo | ||
uses: actions/checkout@v2 | ||
uses: actions/checkout@v4 | ||
with: | ||
persist-credentials: false | ||
- run: | | ||
|
@@ -147,25 +147,26 @@ jobs: | |
node-version: 18.x | ||
- name: semanticRelease | ||
id: semantic-release | ||
run: DEBUG=semantic-release:* npx semantic-release -t \${version} | ||
run: | | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we are merging it now, we should remove the dry-run flag right? |
||
DEBUG=semantic-release:* npx semantic-release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }} | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
- name: Update release | ||
run: | | ||
fileName="$GITHUB_WORKSPACE/.github/scripts/update-release.js" | ||
node -e "require('$fileName').updateRelease()" | ||
env: | ||
REPO_ACCESS_TOKEN: ${{ github.token }} | ||
TAG_NAME: ${{ steps.semantic-release.outputs.TAG_NAME }} | ||
RELEASE_BODY: ${{needs.update-api-specs.outputs.change-log}} | ||
REPO_NAME: ${{ github.repository }} | ||
# - name: Update release | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we are merging it now, we should uncomment this step right? |
||
# run: | | ||
# fileName="$GITHUB_WORKSPACE/.github/scripts/update-release.js" | ||
# node -e "require('$fileName').updateRelease()" | ||
# env: | ||
# REPO_ACCESS_TOKEN: ${{ github.token }} | ||
# TAG_NAME: ${{ steps.semantic-release.outputs.TAG_NAME }} | ||
# RELEASE_BODY: ${{needs.update-api-specs.outputs.change-log}} | ||
# REPO_NAME: ${{ github.repository }} | ||
triggerCliWorkflow: | ||
runs-on: ubuntu-latest | ||
needs: [ update-api-specs, release] | ||
steps: | ||
- name: Checkout cli-core repo | ||
uses: actions/checkout@v2 | ||
uses: actions/checkout@v4 | ||
- run: | | ||
git pull | ||
make install | ||
|
@@ -178,7 +179,8 @@ jobs: | |
WORKFLOW_NAME: 'release.yml' | ||
BRANCH_NAME: ${{github.event.inputs.cli-branch}} | ||
REPO_NAME: ${{ github.repository_owner }}/twilio-cli | ||
INPUTS: '{ "change-log": ${{ toJSON(needs.update-api-specs.outputs.change-log) }}, "version-type": "${{needs.update-api-specs.outputs.version-type}}", "homebrew-branch": "${{github.event.inputs.homebrew-branch}}", "homebrew-prerelease": "${{github.event.inputs.homebrew-prerelease}}" }' | ||
INPUTS: '{ "change-log": "changelog3", "version-type": "2", "homebrew-branch": "${{github.event.inputs.homebrew-branch}}", "homebrew-prerelease": "${{github.event.inputs.homebrew-prerelease}}" }' | ||
CLI_CORE_TAG: ${{ needs.release.outputs.tag-name }} | ||
# notify-complete-fail: | ||
# if: ${{ (needs.cli-token-validation.result != 'failure' || needs.cli-core-token-validation.result != 'failure' ) && (failure() || cancelled()) }} | ||
# needs: [ triggerCliWorkflow ] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,8 @@ | |
"branches": [ | ||
"main", | ||
{ | ||
"name": "release-feature-branch", | ||
"prerelease": "rc" | ||
"name": "cli-integration-test", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we are not releasing from custom branch, we do not need this change anymore I guess. |
||
"prerelease": "alpha" | ||
} | ||
], | ||
"plugins": [ | ||
|
@@ -58,11 +58,16 @@ | |
"changelogFile": "CHANGES.md" | ||
} | ||
], | ||
"@semantic-release/npm", | ||
[ | ||
"@semantic-release/npm",{ | ||
"npmPublish": false | ||
} | ||
], | ||
[ | ||
"@semantic-release/github", | ||
{ | ||
"successComment": false | ||
"successComment": false, | ||
"npmPublish": false | ||
} | ||
], | ||
[ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this line added? How will this change impact?