Skip to content

Commit

Permalink
update ci/cd
Browse files Browse the repository at this point in the history
  • Loading branch information
matronator committed Apr 22, 2024
1 parent 5571c27 commit ee2de53
Show file tree
Hide file tree
Showing 9 changed files with 176 additions and 56 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/releaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# .github/workflows/release.yml
name: goreleaser

on:
pull_request:
push:
# run only against tags
tags:
- "*"

permissions:
contents: write
packages: write
# issues: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: stable
# More assembly might be required: Docker logins, GPG, etc.
# It all depends on your needs.
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser
# 'latest', 'nightly', or a semver
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
- name: Publish to NPM
uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
run: cd ./npm && npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ go.work
.amock/

dist/
build/
cmd/
.idea/
8 changes: 7 additions & 1 deletion .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ before:
hooks:
- go mod download
- go mod tidy
- cd npm && npm version from-git

builds:
- env:
Expand Down Expand Up @@ -80,6 +81,11 @@ brews:

folder: Formula

repository:
owner: matronator
name: homebrew-tap
branch: main

# Caveats for the user of your binary.
# Default is empty.
caveats: ""
Expand All @@ -90,7 +96,7 @@ brews:

# SPDX identifier of your app's license.
# Default is empty.
license: "MIT"
license: "GPL-3.0-only"

# Packages your package depends on.
dependencies:
Expand Down
5 changes: 4 additions & 1 deletion .idea/amock.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 0 additions & 43 deletions Formula/amock.rb

This file was deleted.

122 changes: 112 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,23 @@ Amock is a simple API mock server that uses JSON files to define entities from w
* [Amock](#amock)
* [API Mock Server](#api-mock-server)
* [Instalation](#instalation)
* [npm (macOS, Linux, Windows)](#npm-macos-linux-windows)
* [GoBinaries (macOS, Linux)](#gobinaries-macos-linux)
* [Homebrew (macOS)](#homebrew-macos)
* [Download from releases (macOS, Linux, Windows)](#download-from-releases-macos-linux-windows)
* [Manual installation (macOS, Linux, Windows)](#manual-installation-macos-linux-windows)
* [Manually download from releases (macOS, Linux, Windows)](#manually-download-from-releases-macos-linux-windows)
* [1. Move the binary to `/usr/local/bin` or some other folder in your PATH:](#1-move-the-binary-to-usrlocalbin-or-some-other-folder-in-your-path)
* [macOS/Linux](#macoslinux)
* [Windows](#windows)
* [2. Add the directory to your PATH:](#2-add-the-directory-to-your-path)
* [macOS/Linux](#macoslinux-1)
* [Windows](#windows-1)
* [With GUI (recommended)](#with-gui-recommended)
* [With PowerShell](#with-powershell)
* [Build from source (macOS, Linux, Windows)](#build-from-source-macos-linux-windows)
* [macOS/Linux](#macoslinux-2)
* [Windows](#windows-2)
* [With GUI (recommended)](#with-gui-recommended-1)
* [With PowerShell](#with-powershell-1)
* [Usage](#usage)
* [Configuration](#configuration)
* [Entity files](#entity-files)
Expand All @@ -26,32 +40,120 @@ Amock is a simple API mock server that uses JSON files to define entities from w

## Instalation

### npm (macOS, Linux, Windows)

```bash
npm install -g amock-cli
```

### GoBinaries (macOS, Linux)

```bash
curl -sf https://gobinaries.com/matronator/amock | sh
```

### Homebrew (macOS)

```bash
brew install matronator/tap/amock
```

### Download from releases (macOS, Linux, Windows)
### Manually download from releases (macOS, Linux, Windows)

Go to the [releases page](https://github.com/matronator/amock/releases/latest) and download the latest version for your OS. Extract the files and do either one of these:

Go to the [releases page](https://github.com/matronator/amock/releases/latest) and download the latest version for your OS. Extract the files and move the binary to a directory in your PATH or add the directory to your PATH.
1. Move the binary to a folder in your `$PATH`, or...
2. Add the folder to your `$PATH`

#### 1. Move the binary to `/usr/local/bin` or some other folder in your PATH:

##### macOS/Linux

```bash
# Either move the binary to a directory in your PATH
mv path/to/extracted/binary/amock /usr/local/bin
sudo mv path/to/extracted/binary/amock /usr/local/bin
```

# Or add the directory to your PATH
##### Windows

```txt
move path\to\extracted\binary\amock.exe C:\path\to\bin
```

#### 2. Add the directory to your PATH:

First move the extracted binary to some permanent folder. Then add the directory to your PATH by running:

##### macOS/Linux

```bash
export PATH=$PATH:path/to/extracted/binary
```

### Manual installation (macOS, Linux, Windows)
To make this permanent, add this line to your `~/.bashrc` or `~/.zshrc` or `~/.profile` file.

##### Windows

###### With GUI (recommended)

Requires Go 1.16 or later
1. Open `"My Computer" > "Properties" > "Advanced" > "Environment Variables" > "Path"`
2. Add the path to the `amock.exe` file to the list
3. Restart your terminal

###### With PowerShell

```powershell
$PATH = [Environment]::GetEnvironmentVariable("PATH", "Machine")
$amock_path = "C:\path\to\amock"
if( $PATH -notlike "*"+$amock_path+"*" ){
[Environment]::SetEnvironmentVariable("PATH", "$PATH;$amock_path", "Machine")
}
```

### Build from source (macOS, Linux, Windows)

> [!IMPORTANT]
> Requires Go 1.16 or later
#### macOS/Linux

```bash
git clone https://github.com/matronator/amock.git
cd amock
go build -o cmd/amock -ldflags="-s -w" .
sudo mv cmd/amock /usr/local/bin
# have to use sudo because /usr/local/bin is protected
```

Make sure that /user/local/bin is in your PATH. If not edit your `~/.bashrc` or `~/.zshrc` or `~/.profile` and add the following line:

```bash
export PATH=$PATH:/usr/local/bin
```

#### Windows

```bash
git clone https://github.com/matronator/amock.git
cd amock
go install
go build -o cmd/amock.exe -ldflags="-s -w" .
```

Next move the `amock.exe` to some permanent location and add it to your PATH with either the GUI or PowerShell:

##### With GUI (recommended)

1. Open `"My Computer" > "Properties" > "Advanced" > "Environment Variables" > "Path"`
2. Add the path to the `amock.exe` file to the list
3. Restart your terminal

##### With PowerShell

```powershell
$PATH = [Environment]::GetEnvironmentVariable("PATH", "Machine")
$amock_path = "C:\path\to\amock"
if( $PATH -notlike "*"+$amock_path+"*" ){
[Environment]::SetEnvironmentVariable("PATH", "$PATH;$amock_path", "Machine")
}
```

## Usage
Expand Down
Binary file renamed build/amock → cmd/amock
Binary file not shown.
File renamed without changes.
2 changes: 1 addition & 1 deletion npm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "amock-cli",
"version": "0.1.2",
"version": "0.1.3",
"description": "Simple API mock server",
"main": "index.js",
"directories": {
Expand Down

0 comments on commit ee2de53

Please sign in to comment.