diff --git a/.github/workflows/deb_packager.yml b/.github/workflows/deb_packager.yml new file mode 100644 index 000000000..10eca7717 --- /dev/null +++ b/.github/workflows/deb_packager.yml @@ -0,0 +1,102 @@ +name: deb_packager + +on: + push: + branches: + - 'main' + paths: + - '**' + tags: + - 'v*.*.*' + - 'v*.*.*-*' + +jobs: + build: + permissions: + id-token: write + contents: write + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + ##### TAG Variable ##### + - name: Adding TAG to ENV + run: echo "GIT_TAG=`echo $(git describe --tags --abbrev=0)`" >> $GITHUB_ENV + - name: adding version + run: | + NUMERIC_VERSION=$( echo ${{ env.GIT_TAG }} | sed 's/[^0-9.]//g' ) + echo "VERSION=$NUMERIC_VERSION" >> $GITHUB_ENV + + - name: cleaning repo + run: cargo clean + + - name: Building for amd64 + run: cargo build --release + + - name: create packaging subdir + run: mkdir -p packaging/deb/miden-node/DEBIAN + + - name: making directory for binary + run: mkdir -p packaging/deb/miden-node/usr/bin + + - name: create systemd location + run: mkdir -p packaging/deb/miden-node/lib/systemd/system + + - name: copy the miden-node service file + run: cp packaging/miden-node.service packaging/deb/miden-node/lib/systemd/system/ + + - name: make directory for example configs + run: mkdir -p packaging/deb/miden-node/etc/miden + + - name: copy the miden-node.toml file + run: cp node/miden.toml packaging/deb/miden-node/etc/miden/ + + - name: copy over the postinst + run: cp packaging/postinst packaging/deb/miden-node/DEBIAN/postinst + + - name: copy over the postrm + run: cp packaging/postrm packaging/deb/miden-node/DEBIAN/postrm + + - name: copying over the build + run: cp -rp target/release/miden-node packaging/deb/miden-node/usr/bin/ + + ########### Control file creation for amd64 ########## + - name: create control file + run: | + touch packaging/deb/miden-node/DEBIAN/control + echo "Package: miden-node" >> packaging/deb/miden-node/DEBIAN/control + echo "Version: ${{ env.VERSION }}" >> packaging/deb/miden-node/DEBIAN/control + echo "Section: base" >> packaging/deb/miden-node/DEBIAN/control + echo "Priority: optional" >> packaging/deb/miden-node/DEBIAN/control + echo "Architecture: amd64" >> packaging/deb/miden-node/DEBIAN/control + echo "Maintainer: Polygon Devops " >> packaging/deb/miden-node/DEBIAN/control + echo "Description: miden-node binary package" >> packaging/deb/miden-node/DEBIAN/control + echo "Homepage: https://polygon.technology/polygon-miden" >> packaging/deb/miden-node/DEBIAN/control + echo "Vcs-Git: git@github.com:0xPolygonMiden/miden-node.git" >> packaging/deb/miden-node/DEBIAN/control + echo "Vcs-Browser: https://github.com/0xPolygonMiden/miden-node" >> packaging/deb/miden-node/DEBIAN/control + + - name: Creating package for binary for miden-node ${{ env.ARCH }} + run: cp -rp packaging/deb/miden-node packaging/deb/miden-node-${{ env.GIT_TAG }}-${{ env.ARCH }} + env: + ARCH: amd64 + + - name: Running package build + run: dpkg-deb --build --root-owner-group packaging/deb/miden-node-${{ env.GIT_TAG }}-${{ env.ARCH }} + env: + ARCH: amd64 + + - name: shasum the package + run: cd packaging/deb/ && sha256sum miden-node-${{ env.GIT_TAG }}-${{ env.ARCH }}.deb > miden-node-${{ env.GIT_TAG }}-${{ env.ARCH }}.deb.checksum + env: + ARCH: amd64 + + - name: release miden-node Packages + uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ env.GIT_TAG }} + prerelease: true + files: | + packaging/deb/miden-node**.deb + packaging/deb/miden-node**.deb.checksum \ No newline at end of file diff --git a/README.md b/README.md index 7ca94f900..58fee8cef 100644 --- a/README.md +++ b/README.md @@ -91,5 +91,28 @@ Please, refer to each component's documentation: Each directory containing the executables also contains an example configuration file. Make sure that the configuration files are mutually consistent. That is, make sure that the URLs are valid and point to the right endpoint. + +### Debian Packages + +The debian packages allow for easy install for miden on debian based systems. Note that there are checksums available for the package. +Current support is for amd64, arm64 support coming soon. + +To install the debian package: +```sh +sudo dpkg -i $package_name.deb +``` +Note, when using the debian package to run the `make-genesis` function, you should define the location of your output: +```sh +miden-node make-genesis -i $input_location_for_gensis.toml -o $output_for_gensis.dat_and_accounts +``` +The debian package has a checksum, you can verify this checksum by download the debian package and checksum file to the same directory and running the following command: +```sh +sha256sum --check $checksumfile +``` +Please make sure you have the sha256sum program installed, for most linux operating systems this is already installed. If you wish to installe it on your macOS, you can use brew: +```sh +brew install coreutils +``` + ## License This project is [MIT licensed](./LICENSE). diff --git a/packaging/genesis.toml b/packaging/genesis.toml new file mode 100644 index 000000000..5cf53bb9b --- /dev/null +++ b/packaging/genesis.toml @@ -0,0 +1,18 @@ +# This is an example genesis input file for the Miden node. +version = 1 +timestamp = 1672531200 + +[[accounts]] +type = "BasicWallet" +init_seed = "0xa123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" +auth_scheme = "RpoFalcon512" +auth_seed = "0xb123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" + +[[accounts]] +type = "BasicFungibleFaucet" +init_seed = "0xc123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" +auth_scheme = "RpoFalcon512" +auth_seed = "0xd123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" +token_symbol = "POL" +decimals = 12 +max_supply = 1000000 diff --git a/packaging/miden-node.service b/packaging/miden-node.service new file mode 100644 index 000000000..bd7882b82 --- /dev/null +++ b/packaging/miden-node.service @@ -0,0 +1,15 @@ +[Unit] +Description=Miden node +Wants=network-online.target + +[Install] +WantedBy=multi-user.target + +[Service] +Type=exec +Environment="RUST_LOG=info" +ExecStart=miden-node start --config /etc/miden/miden.toml +WorkingDirectory=/opt/miden +User=miden +RestartSec=5 +Restart=always \ No newline at end of file diff --git a/packaging/miden.toml b/packaging/miden.toml new file mode 100644 index 000000000..7bdcfadf9 --- /dev/null +++ b/packaging/miden.toml @@ -0,0 +1,18 @@ +# This is an example configuration file for the Miden node. + +[block_producer] +# port defined as: sum(ord(c)**p for (p, c) in enumerate('miden-block-producer', 1)) % 2**16 +endpoint = { host = "localhost", port = 48046 } +store_url = "http://localhost:28943" + +[rpc] +# port defined as: sum(ord(c)**p for (p, c) in enumerate('miden-rpc', 1)) % 2**16 +endpoint = { host = "localhost", port = 57291 } +block_producer_url = "http://localhost:48046" +store_url = "http://localhost:28943" + +[store] +# port defined as: sum(ord(c)**p for (p, c) in enumerate('miden-store', 1)) % 2**16 +endpoint = { host = "localhost", port = 28943 } +database_filepath = "/opt/miden/miden-store.sqlite3" +genesis_filepath = "/opt/miden/genesis.dat" diff --git a/packaging/postinst b/packaging/postinst new file mode 100755 index 000000000..96183d714 --- /dev/null +++ b/packaging/postinst @@ -0,0 +1,12 @@ +#!/bin/bash +# This is a postinstallation script so the service can be configured and started when requested +# +sudo adduser --disabled-password --disabled-login --shell /usr/sbin/nologin --quiet --system --no-create-home --home /nonexistent miden +if [ -d "/opt/miden" ] +then + echo "Directory /opt/miden exists." +else + mkdir -p /opt/miden + sudo chown -R miden /opt/miden +fi +sudo systemctl daemon-reload \ No newline at end of file diff --git a/packaging/postrm b/packaging/postrm new file mode 100755 index 000000000..2b8806559 --- /dev/null +++ b/packaging/postrm @@ -0,0 +1,8 @@ +#!/bin/bash +# +############### +# Remove miden installs +############## +sudo rm -rf /lib/systemd/system/miden-node.service +sudo deluser miden +sudo systemctl daemon-reload \ No newline at end of file