diff --git a/.github/workflows/upload-binary.yml b/.github/workflows/upload-binary.yml index e2cf69817..f65fc93f9 100644 --- a/.github/workflows/upload-binary.yml +++ b/.github/workflows/upload-binary.yml @@ -51,42 +51,54 @@ jobs: - uses: actions/setup-node@v1 with: node-version: 16 + - run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} name: Get version id: get_version shell: bash + - run: npm ci name: Install dependencies + - run: npm run pkg -- -t node12-${{ matrix.platform }} name: Pack the binary using vercel/pkg + - run: | echo "::set-output name=NODE_SQLITE_PATH::$(find ./node_modules -name node_sqlite3.node)" name: Find SQLite binary id: find-node-sqlite shell: bash + - run: echo ${{ steps.find-node-sqlite.outputs.NODE_SQLITE_PATH }} name: Check if the SQLite binary is exists shell: bash + - run: cp ${{ steps.find-node-sqlite.outputs.NODE_SQLITE_PATH }} ./dist name: Copy the node sqlite binary shell: bash + - run: file ./dist/* name: List all the files to be compressed shell: bash + - name: Compress all binaries to one zip uses: vimtor/action-zip@v1 with: files: dist/${{ matrix.file_name }} dist/node_sqlite3.node dest: monika-${{ steps.get_version.outputs.VERSION }}-${{ matrix.platform }}.zip + - name: Generate SHA256 Checksum run: shasum -a 256 monika-${{ steps.get_version.outputs.VERSION }}-${{ matrix.platform }}.zip > monika-${{ steps.get_version.outputs.VERSION }}-${{ matrix.platform }}-CHECKSUM.txt + - name: Upload binary to release + id: upload_binary_to_release uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} file: monika-${{ steps.get_version.outputs.VERSION }}-${{ matrix.platform }}.zip asset_name: monika-${{ steps.get_version.outputs.VERSION }}-${{ matrix.platform }}.zip tag: ${{ github.ref }} + - name: Upload checksum to release uses: svenstaro/upload-release-action@v2 with: @@ -94,3 +106,111 @@ jobs: file: monika-${{ steps.get_version.outputs.VERSION }}-${{ matrix.platform }}-CHECKSUM.txt asset_name: monika-${{ steps.get_version.outputs.VERSION }}-${{ matrix.platform }}-CHECKSUM.txt tag: ${{ github.ref }} + + - name: Read checksum file + if: runner.os == 'Windows' + id: checksum_file + uses: juliangruber/read-file-action@v1 + with: + path: monika-${{ steps.get_version.outputs.VERSION }}-win-x64-CHECKSUM.txt + trim: true + + - name: Create chocolatey tools folder + run: mkdir -p ./chocolatey/tools + + - name: Create chocolateyinstall.ps1 file + if: runner.os == 'Windows' + uses: actions/github-script@v6 + with: + script: | + const fs = require('fs'); + const oldString = fs.readFileSync('./chocolatey/example/chocolateyinstall.example.ps1','utf8').toString(); + const releaseUrlString = "${{ steps.upload_binary_to_release.outputs.browser_download_url }}" + const checkSumString = "${{ steps.checksum_file.outputs.content }}".split("*")[0].trim() + const newString = oldString.replace("_RELEASE_URL_", releaseUrlString).replace("_CHECKSUM_CONTENT_", checkSumString); + fs.writeFile("./chocolatey/tools/chocolateyinstall.ps1", newString, { + encoding: "utf8" + }, + (err) => { + if (err) + console.log(err); + else { + console.log("File written successfully\n"); + } + }); + return newString; + result-encoding: string + + - name: See chocolateyinstall.ps1 file content + if: runner.os == 'Windows' + run: cat ./chocolatey/tools/chocolateyinstall.ps1 + + - run: echo ${{ steps.get_version.outputs.VERSION }} | sed 's/^.//' > version_number.txt + name: Write version number without preftix + if: runner.os == 'Windows' + + - name: See version_number.txt content + if: runner.os == 'Windows' + run: cat version_number.txt + + - name: Read version number without preftix + if: runner.os == 'Windows' + id: read_version + uses: juliangruber/read-file-action@v1 + with: + path: version_number.txt + trim: true + + - name: Change version in nuspec file + if: runner.os == 'Windows' + uses: actions/github-script@v6 + with: + script: | + const fs = require('fs'); + const oldString = fs.readFileSync('./chocolatey/example/monika.example.nuspec','utf8').toString(); + const versionString = "${{ steps.read_version.outputs.content }}" + const newString = oldString.replace("_VERSION_", versionString); + fs.writeFile("./chocolatey/monika.nuspec", newString, { + encoding: "utf8" + }, + (err) => { + if (err) + console.log(err); + else { + console.log("File written successfully\n"); + } + }); + return newString; + result-encoding: string + + - name: see nuspec file content + if: runner.os == 'Windows' + run: cat ./chocolatey/monika.nuspec + + - name: Choco pack + if: runner.os == 'Windows' + working-directory: ./chocolatey + run: choco pack + + - name: remove example folder + if: runner.os == 'Windows' + working-directory: ./chocolatey + run: rm -r example + + - name: List all the files in chocolatey folder + if: runner.os == 'Windows' + run: file ./chocolatey/* + + - name: List all the files in chocolatey/tools folder + if: runner.os == 'Windows' + run: file ./chocolatey/tools/* + + - name: Choco set apikey + if: runner.os == 'Windows' + working-directory: ./chocolatey + run: choco apikey --key ${{ secrets.CHOCOLATEY_API_KEY }} --source https://push.chocolatey.org/ + + - name: Choco push + if: runner.os == 'Windows' + working-directory: ./chocolatey + run: choco push monika.1.6.12.nupkg --source https://push.chocolatey.org/ \ No newline at end of file diff --git a/chocolatey/example/chocolateyinstall.example.ps1 b/chocolatey/example/chocolateyinstall.example.ps1 new file mode 100644 index 000000000..93883287a --- /dev/null +++ b/chocolatey/example/chocolateyinstall.example.ps1 @@ -0,0 +1,13 @@ +$ErrorActionPreference = 'Stop'; +$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)" +$url64 = '_RELEASE_URL_' + +$packageArgs = @{ + packageName = 'monika' + unzipLocation = $toolsDir + url64bit = $url64 + checksum64 = '_CHECKSUM_CONTENT_' + checksumType64= 'sha256' +} + +Install-ChocolateyZipPackage @packageArgs \ No newline at end of file diff --git a/chocolatey/example/monika.example.nuspec b/chocolatey/example/monika.example.nuspec new file mode 100644 index 000000000..bb7525b70 --- /dev/null +++ b/chocolatey/example/monika.example.nuspec @@ -0,0 +1,16 @@ + + + + monika + _VERSION_ + monika (Install) + raosan + https://monika.hyperjump.tech/ + https://cdn.statically.io/gh/hyperjumptech/monika/main/docs/public/monika.svg + monika monitoring + Monika - Free and Open Source Synthetic Monitoring Tool + + + + + \ No newline at end of file diff --git a/docs/src/pages/quick-start.md b/docs/src/pages/quick-start.md index 43f556540..22e0dfb1c 100644 --- a/docs/src/pages/quick-start.md +++ b/docs/src/pages/quick-start.md @@ -41,6 +41,14 @@ There are many ways to install Monika [![Get it from the Snap Store](https://snapcraft.io/static/images/badges/en/snap-store-black.svg)](https://snapcraft.io/monika) +5. Install via [Chocolatey](https://community.chocolatey.org/packages/monika) (**Windows**) + + If you are using Windows and familliar with chocolatey, you can search the monika package in [Chocolatey Community Repository](https://community.chocolatey.org/). Type in `monika` in the search bar and you will find the package, then you can see the package detail and install it with just this command in Windows Power Shell (With Administrator permission) + + ``` + choco install monika + ``` + ## Download the configuration file Download the example configuration that uses Desktop notification [here](https://raw.githubusercontent.com/hyperjumptech/monika/main/config_sample/config.desktop.example.yml) and rename it as monika.yml