Skip to content

Commit

Permalink
feature: create release script (#2494)
Browse files Browse the repository at this point in the history
* Bump version to 2.17.5

* Adds create-release command and script

* Bump version to 2.17.6

* Bump version to 2.17.7

* Bump version to 2.17.5

* Bump version to 2.17.5

* Bump version to 2.17.6

* Bump version to 2.17.5

* Update create-release.js

* Bump version to 2.17.5

* Update create-release.js

* Bump version to 2.17.5

* Updates README.md
  • Loading branch information
comountainclimber authored May 22, 2023
1 parent 047f753 commit 9c8c97a
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 25 deletions.
24 changes: 19 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,8 @@ Execute these commands in the project's root directory:

Setup:

- `yarn install` - Installing node dependencies
- `yarn` - Installing node dependencies
- If you get any errors related to the node-hid package, please check installation instructions here: https://github.com/node-hid/node-hid#compiling-from-source. On Linux you may need to run `sudo apt install libusb-1.0-0 libusb-1.0-0-dev`, for example.
- `./node_modules/.bin/electron -v` confirm electron is version 1.8.4
- Electron may take anywhere from 10 to 15 seconds to fully start using the commands below. Be patient.

Developing:

Expand All @@ -87,6 +85,22 @@ A gentle reminder, github issues are meant to be used by developers for maintain

should be asked in proper support channels such as the [NEO subreddit](https://www.reddit.com/r/NEO/), or the official [NEO Discord Channel](https://discord.gg/R8v48YA). You should also check the list of [frequently asked questions (FAQ)](https://github.com/CityOfZion/awesome-NEO/blob/master/resources/faq.md) to see if your question has been answered there already.

### Contributing
### Releasing

Contributing to neon-wallet is eligible for rewards distributed in NEO via the [City of Zion](https://github.com/CityOfZion/standards/blob/master/Introduction.md). Open issues are categorized into high, medium and low impact to roughly group issues and feature requests into their significance and impact to the project. These categories generally correspond to the level of reward that will be distributed upon completion of the issue. Additionally, QA testing, pull request review and creation of issues are also all items eligible for contribution rewards.
- To bump the patch version:

```
yarn create-release:patch
```

- To bump the minor version:

```
yarn create-release:minor
```

- To bump the major version:

```
yarn create-release:major
```
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
"test:e2e": "ava __e2e__/*.e2e.js --timeout=120s -s",
"test-watch": "jest --watch",
"pack": "build --dir",
"create-release:patch": "node scripts/create-release.js patch",
"create-release:minor": "node scripts/create-release.js minor",
"create-release:major": "node scripts/create-release.js major",
"release": "yarn assets && yarn electron-builder --publish always",
"release:mac": "yarn assets && yarn electron-builder --publish always --mac --x64 --arm64",
"dist": "yarn assets && dotenv yarn electron-builder",
Expand Down Expand Up @@ -311,4 +314,4 @@
"setupTestFrameworkScriptFile": "<rootDir>/__tests__/setupTests.js",
"testURL": "http://localhost"
}
}
}
70 changes: 70 additions & 0 deletions scripts/create-release.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
const fs = require('fs')
const { execSync } = require('child_process')

// Helper function to bump the version
function bumpVersion(version, versionChangeType) {
const parts = version.split('.')

// eslint-disable-next-line default-case
switch (versionChangeType) {
case 'patch':
parts[2] = Number(parts[2]) + 1 // Bump patch version
break
case 'minor':
parts[1] = Number(parts[1]) + 1 // Bump minor version
parts[2] = 0 // Reset patch version
break
case 'major':
parts[0] = Number(parts[0]) + 1 // Bump major version
parts[1] = 0 // Reset minor version
parts[2] = 0 // Reset patch version
break
}

return parts.join('.')
}

// Read package.json
const packageJsonPath = 'package.json'
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath))

// Determine the version change type
const validVersionChangeTypes = ['patch', 'minor', 'major']
const versionChangeType = process.argv[2]

if (!validVersionChangeTypes.includes(versionChangeType)) {
console.error(
'Invalid version change type. Please specify either "patch", "minor", or "major".',
)
process.exit(1)
}

// Bump version
const currentVersion = packageJson.version
const newVersion = bumpVersion(currentVersion, versionChangeType)
packageJson.version = newVersion

// Write updated package.json
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2))

// Commit and push the changes
try {
execSync('git add package.json')
execSync(`git commit -m "Bump version to ${newVersion}"`)
execSync('git push origin HEAD --no-verify')
} catch (error) {
console.error('Error occurred during commit and push:', error)
}

// Create and push the tag
try {
execSync(`git tag v${newVersion}`)
execSync(`git push origin v${newVersion} --no-verify`)
} catch (error) {
console.error('Error occurred during tag creation and push:', error)
}

// eslint-disable-next-line
console.log(
`Version bumped to ${newVersion}, and a draft release will be created automatically 🚀...`,
)
19 changes: 0 additions & 19 deletions scripts/release-master.sh

This file was deleted.

0 comments on commit 9c8c97a

Please sign in to comment.