-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added check release for Trezor. Fixed seedsigner check release
- Loading branch information
1 parent
797d7ca
commit c8d9039
Showing
4 changed files
with
172 additions
and
1 deletion.
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,43 @@ | ||
name: Check Releases Template | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
item-id: | ||
required: true | ||
type: string | ||
changelog-url: | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
check-release: | ||
runs-on: ubuntu-latest | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: 14 | ||
|
||
- name: Install dependencies | ||
run: npm install | ||
working-directory: scripts | ||
|
||
- name: Run script | ||
run: node github-release.js ${{ inputs.item-id }} ${{ inputs.changelog-url }} | ||
working-directory: scripts | ||
|
||
- name: Create Pull Request | ||
uses: peter-evans/[email protected] | ||
with: | ||
title: "New ${{ inputs.item-id }} release" | ||
commit-message: "New ${{ inputs.item-id }} release" | ||
branch: "${{ inputs.item-id }}/new-release" | ||
add-paths: "items/*.json" | ||
assignees: "${{ secrets.ASSIGNEE }}" |
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
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,118 @@ | ||
require('dotenv').config(); | ||
const fs = require('fs'); | ||
const axios = require('axios'); | ||
|
||
const itemId = process.argv[2]; | ||
const changelogUrl = process.argv[3]; | ||
|
||
var latestVersion | ||
var latestReleaseDate | ||
|
||
axios | ||
.get(changelogUrl) | ||
.then((response) => { | ||
var body = response.data | ||
// Split the content into lines | ||
const lines = body.split('\n'); | ||
|
||
// Find the first line starting with "##" | ||
const regex = /^## \[([\d.]+)\] \(([^)]+)\)/; | ||
for (const line of lines) { | ||
const match = line.match(regex); | ||
if (match) { | ||
latestVersion = "v" + match[1]; | ||
latestReleaseDate = formatDate(match[2]); | ||
break; | ||
} | ||
} | ||
|
||
console.log(`Sanitized version: ${latestVersion}`); | ||
console.log(`Release Date: ${latestReleaseDate}`); | ||
updateJson(itemId, latestVersion, latestReleaseDate); | ||
|
||
}) | ||
.catch((error) => { | ||
console.error('Error fetching release information:', error.message); | ||
process.exit(1); | ||
}); | ||
|
||
function formatDate(inputDate) { | ||
// Define months for formatting | ||
const months = [ | ||
"January", "February", "March", "April", "May", "June", | ||
"July", "August", "September", "October", "November", "December" | ||
]; | ||
|
||
// Split the input date string into parts | ||
const parts = inputDate.match(/(\d+)\w+\s(\w+)\s(\d+)/); | ||
|
||
if (parts && parts.length === 4) { | ||
const day = parseInt(parts[1]); | ||
const monthIndex = months.indexOf(parts[2]); | ||
const year = parseInt(parts[3]); | ||
|
||
if (monthIndex !== -1) { | ||
// Create a JavaScript Date object | ||
const date = new Date(year, monthIndex, day); | ||
|
||
// Format the date in the desired output format (e.g., "Jul 27, 2023") | ||
const formattedDate = `${months[date.getMonth()]} ${date.getDate()}, ${date.getFullYear()}`; | ||
return formattedDate; | ||
} | ||
} | ||
|
||
// Return the original input if parsing fails | ||
return inputDate; | ||
} | ||
|
||
function updateJson(itemId, latestVersion, latestReleaseDate) { | ||
// Define the path to your JSON file. | ||
const filePath = `./items/${itemId}.json`; | ||
|
||
// Read the JSON file. | ||
fs.readFile(filePath, 'utf8', (err, data) => { | ||
if (err) { | ||
console.error('Error reading JSON file:', err); | ||
return; | ||
} | ||
|
||
try { | ||
const wallet = JSON.parse(data); | ||
var modifyJson = false | ||
|
||
console.log("Updating hardware wallet firmware") | ||
|
||
var currentVersion = wallet["firmware"]["latest-version"].value | ||
console.log("Current version found: " + currentVersion) | ||
if (latestVersion !== currentVersion) { | ||
wallet["firmware"]["latest-version"].value = latestVersion | ||
modifyJson = true | ||
} | ||
|
||
var currentReleaseDate = wallet["firmware"]["latest-release-date"].value | ||
if (latestReleaseDate !== currentReleaseDate) { | ||
wallet["firmware"]["latest-release-date"].value = latestReleaseDate | ||
modifyJson = true | ||
} | ||
console.log("Current Release date found: " + currentReleaseDate) | ||
|
||
if (modifyJson) { | ||
// Convert the modified object back to a JSON string. | ||
const updatedJsonString = JSON.stringify(wallet, null, 2); | ||
|
||
// Write the updated JSON string back to the file. | ||
fs.writeFile(filePath, updatedJsonString, (writeErr) => { | ||
if (writeErr) { | ||
console.error('Error writing JSON file:', writeErr); | ||
} else { | ||
console.log('JSON file updated successfully.'); | ||
} | ||
}); | ||
} | ||
|
||
} catch (parseError) { | ||
console.error('Error parsing JSON:', parseError); | ||
process.exit(1); | ||
} | ||
}); | ||
} |
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