Skip to content
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

Set stable tag #3084

Merged
merged 5 commits into from
Dec 18, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add setTag action
  • Loading branch information
mcm1957 committed Dec 18, 2023
commit 55beef409899503d93fd78f9a62ec6d4517d5b6d
33 changes: 33 additions & 0 deletions .github/workflows/setTag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Manual action

# configure manual trigger
on:
workflow_dispatch:
inputs:
action:
type: choice
description: action to perform
options:
- closeIssue
- reopenIssue
required: true
repository:
type: string
issue:
type: string

jobs:
manual-action:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
- run: npm i
- run: npm run manualAction
env:
OWN_GITHUB_TOKEN: ${{ secrets.OWN_GITHUB_TOKEN }}
ACTION: ${{ github.event.inputs.action }}
REPOSITORY: ${{ github.event.inputs.repository }}
ISSUE: ${{ github.event.inputs.issue }}
63 changes: 63 additions & 0 deletions lib/setTag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
'use strict';

const execSync = require('child_process').execSync;

const {
// addComment,
// addLabel,
// getGithub,
getUrl,
// getAllComments,
// deleteComment
} = require('./common');

async function getNpmMeta( pAdapter ) {
return await getUrl(`https://registry.npmjs.org/iobroker.${pAdapter}`);
};

async function getNpmDisttags(pAdapter) {
const npmMeta = await getNpmMeta( pAdapter );
return npmMeta['dist-tags'];
};


async function doIt() {

const npmTags=await getNpmDisttags(`${process.env.INPUT_ADAPTER}`);
const npmRelease = npmTags[`${process.env.INPUT_TAG}`] || '0.0.0';
const targetRelease = `${process.env.INPUT_RELEASE}`;

if (targetRelease === npmRelease) {
console.log (`iobroker.${process.env.INPUT_ADAPTER} ${targetRelease} correctly tagged as ${process.env.INPUT_TAG}`)
} else {
if ( npmRelease === '0.0.0' ) {
console.log (`iobroker.${process.env.INPUT_ADAPTER} does not provide a tag ${process.env.INPUT_TAG}`)
}
console.log (`iobroker.${process.env.INPUT_ADAPTER} ${targetRelease} need to be tagged as ${process.env.INPUT_TAG}`)
console.log( `executing npm --//registry.npmjs.org/:_authToken=*** dist-tag add iobroker.${process.env.INPUT_ADAPTER}@${targetRelease} ${process.env.INPUT_TAG}`);
const cmd = `npm --//registry.npmjs.org/:_authToken=${process.env.NPM_TOKEN} dist-tag add iobroker.${process.env.INPUT_ADAPTER}@${targetRelease} ${process.env.INPUT_TAG}`;
try {

Check notice

Code scanning / CodeQL

Syntax error Note

Error: Missing catch or finally clause
const result=execSync( cmd, { encoding: 'utf-8' });
// console.log(result);
// } catch (_e) {
// // console.log (JSON.stringify(e));
// }
}

return 'done';
}

// activate for debugging purposes
//process.env.GITHUB_REF = 'refs/pull/2298/merge';
//process.env.OWN_GITHUB_TOKEN = 'add-token-here';
//process.env.GITHUB_EVENT_PATH = __dirname + '/../event.json';

console.log(`process.env.OWN_GITHUB_TOKEN = ${(process.env.OWN_GITHUB_TOKEN || '').length}`);
console.log(`process.env.NPM_TOKEN = ${(process.env.NPM_TOKEN || '').length}`);
console.log(`process.env.INPUT_TAG = ${(process.env.INPUT_TAG || '')}`);
console.log(`process.env.INPUT_ADAPTER = ${(process.env.INPUT_ADAPTER || '')}`);
console.log(`process.env.INPUT_RELEASE = ${(process.env.INPUT_RELEASE || '')}`);

doIt()
.then(result => console.log(result))
.catch(e => console.error(e));
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@
"manualAction": "node lib/manualAction.js",
"setLabels": "node lib/setLabels.js",
"setStableTag": "node lib/setStableTag.js",
"setTag": "node lib/setTag.js",
"stable": "node lib/readyForStable.js",
"stableBrandNewInfo": "node lib/stableBrandNewInfo.js",
"stableBrandNewReminder": "node lib/stableBrandNewReminder.js"