Skip to content

Commit

Permalink
feat: 添加打包脚本
Browse files Browse the repository at this point in the history
  • Loading branch information
ystyle committed Aug 9, 2023
1 parent 4e9793e commit d57ea31
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 2 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Go

on:
release:
types: [published]

jobs:

build:
name: Build
runs-on: ubuntu-latest
steps:

- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.19
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Get dependencies
run: |
curl -OL https://github.com/ystyle/kaf-cli/releases/download/kindlegen/KindleGen_Mac_64bit_v2_9.zip
curl -OL https://github.com/ystyle/kaf-cli/releases/download/kindlegen/kindlegen_win32_v2_9.zip
unzip -d darwin KindleGen_Mac_64bit_v2_9.zip
unzip -d windows kindlegen_win32_v2_9.zip
- name: Build
run: |
hash=`git rev-list --tags --max-count=1`
version=`git describe --tags $hash`
flag="-s -w -X main.secret=${{ secrets.API_SECRET }} -X main.measurement=${{ secrets.MEASUREMENT }} -X main.version=$version"
go mod tidy
GOOS=linux GOARCH=amd64 go build -ldflags "$flag" -o build/linux-amd64/kas main.go
GOOS=linux GOARCH=arm64 go build -ldflags "$flag" -o build/linux-arm64/kas main.go
GOOS=linux GOARCH=loong64 go build -ldflags "$flag" -o build/linux-loong64/kas main.go
GOOS=darwin GOARCH=amd64 go build -ldflags "$flag" -o build/darwin-amd64/kas main.go
GOOS=darwin GOARCH=arm64 go build -ldflags "$flag" -o build/darwin-arm64/kas main.go
GOOS=windows GOARCH=386 go build -ldflags "$flag" -o build/windows-386/kas.exe main.go
GOOS=windows GOARCH=amd64 go build -ldflags "$flag" -o build/windows-amd64/kas.exe main.go
- name: compression zip
run: |
hash=`git rev-list --tags --max-count=1`
version=`git describe --tags $hash`
zip -j kas_${version}_windows_amd64.zip build/windows-amd64/kas.exe windows/kindlegen.exe 注册右键菜单.ps1
zip -j kas_${version}_windows_386.zip build/windows-386/kas.exe windows/kindlegen.exe
zip -j kas_${version}_darwin_amd64.zip build/darwin-amd64/kas darwin/kindlegen
zip -j kas_${version}_darwin_arm64.zip build/darwin-arm64/kas darwin/kindlegen
zip -j kas_${version}_linux_amd64.zip build/linux-amd64/kas
zip -j kas_${version}_linux_arm64.zip build/linux-arm64/kas
zip -j kas_${version}_linux_loong64.zip build/linux-loong64/kas
- name: Upload release binaries
uses: alexellis/upload-assets@0.2.2
env:
GITHUB_TOKEN: ${{ github.token }}
with:
asset_paths: '["./kas_*.zip"]'
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ WORKDIR /go/src/app
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories && \
apk --update add git curl tzdata && \
go build -v -o /go/src/app/kas main.go && \
find / -name "rice" && \
rice append --exec kas && \
curl https://archive.org/download/kindlegen2.9/kindlegen_linux_2.6_i386_v2_9.tar.gz | tar -zx

FROM alpine
Expand Down

0 comments on commit d57ea31

Please sign in to comment.