Skip to content
This repository was archived by the owner on May 30, 2024. It is now read-only.

Commit 8c5aefc

Browse files
author
Noah Lee
authored
Add the workflow to release CLI commands (#363)
* Add the script for building cli * Add the release job
1 parent 5d158e9 commit 8c5aefc

File tree

3 files changed

+58
-1
lines changed

3 files changed

+58
-1
lines changed

.github/workflows/publish.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,31 @@ jobs:
4141
platforms: linux/amd64 # ,linux/arm64
4242
push: true
4343
tags: ${{ steps.docker_meta.outputs.tags }}
44+
45+
release:
46+
runs-on: ubuntu-latest
47+
steps:
48+
-
49+
name: Checkout
50+
uses: actions/checkout@v2
51+
-
52+
uses: actions/setup-go@v1
53+
with:
54+
go-version: '1.17'
55+
-
56+
name: test
57+
run: go test -cpu 4 -coverprofile .testCoverage.txt $(go list ./... | grep -v model/ent | grep -v mock)
58+
env:
59+
GIN_MODE: release
60+
-
61+
name: build
62+
run: sh ./scripts/build-cli.sh
63+
-
64+
name: release
65+
uses: "marvinpinto/action-automatic-releases@latest"
66+
with:
67+
repo_token: "${{ github.token }}"
68+
prerelease: true
69+
files: |
70+
release/gitploy_*.tar.gz
71+
release/gitploy_checksums.txt

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,6 @@
1515
# Dependency directories (remove the comment below to include it)
1616
# vendor/
1717
.env
18-
*.db
18+
*.db
19+
20+
release/

scripts/build-cli.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/sh
2+
set -e
3+
set -x
4+
5+
# disable CGO for cross-compiling
6+
export CGO_ENABLED=0
7+
8+
# compile for all architectures
9+
GOOS=linux GOARCH=amd64 go build -ldflags "-X main.Version=${GITHUB_REF_NAME##v}" -o release/linux/amd64/gitploy ./cmd/cli
10+
GOOS=linux GOARCH=arm64 go build -ldflags "-X main.Version=${GITHUB_REF_NAME##v}" -o release/linux/arm64/gitploy ./cmd/cli
11+
GOOS=linux GOARCH=ppc64le go build -ldflags "-X main.Version=${GITHUB_REF_NAME##v}" -o release/linux/ppc64le/gitploy ./cmd/cli
12+
GOOS=linux GOARCH=arm go build -ldflags "-X main.Version=${GITHUB_REF_NAME##v}" -o release/linux/arm/gitploy ./cmd/cli
13+
GOOS=windows GOARCH=amd64 go build -ldflags "-X main.Version=${GITHUB_REF_NAME##v}" -o release/windows/amd64/gitploy.exe ./cmd/cli
14+
GOOS=darwin GOARCH=amd64 go build -ldflags "-X main.Version=${GITHUB_REF_NAME##v}" -o release/darwin/amd64/gitploy ./cmd/cli
15+
GOOS=darwin GOARCH=arm64 go build -ldflags "-X main.Version=${GITHUB_REF_NAME##v}" -o release/darwin/arm64/gitploy ./cmd/cli
16+
17+
# tar binary files prior to upload
18+
tar -cvzf release/gitploy_linux_amd64.tar.gz -C release/linux/amd64 gitploy
19+
tar -cvzf release/gitploy_linux_arm64.tar.gz -C release/linux/arm64 gitploy
20+
tar -cvzf release/gitploy_linux_ppc64le.tar.gz -C release/linux/ppc64le gitploy
21+
tar -cvzf release/gitploy_linux_arm.tar.gz -C release/linux/arm gitploy
22+
tar -cvzf release/gitploy_windows_amd64.tar.gz -C release/windows/amd64 gitploy.exe
23+
tar -cvzf release/gitploy_darwin_amd64.tar.gz -C release/darwin/amd64 gitploy
24+
tar -cvzf release/gitploy_darwin_arm64.tar.gz -C release/darwin/arm64 gitploy
25+
26+
# generate shas for tar files
27+
sha256sum release/*.tar.gz > release/gitploy_checksums.txt

0 commit comments

Comments
 (0)