Skip to content

Commit

Permalink
tools: add build tools and scripts
Browse files Browse the repository at this point in the history
This commit contains the files and the scripts which are necessary to build, package, and publish the LogDNA Agent for Linux, Win32 and Mac Systems. Some parts have been taken from [Gruntfile](https://github.com/logdna/logdna-agent/blob/master/Gruntfile.js) and some have been taken from the internal instances.

Semver: patch
Ref: LOG-5336, LOG-5337, LOG-5338, LOG-5339
  • Loading branch information
Samir Musali authored and smusali committed Aug 20, 2020
1 parent e2d374e commit 45964da
Show file tree
Hide file tree
Showing 25 changed files with 667 additions and 98 deletions.
22 changes: 8 additions & 14 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,20 @@
logs
*.log

# dependencies
node_modules

# builds
.build
.builds
logdna-agent.exe
tmp

# packages
**/*.deb
**/*.rpm
**/*.exe
**/*.nupkg
**/*.pkg

# Test directory
.temp
Expand All @@ -24,22 +31,9 @@ lib-cov
# Coverage directory used by tools like istanbul
coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules
./logdna-agent
*.pkg
*.tgz

# Some extra data
package-lock.json
*~
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ LABEL org.label-schema.vcs-url="https://github.com/logdna/logdna-agent"
LABEL org.label-schema.vendor="LogDNA Inc."
LABEL org.label-schema.docker.cmd="docker run logdna/logdna-agent:latest"

COPY logdna.gpg /etc/
COPY tools/files/logdna.gpg /etc/

RUN echo "deb http://repo.logdna.com stable main" > /etc/apt/sources.list.d/logdna.list && \
apt-key add /etc/logdna.gpg && \
Expand Down
72 changes: 0 additions & 72 deletions Gruntfile.js

This file was deleted.

21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2020 LogDNA

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
7 changes: 0 additions & 7 deletions LICENSE.md

This file was deleted.

4 changes: 0 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@
"eslint": "^7.6.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-sensible": "^2.2.0",
"grunt": "^1.0.4",
"grunt-contrib-copy": "^1.0.0",
"grunt-exec": "^3.0.0",
"load-grunt-tasks": "^5.1.0",
"tap": "^14.10.8"
}
}
92 changes: 92 additions & 0 deletions tools/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# How to Build

## Requirements
- Update the [`CHANGELOG`](../CHANGELOG.md)
- Update the `version` in [`package.json`](../package.json#L3)
- Update the `version` in [`logdna-agent.rb`](./files/darwin/logdna-agent.rb#L2)
- Update the `version` in [`logdna-agent.nuspec`](./files/win32/logdna-agent.nuspec#L7)

## LogDNA Agent for Debian Systems
LogDNA Agent can be built and released for Debian systems by running the `scripts/debian.sh` script:
`bash tools/scripts/debian.sh`

### Dependencies
- `Node.js: v8.3.0` and `NPM: v5.3.0`
- `NEXE: v3.3.3` by `npm install -g [email protected]`
- `fpm` by `sudo gem install --no-document fpm`
- `ghr` by `go get -u github.com/tcnksm/ghr`
- `deb-s3` by `sudo gem install deb-s3`

### Environment Variables
- `AWS_ACCESS_KEY`
- `AWS_SECRET_KEY`
- `GITHUB_API_TOKEN`

### Steps
1. Compile the source code into the executable
2. Package the executable into the Debian package
3. Create / Update the GitHub Release for the specified tag by uploading the Debian package
4. Publish the Debian package into the specified S3 bucket

## LogDNA Agent for RedHat Systems
LogDNA Agent can be built and released for RedHat systems by running the `scripts/redhat.sh` script from the project directory:
`bash tools/scripts/redhat.sh`

### Dependencies
- `Node.js: v8.3.0` and `NPM: v5.3.0`
- `NEXE: v3.3.3` by `npm install -g [email protected]`
- `fpm` by `sudo gem install --no-document fpm`
- `ghr` by `go get -u github.com/tcnksm/ghr`
- `rpm-s3` by `git clone https://github.com/crohr/rpm-s3 --recurse-submodules`

### Environment Variables
- `AWS_ACCESS_KEY`
- `AWS_SECRET_KEY`
- `GITHUB_API_TOKEN`

### Steps
1. Compile the source code into the executable
2. Package the executable into the RedHat package
3. Create / Update the GitHub Release for the specified tag by uploading the RedHat package
4. Publish the RedHat package into the specified S3 bucket

## LogDNA Agent for Darwin Systems
LogDNA Agent can be built and released for Darwin systems by running the `scripts/darwin.sh` script from the project directory:
`bash tools/scripts/darwin.sh`

### Dependencies
- `Node.js: v8.3.0` and `NPM: v5.3.0`
- `NEXE: v3.3.3` by `npm install -g [email protected]`
- `fpm` by `sudo gem install --no-document fpm`
- `ghr` by `brew install ghr`

### Environment Variables
- `GITHUB_API_TOKEN`

### Steps
1. Compile the source code into the executable
2. Package the executable into the MacOSX package
3. Create / Update the GitHub Release for the specified tag by uploading the MacOSX package
4. Sign the MacOSX package using the private keychain
5. Publish the MacOSX package by creating a Pull Request to update [logdna-agent.rb](https://github.com/Homebrew/homebrew-cask/blob/master/Casks/logdna-agent.rb) using [logdna-bot/homebrew-cask](https://github.com/logdnabot/homebrew-cask)

## LogDNA Agent for Win32 Systems
LogDNA Agent can be built and released for Win32 systems by running the `scripts/win32.sh` script from the project directory:
`./tools/scripts/win32.sh`

### Dependencies
- `choco` by `iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))` on `PowerShell`
- `nssm` by `choco install -y nssm`
- `Node.js: v8.3.0` and `NPM: v5.3.0` by `choco install nodejs --version=8.3.0`
- `NEXE: v3.3.3` by `npm install -g [email protected]`
- `ghr` by `go get -u github.com/tcnksm/ghr`

### Environment Variables
- `GITHUB_API_TOKEN`
- `CHOCO_API_KEY`

### Steps
1. Compile the source code into the executable
2. Package the executable into the NuPKG package
3. Create / Update the GitHub Release for the specified tag by uploading the NuPKG package
4. Publish the NuPKG package into [Chocolatey](https://chocolatey.org/packages/logdna-agent)
22 changes: 22 additions & 0 deletions tools/files/darwin/com.logdna.logdna-agent.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>com.logdna.logdna-agentd</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/logdna-agent</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StandardErrorPath</key>
<string>/Library/Logs/logdna-agent.log</string>
<key>StandardOutPath</key>
<string>/Library/Logs/logdna-agent.log</string>
</dict>
</plist>
23 changes: 23 additions & 0 deletions tools/files/darwin/logdna-agent.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
cask 'logdna-agent' do
version '1.6.2'
sha256 '350956cbeddf0f0b1cf991a58d659e2a4c2344b621370e10c8adb950f9c6bc47'

# github.com/logdna/logdna-agent was verified as official when first introduced to the cask
url "https://github.com/logdna/logdna-agent/releases/download/#{version}/logdna-agent-#{version}.pkg"
appcast 'https://github.com/logdna/logdna-agent/releases.atom'
name 'LogDNA Agent'
homepage 'https://logdna.com/'

pkg "logdna-agent-#{version}.pkg"

uninstall pkgutil: 'com.logdna.logdna-agent',
launchctl: 'com.logdna.logdna-agentd'

caveats <<~EOS
When you first start logdna-agent, you must set your LogDNA API key with the command:
sudo logdna-agent -k <api-key>
To always run logdna-agent in the background, use the command:
sudo launchctl load -w /Library/LaunchDaemons/com.logdna.logdna-agent.plist
EOS
end
3 changes: 3 additions & 0 deletions tools/files/darwin/mac-after-install
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
sudo chown root:wheel /Library/LaunchDaemons/com.logdna.logdna-agent.plist
sudo chmod 644 /Library/LaunchDaemons/com.logdna.logdna-agent.plist
9 changes: 9 additions & 0 deletions tools/files/darwin/uninstall-mac-agent
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
if sudo /bin/launchctl list com.logdna.logdna-agentd &> /dev/null; then
sudo /bin/launchctl unload "/Library/LaunchDaemons/com.logdna.logdna-agent.plist"
fi

sudo pkill -f logdna-agent

( cd / ; sudo pkgutil --only-files --files com.logdna.logdna-agent | tr '\n' '\0' | xargs -n 1 -0 sudo rm -if )
sudo pkgutil --forget com.logdna.logdna-agent
1 change: 1 addition & 0 deletions tools/files/linux/after-upgrade
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/etc/init.d/logdna-agent restart
1 change: 1 addition & 0 deletions tools/files/linux/before-remove
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/etc/init.d/logdna-agent stop
Loading

0 comments on commit 45964da

Please sign in to comment.