Skip to content

Commit

Permalink
Automate releasing binary executables
Browse files Browse the repository at this point in the history
  • Loading branch information
yanecc committed May 6, 2024
1 parent 6c77803 commit c01056b
Show file tree
Hide file tree
Showing 6 changed files with 159 additions and 21 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/Build for release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,19 @@ jobs:
FILE_NAME="${{ env.Executable }}-$VERSION-freebsd-x86_64"
echo "FILE_NAME=$FILE_NAME" >> $GITHUB_OUTPUT
echo "Generated file name: $FILE_NAME"
cp bin/${{ env.Executable }} ${{ env.Executable }}-freebsd-x86_64
- name: Publish to Releases
if: github.event_name == 'release'
uses: ncipollo/release-action@v1
with:
name: "MockGPT v${{ github.event.release.tag_name }}"
allowUpdates: true
artifacts: "${{ env.Executable }}-freebsd-x86_64"
artifactErrorsFailBuild: false
omitNameDuringUpdate: true
omitBodyDuringUpdate: true
omitPrereleaseDuringUpdate: true

- name: Collect assets
run: |
Expand Down Expand Up @@ -102,6 +115,19 @@ jobs:
FILE_NAME="${{ env.Executable }}-$VERSION-linux-arm64"
echo "FILE_NAME=$FILE_NAME" >> $GITHUB_OUTPUT
echo "Generated file name: $FILE_NAME"
cp bin/${{ env.Executable }} ${{ env.Executable }}-linux-arm64
- name: Publish to Releases
if: github.event_name == 'release'
uses: ncipollo/release-action@v1
with:
name: "MockGPT v${{ github.event.release.tag_name }}"
allowUpdates: true
artifacts: "${{ env.Executable }}-linux-arm64"
artifactErrorsFailBuild: false
omitNameDuringUpdate: true
omitBodyDuringUpdate: true
omitPrereleaseDuringUpdate: true

- name: Collect assets
run: |
Expand Down Expand Up @@ -146,6 +172,19 @@ jobs:
FILE_NAME="${{ env.Executable }}-$VERSION-linux-x86_64"
echo "FILE_NAME=$FILE_NAME" >> $GITHUB_OUTPUT
echo "Generated file name: $FILE_NAME"
cp bin/${{ env.Executable }} ${{ env.Executable }}-linux-x86_64
- name: Publish to Releases
if: github.event_name == 'release'
uses: ncipollo/release-action@v1
with:
name: "MockGPT v${{ github.event.release.tag_name }}"
allowUpdates: true
artifacts: "${{ env.Executable }}-linux-x86_64"
artifactErrorsFailBuild: false
omitNameDuringUpdate: true
omitBodyDuringUpdate: true
omitPrereleaseDuringUpdate: true

- name: Collect assets
run: |
Expand Down Expand Up @@ -347,6 +386,18 @@ jobs:
sudo chmod +x /usr/bin/lipo
lipo -create arm64/${{ env.Executable }} amd64/${{ env.Executable }} -output ${{ env.Executable }}
- name: Publish to Releases
if: github.event_name == 'release'
uses: ncipollo/release-action@v1
with:
name: "MockGPT v${{ github.event.release.tag_name }}"
allowUpdates: true
artifacts: "${{ env.Executable }}-macos-universal"
artifactErrorsFailBuild: false
omitNameDuringUpdate: true
omitBodyDuringUpdate: true
omitPrereleaseDuringUpdate: true

- name: Collect assets
run: |
mv amd64/LICENSE amd64/README.md amd64/README_zh.md .
Expand Down
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,24 @@ Ollama and at least one large model pulled.

# Installation

The release page provides statically compiled binary files for main platforms. For other platforms and architectures, check [Build for release](https://github.com/yanecc/MockGPT/actions/workflows/Build%20for%20release.yml) first, you may find monthly built products from the artifacts, or will have to install the Crystal language environment and compile it yourself otherwise.
Quick start on Linux, macOS, and FreeBSD (root required):

``` shell
# Linux arm64
sudo curl -L -o /usr/bin/mockgpt https://github.com/yanecc/MockGPT/releases/latest/download/mockgpt-linux-arm64
sudo chmod +x /usr/bin/mockgpt
# Linux x86_64
sudo curl -L -o /usr/bin/mockgpt https://github.com/yanecc/MockGPT/releases/latest/download/mockgpt-linux-x86_64
sudo chmod +x /usr/bin/mockgpt
# macOS arm64/x86_64
sudo curl -L -o /usr/bin/mockgpt https://github.com/yanecc/MockGPT/releases/latest/download/mockgpt-macos-universal
sudo chmod +x /usr/bin/mockgpt
# FreeBSD x86_64
sudo fetch -o /usr/bin/mockgpt https://github.com/yanecc/MockGPT/releases/latest/download/mockgpt-freebsd-x86_64
sudo chmod +x /usr/bin/mockgpt
```

The [releases page](https://github.com/yanecc/MockGPT/releases/latest) provides statically compiled binary files and release packages for main platforms. For other platforms and architectures, check [Build for release](https://github.com/yanecc/MockGPT/actions/workflows/Build%20for%20release.yml) first, you may find monthly built products from the artifacts, or will have to install the Crystal language environment and compile it yourself otherwise.

``` shell
git clone https://github.com/yanecc/MockGPT
Expand Down
19 changes: 18 additions & 1 deletion README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,24 @@ Ollama及至少一个大模型

# 安装

发布页面为主流平台提供了静态编译的MockGPT程序,若在其他平台使用,首先查看[Build for release](https://github.com/yanecc/MockGPT/actions/workflows/Build%20for%20release.yml),那里可能有每月构建的版本,若没有则需要安装Crystal语言环境自行编译。
快速安装(需要root权限):

``` shell
# Linux arm64
sudo curl -L -o /usr/bin/mockgpt https://github.com/yanecc/MockGPT/releases/latest/download/mockgpt-linux-arm64
sudo chmod +x /usr/bin/mockgpt
# Linux x86_64
sudo curl -L -o /usr/bin/mockgpt https://github.com/yanecc/MockGPT/releases/latest/download/mockgpt-linux-x86_64
sudo chmod +x /usr/bin/mockgpt
# macOS arm64/x86_64
sudo curl -L -o /usr/bin/mockgpt https://github.com/yanecc/MockGPT/releases/latest/download/mockgpt-macos-universal
sudo chmod +x /usr/bin/mockgpt
# FreeBSD x86_64
sudo fetch -o /usr/bin/mockgpt https://github.com/yanecc/MockGPT/releases/latest/download/mockgpt-freebsd-x86_64
sudo chmod +x /usr/bin/mockgpt
```

[发布页面](https://github.com/yanecc/MockGPT/releases/latest)为主流平台提供了静态编译的MockGPT程序和发行包,若在其他平台使用,首先查看[Build for release](https://github.com/yanecc/MockGPT/actions/workflows/Build%20for%20release.yml),那里可能有每月构建的版本,若没有则需要安装Crystal语言环境自行编译。

``` shell
git clone https://github.com/yanecc/MockGPT
Expand Down
70 changes: 51 additions & 19 deletions src/mockgpt.cr
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,58 @@ if File.file?(confPath)
Mocker.gpt = mocker["gpt"].as_s if mocker["gpt"]?
end

COMMANDS_VERSION = <<-VERSION
MockGPT v1.2.1
GitHub: \t https://github.com/yanecc/mockgpt
Codeberg:\t https://codeberg.org/sunrise/mockgpt
VERSION

OptionParser.parse do |parser|
parser.banner = "Usage: mockgpt [arguments]"
parser.banner = "Usage: mockgpt <subcommand>/<options> <arguments>"
parser.on("config", "Display the configuration in effect") do
parser.on("-h", "--help", "Show config help") do
puts CONFIG_HELP
exit
end
parser.unknown_args do |args, options|
if args.size > 2
STDERR.puts "Too many arguments: #{args}", parser
exit(1)
end
case args[0]? || "all"
when "all"
puts "Host \t: #{Mocker.host}"
puts "Port \t: #{Mocker.port}"
puts "Model\t: #{Mocker.model}"
puts "GPT \t: #{Mocker.gpt}"
when "host"
puts Mocker.host
when "port"
puts Mocker.port
when "model"
puts Mocker.model
when "gpt"
puts Mocker.gpt
when "init"
puts "Config file initialized."
when "rm"
args[1]? && case args[1]
when "host"
puts Mocker.host
when "port"
puts Mocker.port
when "model"
puts Mocker.model
when "gpt"
puts Mocker.gpt
else
STDERR.puts "Undefined option: #{args[1]}", parser
end
else
STDERR.puts "Undefined option: #{args[1]}", parser
end

exit
end
end
parser.on("version", "Print the version") do
puts COMMANDS_VERSION
exit
end
parser.on("-b HOST", "--binding HOST", "Bind to the specified host") { |_host| Mocker.host = _host }
parser.on("-p PORT", "--port PORT", "Run on the specified port") { |_port| Mocker.port = _port.to_i }
parser.on("-m MODEL", "--mocker MODEL", "Employ the specified model") { |_model| Mocker.model = _model }
Expand All @@ -44,17 +87,6 @@ OptionParser.parse do |parser|
puts COMMANDS_VERSION
exit
end
parser.on("version", "Print the version") do
puts COMMANDS_VERSION
exit
end
parser.on("config", "Display the configuration in effect") do
puts "Host \t: #{Mocker.host}"
puts "Port \t: #{Mocker.port}"
puts "Model\t: #{Mocker.model}"
puts "GPT \t: #{Mocker.gpt}"
exit
end
parser.invalid_option do |flag|
STDERR.puts "ERROR: #{flag} is not a valid option."
STDERR.puts parser
Expand Down
Empty file added src/mockgpt/config.cr
Empty file.
21 changes: 21 additions & 0 deletions src/mockgpt/constants.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
COMMANDS_VERSION = <<-VERSION
MockGPT v1.2.1
GitHub: \t https://github.com/yanecc/mockgpt
Codeberg:\t https://codeberg.org/sunrise/mockgpt
VERSION
CONFIG_HELP = <<-CONFIG
Usage: mockgpt config [rm] <name> <value>
Example:
mockgpt config [all]
mockgpt config init
mockgpt config port 8080
mockgpt config rm port
Options:
rm \t Reset a configuration to the default value
all \t Display all configurations, same as mockgpt config
init \t Initialize the configuration file if not exist
-h, --help \t Show this help for config
CONFIG

0 comments on commit c01056b

Please sign in to comment.