diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 81ff6da3..d10f4438 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -41,7 +41,7 @@ jobs: - name: Build and push uses: docker/build-push-action@v2 with: - context: . + context: docker platforms: linux/amd64,linux/arm64,linux/arm/v7 push: ${{ github.event_name != 'pull_request' }} tags: | diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 00000000..8e6777cd --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,33 @@ +name: Make release + +on: + push: + tags: + - v* + branches: + - docker + +jobs: + push-store-image: + runs-on: ubuntu-latest + defaults: + run: + working-directory: "." + steps: + - name: "Checkout GitHub Action" + uses: actions/checkout@main + + - name: "Run release script" + run: npm i && node scripts/gh-release.js + + - name: get-npm-version + id: package-version + uses: martinbeentjes/npm-get-version-action@v1.3.1 + + - name: "Release" + uses: softprops/action-gh-release@v1 + with: + body_path: release-notes.md + files: ./release/*.zip + name: Unchained v${{ steps.package-version.outputs.current-version }} + tag_name: v${{ steps.package-version.outputs.current-version }} diff --git a/.gitignore b/.gitignore index d71700d5..b582e9b8 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ conf.*.yaml .env dist data +release +release-notes.md diff --git a/Dockerfile b/docker/Dockerfile similarity index 100% rename from Dockerfile rename to docker/Dockerfile diff --git a/compose.yaml b/docker/compose.yaml similarity index 100% rename from compose.yaml rename to docker/compose.yaml diff --git a/unchained.sh b/docker/unchained.sh similarity index 100% rename from unchained.sh rename to docker/unchained.sh diff --git a/quickstart.md b/quickstart.md index adff321a..24c44301 100644 --- a/quickstart.md +++ b/quickstart.md @@ -1,15 +1,58 @@ # Quick Start -## Prerequisites +## Using Docker + +Running Unchained with Docker is straightforward. Make sure you +[have Docker installed](https://docs.docker.com/engine/install/). +Then, head over to the +[Unchained release page](https://github.com/KenshiTech/unchained/releases) +on GitHub, find the latest Docker release file (file name ends with +`-docker.zip`), download it, and uncompress it. + +Once done, head to the uncompressed directory and use one of the following +commands in your favorite terminal emulator. + +### Start Node + +To start the node, run this command while in the release directory: + +```bash +./scripts/start_node.sh +``` + +### Stop Node + +To stop the node, run this command while in the release directory: + +```bash +./scripts/stop_node.sh +``` + +### View Node + +To view the node, run this command while in the release directory: + +```bash +./scripts/view_node.sh +``` + +## Installing Locally + +Follow these instructions if you want to install Unchained and its dependencies +locally, on a +[RaspberryPi](https://forum.kenshi.io/t/how-to-set-up-your-unchained-node-on-raspberry-pi/132), +on a server, or on your computer/laptop. + +### Prerequisites To run a Kenshi Unchained validator, you need to install Node.js. Follow the installation instructions for your platform on the Node.js [official installation](https://nodejs.org/en/download/package-manager) page. -## Install the Unchained Client +### Install the Unchained Client -The easiest way to get started is to install the Unchained client globally. -On windows, Linux, MacOS, and BSD, run this command in CMD or terminal: +The easiest way to get the Unchained client is to install it globally. On +windows, Linux, MacOS, and BSD, run this command in CMD or terminal: ```bash npm i -g @kenshi.io/unchained @@ -22,7 +65,7 @@ Note: On UNIX-like operating systems, you might need to run this command with sudo npm i -g @kenshi.io/unchained ``` -### Updates +#### Updates To update the Unchained client, you can re-run the installation command above. Adding `@latest` to the end would result in installing the latest version. @@ -31,7 +74,7 @@ Adding `@latest` to the end would result in installing the latest version. sudo npm i -g @kenshi.io/unchained@latest ``` -## MongoDB +### MongoDB Note: Skip this step if you're planning to run a lite node. @@ -44,12 +87,12 @@ free credits on [Digital Ocean](https://try.digitalocean.com/freetrialoffer/). Contact us on [Telegram](https://t.me/kenshi) if you need help with this step. -### MongoDB Atlas +#### MongoDB Atlas If you want to use MongoDB Atlas, there is a great tutorial you can watch on the [official MongoDB YouTube channel](https://www.youtube.com/watch?v=jXgJyuBeb_o). -### Installing MongoDB Locally +#### Installing MongoDB Locally If you want to install MongoDB locally, first follow the official MongoDB installation @@ -63,7 +106,7 @@ mongodb://localhost:27017/ Replace `` with the name of the database you want to use (for example, `unchained`). -#### Securing Your Local MongoDB +##### Securing Your Local MongoDB To secure your local MongoDB installation, you should first enable DB authentication. To do so, follow the guide @@ -87,7 +130,7 @@ Replace `user` with your username, replace `` with a `` with the name of the database you want to use for Unchained. Your user needs `readWrite` access to this database. -## Configuration +### Configuration You need a configuration file to get started. You can start with the following config: diff --git a/scripts/gh-release.js b/scripts/gh-release.js new file mode 100644 index 00000000..830f59d8 --- /dev/null +++ b/scripts/gh-release.js @@ -0,0 +1,65 @@ +import { writeFileSync, readFileSync, mkdirSync, copyFileSync } from "fs"; +import { dirname } from "path"; +import { execSync } from "child_process"; + +const packageJson = JSON.parse(readFileSync("./package.json")); + +const about = [ + "Unchained is a decentralized, peer-to-peer network for data validation.", + "Unchained nodes work to validate data together and are rewarded in KNS tokens.", + "The validated data can then be queried by consumer in exchange for KNS tokens.", + "Learn more about Unchained [here](https://kenshi.io/docs/unchained).", +].join(" "); + +const questions = [ + "Have any questions? Ask in the [forum](https://forum.kenshi.io/c/unchained),", + "in our [chat](https://t.me/KenshiTech/85602), or send us an", + "[email](mailto:hi@kenshi.io).", +].join(" "); + +const releaseTemplate = (changes) => `\ +${about} + +${questions} + +${changes} + `; + +const makeReleaseNotes = async () => { + const url = + "https://app.whatthediff.ai/changelog/github/KenshiTech/unchained.json"; + const req = await fetch(url); + const notes = await req.json(); + const wtd = notes.changelog.data[0]; + + const changes = wtd.comment.replace(/^## PR Summary/, "## Changes"); + const release = releaseTemplate(changes); + + writeFileSync("./release-notes.md", release); +}; + +const makeReleaseFile = (name, files) => { + const dirName = `unchained-v${packageJson.version}-${name}`; + mkdirSync(`release/${dirName}`, { recursive: true }); + for (const { source, target } of files) { + const dirToMake = dirname(target); + if (dirToMake !== ".") { + mkdirSync(`release/${dirName}/${dirToMake}`, { recursive: true }); + } + copyFileSync(source, `release/${dirName}/${target}`); + } + execSync(`cd release && zip -r ${dirName}.zip ${dirName}`); +}; + +await makeReleaseNotes(); +mkdirSync("./release", { recursive: true }); +makeReleaseFile("docker", [ + { source: "docker/compose.yaml", target: "compose.yaml" }, + { source: "docker/Dockerfile", target: "Dockerfile" }, + { source: "docker/scripts/start_node.sh", target: "scripts/start_node.sh" }, + { source: "docker/scripts/stop_node.sh", target: "scripts/stop_node.sh" }, + { source: "docker/scripts/view_node.sh", target: "scripts/view_node.sh" }, + { source: ".env.template", target: ".env.template" }, + { source: "conf.yaml.template", target: "conf.yaml.template" }, + { source: "LICENSE", target: "LICENSE" }, +]);