Skip to content

Commit 1469b39

Browse files
committed
update github actions to create .deb package
1 parent ef4e823 commit 1469b39

2 files changed

Lines changed: 53 additions & 19 deletions

File tree

.github/workflows/main.yml

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@ jobs:
2222
GOOS: linux
2323
GOARCH: amd64
2424
runTests: true
25+
deb_arch: amd64
2526

2627
- name: linux 386
2728
env:
2829
GOOS: linux
2930
GOARCH: 386
3031
runTests: false
32+
deb_arch: i386
3133

3234
- name: darwin amd64
3335
env:
@@ -48,27 +50,27 @@ jobs:
4850
runTests: true
4951

5052
steps:
51-
- name: check out code into the Go module directory
52-
uses: actions/checkout@v4
53+
- name: check out code into the Go module directory
54+
uses: actions/checkout@v4
5355

54-
- name: set up Go 1.x
55-
uses: actions/setup-go@v5
56-
with:
57-
go-version-file: "go.mod"
58-
id: go
56+
- name: set up Go 1.x
57+
uses: actions/setup-go@v5
58+
with:
59+
go-version-file: "go.mod"
60+
id: go
5961

60-
- name: get dependencies
61-
run: |
62-
export GOPATH=$HOME/go
63-
./tools/install.sh
62+
- name: get dependencies
63+
run: |
64+
export GOPATH=$HOME/go
65+
./tools/install.sh
6466
65-
- name: build
66-
env: ${{ matrix.env }}
67-
run: go build -v ./cmd/... ./src/...
67+
- name: build
68+
env: ${{ matrix.env }}
69+
run: go build -v ./cmd/... ./src/...
6870

69-
- name: test
70-
if: ${{ matrix.runTests }}
71-
run: env ${{ matrix.osEnv }} go test -v ./cmd/... ./src/...
71+
- name: test
72+
if: ${{ matrix.runTests }}
73+
run: env ${{ matrix.osEnv }} go test -v ./cmd/... ./src/...
7274

73-
- name: lint
74-
run: env ${{ matrix.osEnv }} gomodrun golangci-lint run ./cmd/... ./src/... --verbose
75+
- name: lint
76+
run: env ${{ matrix.osEnv }} gomodrun golangci-lint run ./cmd/... ./src/... --verbose

.github/workflows/release.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
file: zcli-linux-amd64
2222
compress: true
2323
strip: true
24+
deb_arch: amd64
2425

2526
- name: linux 386
2627
env:
@@ -29,6 +30,7 @@ jobs:
2930
file: zcli-linux-i386
3031
compress: true
3132
strip: true
33+
deb_arch: i386
3234

3335
- name: darwin amd64
3436
env:
@@ -84,6 +86,36 @@ jobs:
8486
file: ./builds/${{ matrix.file }}
8587
strip: ${{ matrix.strip }}
8688

89+
- name: prepare .deb package tree
90+
if: ${{ matrix.deb_arch }}
91+
run: |
92+
mkdir -p .debpkg/usr/local/bin
93+
cp builds/${{ matrix.file }} .debpkg/usr/local/bin/zcli
94+
chmod +x .debpkg/usr/local/bin/zcli
95+
96+
- name: build .deb package
97+
if: ${{ matrix.deb_arch }}
98+
uses: jiro4989/build-deb-action@v4
99+
with:
100+
package: zcli
101+
package_root: .debpkg
102+
maintainer: 'Zerops <https://zerops.io>'
103+
version: ${{ github.event.release.tag_name }}
104+
arch: ${{ matrix.deb_arch }}
105+
desc: 'Zerops CLI'
106+
homepage: 'https://github.com/zeropsio/zcli'
107+
108+
- name: upload .deb asset
109+
if: ${{ matrix.deb_arch }}
110+
uses: actions/upload-release-asset@v1
111+
env:
112+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
113+
with:
114+
upload_url: ${{ github.event.release.upload_url }}
115+
asset_path: ./zcli_${{ github.event.release.tag_name }}_${{ matrix.deb_arch }}.deb
116+
asset_name: zcli_${{ github.event.release.tag_name }}_${{ matrix.deb_arch }}.deb
117+
asset_content_type: application/vnd.debian.binary-package
118+
87119
- name: package binaries for NPM
88120
run: tar -czvf ${{ matrix.file }}-npm.tar.gz builds/${{ matrix.file }}
89121

0 commit comments

Comments
 (0)