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

Add the workflow to release CLI commands #363

Merged
merged 2 commits into from
Feb 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,31 @@ jobs:
platforms: linux/amd64 # ,linux/arm64
push: true
tags: ${{ steps.docker_meta.outputs.tags }}

release:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
-
uses: actions/setup-go@v1
with:
go-version: '1.17'
-
name: test
run: go test -cpu 4 -coverprofile .testCoverage.txt $(go list ./... | grep -v model/ent | grep -v mock)
env:
GIN_MODE: release
-
name: build
run: sh ./scripts/build-cli.sh
-
name: release
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ github.token }}"
prerelease: true
files: |
release/gitploy_*.tar.gz
release/gitploy_checksums.txt
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@
# Dependency directories (remove the comment below to include it)
# vendor/
.env
*.db
*.db

release/
27 changes: 27 additions & 0 deletions scripts/build-cli.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh
set -e
set -x

# disable CGO for cross-compiling
export CGO_ENABLED=0

# compile for all architectures
GOOS=linux GOARCH=amd64 go build -ldflags "-X main.Version=${GITHUB_REF_NAME##v}" -o release/linux/amd64/gitploy ./cmd/cli
GOOS=linux GOARCH=arm64 go build -ldflags "-X main.Version=${GITHUB_REF_NAME##v}" -o release/linux/arm64/gitploy ./cmd/cli
GOOS=linux GOARCH=ppc64le go build -ldflags "-X main.Version=${GITHUB_REF_NAME##v}" -o release/linux/ppc64le/gitploy ./cmd/cli
GOOS=linux GOARCH=arm go build -ldflags "-X main.Version=${GITHUB_REF_NAME##v}" -o release/linux/arm/gitploy ./cmd/cli
GOOS=windows GOARCH=amd64 go build -ldflags "-X main.Version=${GITHUB_REF_NAME##v}" -o release/windows/amd64/gitploy.exe ./cmd/cli
GOOS=darwin GOARCH=amd64 go build -ldflags "-X main.Version=${GITHUB_REF_NAME##v}" -o release/darwin/amd64/gitploy ./cmd/cli
GOOS=darwin GOARCH=arm64 go build -ldflags "-X main.Version=${GITHUB_REF_NAME##v}" -o release/darwin/arm64/gitploy ./cmd/cli

# tar binary files prior to upload
tar -cvzf release/gitploy_linux_amd64.tar.gz -C release/linux/amd64 gitploy
tar -cvzf release/gitploy_linux_arm64.tar.gz -C release/linux/arm64 gitploy
tar -cvzf release/gitploy_linux_ppc64le.tar.gz -C release/linux/ppc64le gitploy
tar -cvzf release/gitploy_linux_arm.tar.gz -C release/linux/arm gitploy
tar -cvzf release/gitploy_windows_amd64.tar.gz -C release/windows/amd64 gitploy.exe
tar -cvzf release/gitploy_darwin_amd64.tar.gz -C release/darwin/amd64 gitploy
tar -cvzf release/gitploy_darwin_arm64.tar.gz -C release/darwin/arm64 gitploy

# generate shas for tar files
sha256sum release/*.tar.gz > release/gitploy_checksums.txt