-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
228 additions
and
46 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,6 @@ config.yaml | |
*.zip | ||
*.exe | ||
|
||
scriptcat | ||
cloudcat | ||
/cloudcat | ||
|
||
cloudcat.db | ||
cloudcat.db |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: GoBuild | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- develop/* | ||
pull_request: | ||
branches: | ||
- main | ||
- develop/* | ||
|
||
jobs: | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/.cache/go-build | ||
~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go- | ||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.16 | ||
|
||
- name: Build | ||
run: make build | ||
|
||
- name: Test | ||
run: go test -v ./... |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
name: release | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
|
||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/.cache/go-build | ||
~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go- | ||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.16 | ||
|
||
- name: Build | ||
run: make build | ||
|
||
- name: Test | ||
run: go test -v ./... | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- name: Login to DockerHub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Get version | ||
id: get_version | ||
run: echo ::set-output name=VERSION::${GITHUB_REF:10} | ||
|
||
- name: Build and push | ||
id: docker_build | ||
uses: docker/build-push-action@v2 | ||
with: | ||
push: true | ||
tags: codfrm/cloudcat:${{ steps.get_version.outputs.VERSION }} | ||
|
||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@latest | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: scriptcat-${{ github.ref }} | ||
body: | | ||
'no description' | ||
draft: false | ||
prerelease: false | ||
|
||
- name: Build Target | ||
run: | | ||
VERSION=${{ steps.get_version.outputs.VERSION }} GOOS=linux GOARCH=amd64 make target | ||
tar -zcvf cloudcat-${{ steps.get_version.outputs.VERSION }}-linux-amd64.tar.gz cloudcat-${{ steps.get_version.outputs.VERSION }}-linux-amd64 | ||
- name: Upload Release Asset zip | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: cloudcat-${{ steps.get_version.outputs.VERSION }}-linux-amd64.tar.gz | ||
asset_name: cloudcat-${{ steps.get_version.outputs.VERSION }}-linux-amd64.tar.gz | ||
asset_content_type: application/tar+gz |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,6 @@ config.yaml | |
*.zip | ||
*.exe | ||
|
||
scriptcat | ||
cloudcat | ||
/cloudcat | ||
|
||
cloudcat.db | ||
cloudcat.db |
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 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,46 @@ | ||
|
||
|
||
# CloudCat | ||
|
||
> 一个用于 **[ScriptCat脚本猫](https://docs.scriptcat.org/)** 扩展云端执行脚本的服务 | ||
 | ||
|
||
|
||
|
||
## 编译 | ||
|
||
|
||
|
||
```shell | ||
make build | ||
``` | ||
\* Windows编译需要安装Mingw64 | ||
|
||
|
||
|
||
## 运行 | ||
|
||
### ScriptCat运行 | ||
|
||
|
||
|
||
``` | ||
scriptcat bilibili.zip | ||
``` | ||
|
||
|
||
|
||
### Docker运行 | ||
|
||
> 请注意Docker中时区问题 | ||
|
||
|
||
```shell | ||
docker pull codfrm/cloudcat:0.1.0 | ||
docker run -it -v $(PWD)/bilibili.zip:/cloudcat/bilibili.zip -v /etc/localtime:/etc/localtime -v /etc/timezone:/etc/timezone codfrm/cloudcat:0.1.0 exec bilibili.zip | ||
``` | ||
|
||
|
||
|
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,22 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/scriptscat/cloudcat/internal/app" | ||
"github.com/scriptscat/cloudcat/internal/pkg/config" | ||
"github.com/sirupsen/logrus" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func main() { | ||
cfg, err := config.Init("config.yaml") | ||
if err != nil { | ||
logrus.Fatalln(err) | ||
rootCmd := &cobra.Command{ | ||
Use: "cloudcat", | ||
} | ||
|
||
if err := app.Run(cfg); err != nil { | ||
logrus.Fatalf("app start err: %v", err) | ||
execCmd := newExecCmd() | ||
serveCmd := newServeCmd() | ||
|
||
rootCmd.AddCommand(execCmd.Commands()...) | ||
rootCmd.AddCommand(serveCmd.Commands()...) | ||
|
||
if err := rootCmd.Execute(); err != nil { | ||
logrus.Fatalln(err) | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/scriptscat/cloudcat/internal/app" | ||
"github.com/scriptscat/cloudcat/internal/pkg/config" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
type serveCmd struct { | ||
config string | ||
} | ||
|
||
func newServeCmd() *serveCmd { | ||
return &serveCmd{} | ||
} | ||
|
||
func (s *serveCmd) Commands() []*cobra.Command { | ||
ret := &cobra.Command{ | ||
Use: "serve [flag]", | ||
Short: "运行脚本猫服务", | ||
RunE: s.serve, | ||
} | ||
ret.Flags().StringVarP(&s.config, "config", "c", "config.yaml", "配置文件") | ||
|
||
return []*cobra.Command{ret} | ||
} | ||
|
||
func (s *serveCmd) serve(cmd *cobra.Command, args []string) error { | ||
cfg, err := config.Init(s.config) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if err := app.Run(cfg); err != nil { | ||
return fmt.Errorf("app start err: %v", err) | ||
} | ||
return nil | ||
} |
This file was deleted.
Oops, something went wrong.
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