Skip to content

Commit

Permalink
ci: github action
Browse files Browse the repository at this point in the history
  • Loading branch information
CodFrm committed Oct 4, 2023
1 parent 0ad5ff6 commit 47e52d8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
14 changes: 6 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ on:
- release/*

env:
CLOUDCAT_PREFIX: "cloudcat_"
CLOUDCAT: "cloudcat"
BINARY_SUFFIX: ""
CCATCTL_PREFIX: "ccatctl_"
CCATCTL: "ccatctl"
COMMIT_ID: "${{ github.sha }}"


Expand Down Expand Up @@ -49,20 +49,18 @@ jobs:
GOARCH: ${{ matrix.goarch }}
run: |
if [ $GOOS = "windows" ]; then export BINARY_SUFFIX="$BINARY_SUFFIX.exe"; fi
export BINARY_NAME="$CLOUDCAT_PREFIX"$GOOS"_$GOARCH$BINARY_SUFFIX"
export CGO_ENABLED=0
export LD_FLAGS="-w -s -X github.com/scriptscat/cloudcat/configs.Version=${COMMIT_ID::7}"
go build -o "bin/$BINARY_NAME" -trimpath -ldflags "$LD_FLAGS" ./cmd/cloudcat
go build -o "bin/$CLOUDCAT" -trimpath -ldflags "$LD_FLAGS" ./cmd/cloudcat
export BINARY_NAME="$CCATCTL_PREFIX"$GOOS"_$GOARCH$BINARY_SUFFIX"
go build -o "bin/$BINARY_NAME" -trimpath -ldflags "$LD_FLAGS" ./cmd/ccatctl
go build -o "bin/$CCATCTL" -trimpath -ldflags "$LD_FLAGS" ./cmd/ccatctl
cd bin
if [ "${{ matrix.goos }}" = "windows" ]; then
zip -j "${CLOUDCAT_PREFIX}${GOOS}_${GOARCH}.zip" "$CCATCTL_PREFIX${GOOS}_${GOARCH}.exe" "$CLOUDCAT_PREFIX${GOOS}_${GOARCH}.exe"
zip -j "${CLOUDCAT}_${GOOS}_${GOARCH}.zip" "${CCATCTL}.exe" "${CLOUDCAT}.exe"
else
tar czvf "${CLOUDCAT_PREFIX}${GOOS}_${GOARCH}.tar.gz" "$CCATCTL_PREFIX${GOOS}_${GOARCH}" "$CLOUDCAT_PREFIX${GOOS}_${GOARCH}"
tar czvf "${CLOUDCAT}_${GOOS}_${GOARCH}.tar.gz" "${CCATCTL}" "${CLOUDCAT}"
fi
- name: Upload artifact
Expand Down
14 changes: 6 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ on:
workflow_dispatch:

env:
CLOUDCAT_PREFIX: "cloudcat_"
CLOUDCAT: "cloudcat"
BINARY_SUFFIX: ""
CCATCTL_PREFIX: "ccatctl_"
CCATCTL: "ccatctl"
COMMIT_ID: "${{ github.sha }}"

jobs:
Expand Down Expand Up @@ -49,20 +49,18 @@ jobs:
GOARCH: ${{ matrix.goarch }}
run: |
if [ $GOOS = "windows" ]; then export BINARY_SUFFIX="$BINARY_SUFFIX.exe"; fi
export BINARY_NAME="$CLOUDCAT_PREFIX"$GOOS"_$GOARCH$BINARY_SUFFIX"
export CGO_ENABLED=0
export LD_FLAGS="-w -s -X github.com/scriptscat/cloudcat/configs.Version=${COMMIT_ID::7}"
go build -o "bin/$BINARY_NAME" -trimpath -ldflags "$LD_FLAGS" ./cmd/cloudcat
go build -o "bin/$CLOUDCAT" -trimpath -ldflags "$LD_FLAGS" ./cmd/cloudcat
export BINARY_NAME="$CCATCTL_PREFIX"$GOOS"_$GOARCH$BINARY_SUFFIX"
go build -o "bin/$BINARY_NAME" -trimpath -ldflags "$LD_FLAGS" ./cmd/ccatctl
go build -o "bin/$CCATCTL" -trimpath -ldflags "$LD_FLAGS" ./cmd/ccatctl
cd bin
if [ "${{ matrix.goos }}" = "windows" ]; then
zip -j "${CLOUDCAT_PREFIX}${GOOS}_${GOARCH}.zip" "$CCATCTL_PREFIX${GOOS}_${GOARCH}.exe" "$CLOUDCAT_PREFIX${GOOS}_${GOARCH}.exe"
zip -j "${CLOUDCAT}_${GOOS}_${GOARCH}.zip" "${CCATCTL}.exe" "${CLOUDCAT}.exe"
else
tar czvf "${CLOUDCAT_PREFIX}${GOOS}_${GOARCH}.tar.gz" "$CCATCTL_PREFIX${GOOS}_${GOARCH}" "$CLOUDCAT_PREFIX${GOOS}_${GOARCH}"
tar czvf "${CLOUDCAT}_${GOOS}_${GOARCH}.tar.gz" "${CCATCTL}" "${CLOUDCAT}"
fi
- name: Upload artifact
Expand Down

0 comments on commit 47e52d8

Please sign in to comment.