Skip to content

Commit

Permalink
ci: github release
Browse files Browse the repository at this point in the history
  • Loading branch information
ztelliot committed May 31, 2024
1 parent 9d317a6 commit 81de8a0
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 14 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: release

on:
pull_request:
push:
tags:
- "*"

permissions:
contents: write

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: stable
- name: Go Releaser
id: goreleaser
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: "~> v1"
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AWS_ACCESS_KEY_ID: ${{ secrets.CLOUDFLARE_API_TOKEN }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.CLOUDFLARE_API_KEY }}
S3_BUCKET: ${{ secrets.CLOUDFLARE_BUCKET }}
S3_REGION: ${{ secrets.CLOUDFLARE_REGION }}
S3_ENDPOINT: ${{ secrets.CLOUDFLARE_ENDPOINT }}
- name: Generate Metadata
id: metadata
env:
METADATA: "${{ steps.goreleaser.outputs.metadata }}"
ARTIFACTS: "${{ steps.goreleaser.outputs.artifacts }}"
run: |
echo "VERSION=$(echo "$METADATA" | jq -r '.tag')" >> $GITHUB_OUTPUT
echo "PLATFORM=$(echo "$ARTIFACTS" | jq -rc '[.[] | select (.internal_type==2) | .name | split("_")[2:] | join("_") | sub("_";"/") | sub(".exe$";"")]')" >> $GITHUB_OUTPUT
- name: Hook API
env:
VERSION: ${{ steps.metadata.outputs.VERSION }}
PLATFORM: ${{ steps.metadata.outputs.PLATFORM }}
TOKEN: ${{ secrets.ACCESS_TOKEN }}
HOOKS: ${{ secrets.HOOKS }}
run: |
export IFS=";"
for hook in $HOOKS; do curl -k -X POST -H "Authorization: $TOKEN" -H "Content-Type: application/json" --data "{\"version\":\"$VERSION\",\"platform\":$PLATFORM}" $hook; done
15 changes: 3 additions & 12 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
project_name: 'taierspeed-cli'
#dist: ./out
before:
hooks:
- go mod download
Expand Down Expand Up @@ -57,20 +56,13 @@ builds:
- goos: darwin
goarch: amd64
archives:
- format_overrides:
- goos: windows
format: zip
files:
- LICENSE
- format: binary
checksum:
name_template: 'checksums.txt'
changelog:
sort: asc
gitea_urls:
api: "{{ .Env.GITEA_URL }}/api/v1"
download: "{{ .Env.GITEA_URL }}"
release:
gitea:
github:
owner: ztelliot
name: taierspeed-cli
disable: false
Expand All @@ -79,5 +71,4 @@ blobs:
bucket: "{{ .Env.S3_BUCKET }}"
region: "{{ .Env.S3_REGION }}"
endpoint: "{{ .Env.S3_ENDPOINT }}"
folder: "taierspeed/{{.Version}}"

folder: "{{ .ProjectName }}/v{{.Version}}"
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/ztelliot/taierspeed-cli

go 1.21
go 1.22

require (
github.com/briandowns/spinner v1.23.0
Expand Down
2 changes: 1 addition & 1 deletion speedtest/speedtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func SpeedTest(c *cli.Context) error {
// print version
if c.Bool(defs.OptionVersion) {
log.SetOutput(os.Stdout)
log.Warnf("%s %s (built on %s %s)", defs.ProgName, defs.ProgVersion, defs.ProgCommit, defs.BuildDate)
log.Warnf("%s %s %s (built on %s)", defs.ProgName, defs.ProgVersion, defs.ProgCommit, defs.BuildDate)
log.Warn("Powered by TaierSpeed")
log.Warn("Project: https://github.com/ztelliot/taierspeed-cli")
log.Warn("Forked: https://github.com/librespeed/speedtest-cli")
Expand Down

0 comments on commit 81de8a0

Please sign in to comment.