-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Jenkins automation for IBM i release builds
- Loading branch information
Showing
2 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
pipeline { | ||
agent { | ||
node { | ||
label 'ibmi7.3' | ||
} | ||
} | ||
environment { | ||
NODE_PATH = '/QOpenSys/pkgs/lib/nodejs18/bin' | ||
} | ||
stages { | ||
stage('build') { | ||
steps { | ||
sh ''' | ||
export PATH=$NODE_PATH:$PATH | ||
npm ci --production | ||
./node_modules/.bin/node-pre-gyp rebuild --production | ||
./node_modules/.bin/node-pre-gyp package | ||
''' | ||
} | ||
} | ||
stage('update-gh-release') { | ||
environment { | ||
GH_TOKEN = credentials('node-odbc-gh-token') | ||
} | ||
steps { | ||
sh ''' | ||
export PATH=$NODE_PATH:$PATH | ||
export GITHUB_TOKEN=$GH_TOKEN_PSW | ||
node .github/upload-release-asset.js build/stage/*.tar.gz | ||
''' | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
const fs = require('fs'); | ||
const path = require('node:path'); | ||
|
||
const tag = process.env.TAG_NAME; | ||
const token = process.env.GITHUB_TOKEN; | ||
const files = process.argv.slice(2); | ||
|
||
if (!tag) { | ||
console.error("Must set TAG_NAME environment variable"); | ||
process.exit(1); | ||
} | ||
if (!token) { | ||
console.error("Must set GITHUB_TOKEN environment variable"); | ||
process.exit(1); | ||
} | ||
if (!files.length) { | ||
console.error("No files passed"); | ||
process.exit(1); | ||
} | ||
|
||
const options = { | ||
headers: { | ||
"Authorization": `Bearer ${token}`, | ||
"X-GitHub-Api-Version": "2022-11-28", | ||
"Accept": "application/vnd.github+json", | ||
"Content-Type": "application/octet-stream", | ||
} | ||
}; | ||
|
||
(async function script() { | ||
const response = await fetch(`https://api.github.com/repos/IBM/node-odbc/releases/tags/${tag}`); | ||
|
||
if (!response.ok) { | ||
console.error(`ERROR: Getting release failed: ${response.status}`) | ||
process.exit(1); | ||
} | ||
|
||
const release_obj = await response.json(); | ||
|
||
// Returns a goofy URL "template", get rid of the parameters | ||
const upload_url = release_obj.upload_url.substr(0, release_obj.upload_url.indexOf('{'));; | ||
|
||
for (const file of files) { | ||
const name = path.basename(file); | ||
console.log(`Uploading ${file} -> ${name}`); | ||
|
||
const content = fs.readFileSync(file); | ||
|
||
const response = await fetch(`${upload_url}?name=${name}`, { | ||
method: "POST", | ||
body: content, | ||
...options | ||
}); | ||
|
||
if (!response.ok) { | ||
console.error(`ERROR: Upload of ${file} failed: ${response.status}`) | ||
process.exit(1); | ||
} | ||
} | ||
})(); |