v1.15.4 #41
Workflow file for this run
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 workflow will run tests using node and then publish a package to GitHub Packages when a release is created | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages | |
name: Upload Binary | |
on: | |
workflow_dispatch: | |
release: | |
types: [published] | |
permissions: | |
issues: read | |
pull-requests: read | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-node@v1 | |
with: | |
node-version: 16 | |
- run: npm ci | |
name: Install dependencies | |
- run: npm run build -w packages/notification | |
- run: npm test | |
name: Run tests | |
- run: npm pack | |
name: Pack using npm pack | |
- run: npm install -g ./hyperjumptech-monika-*.tgz | |
name: Install the packed npm package | |
- run: npm run prod_test | |
name: Run production test | |
upload: | |
needs: test | |
name: Publish for ${{ matrix.os }} | |
runs-on: ${{ matrix.runs_on }} | |
strategy: | |
matrix: | |
include: | |
- os: Linux | |
runs_on: ubuntu-latest | |
platform: linux-x64 | |
file_name: monika | |
- os: Windows | |
runs_on: windows-latest | |
platform: win-x64 | |
file_name: monika.exe | |
- os: MacOS | |
runs_on: macos-latest | |
platform: macos-x64 | |
file_name: monika | |
steps: | |
- uses: actions/checkout@v2 | |
- 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 build -w packages/notification | |
- run: npm run pkg -- -t node16-${{ matrix.platform }} | |
name: Pack the binary using vercel/pkg | |
- 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 }} | |
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: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
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 prefix | |
if: runner.os == 'Windows' | |
- name: See version_number.txt content | |
if: runner.os == 'Windows' | |
run: cat version_number.txt | |
- name: Read version number without prefix | |
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.${{ steps.read_version.outputs.content }}.nupkg --source https://push.chocolatey.org/ |