From ca44a6e0744458d843613ed577168313a17192fa Mon Sep 17 00:00:00 2001 From: Jo <10510431+j178@users.noreply.github.com> Date: Sat, 8 Oct 2022 16:40:35 +0800 Subject: [PATCH] Add goreleaser (#2) * Add goreleaser * Change goreleaser main package * Update readme * Update goreleaser --- .github/workflows/release.yml | 29 ++++++++++++++++++++++++++++ .gitignore | 4 ++++ .goreleaser.yaml | 36 +++++++++++++++++++++++++++++++++++ README.md | 4 ++-- 4 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/release.yml create mode 100644 .goreleaser.yaml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..2dc211e --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,29 @@ +name: Release + +on: + push: + tags: + - '*' + +permissions: + contents: write + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - run: git fetch --force --tags + - uses: actions/setup-go@v3 + with: + go-version: '>=1.19.2' + cache: true + - uses: goreleaser/goreleaser-action@v2 + with: + distribution: goreleaser + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index ae53d93..52183cf 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,5 @@ /cmd/twiyou/dev.go +.DS_Store +twiyou + +dist/ diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..87383cc --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,36 @@ +# This is an example .goreleaser.yml file with some sensible defaults. +# Make sure to check the documentation at https://goreleaser.com +before: + hooks: + - go mod tidy +builds: + - main: ./cmd/twiyou + env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - darwin + goarch: + - amd64 + - arm64 + flags: + - -v + - -trimpath +archives: + - replacements: + darwin: Darwin + linux: Linux + windows: Windows + 386: i386 + amd64: x86_64 +checksum: + name_template: 'checksums.txt' +snapshot: + name_template: "{{ incpatch .Version }}-next" +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^test:' diff --git a/README.md b/README.md index 0983df5..08fb5f5 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ twiyou(推油)是一款推特好友/推特数据监测工具。 运行起来需要部署3个组件:数据库,数据抓取工具,监控面板,目前这3个组件都有免费的白嫖资源,此外需要有推特开发者账号。 - 数据库我用的是TiDB Cloud DevTier (https://tidbcloud.com/ )的免费资源,理论上兼容MySQL协议的应该都行,不过我没试。 -- 数据抓取工具可以`go build ./cmd/twiyou`编译出来,找台机器配置好环境变量定时运行程序就行(推荐5分钟运行一次)。也可以免费部署到Vercel (https://vercel.com/ ),不过我测了效果不算太好,没有服务器资源的话可以凑合用。 +- 数据抓取工具可以从 [Release](https://github.com/disksing/twiyou/releases) 下载或者自行 `go build ./cmd/twiyou` 编译出来,找台机器配置好环境变量定时运行程序就行(推荐5分钟运行一次)。也可以免费部署到Vercel (https://vercel.com/ ),不过我测了效果不算太好,没有服务器资源的话可以凑合用。 - 监控面板用的是Grafana,Grafana Cloud (https://grafana.com/ )也是可以创建免费的账号,添加数据库数据源之后,把监控模板导入就行。 ## 搭建自己的部署(详细攻略) @@ -37,7 +37,7 @@ twiyou(推油)是一款推特好友/推特数据监测工具。 ### 3. 部署数据抓取工具 -下载地址:TBD(还没整release,先自己编译吧) +下载地址:https://github.com/disksing/twiyou/releases 然后配置好crontab和环境变量每5分钟运行一次就行,抓下来的数据都会写到数据库里面,本地不存数据。