-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
20a80fb
commit bd935e5
Showing
10 changed files
with
190 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: release | ||
|
||
on: | ||
push: | ||
tags: | ||
- "v*" | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
release-tag: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
cache: false | ||
go-version: "1.22" | ||
- name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v4 | ||
with: | ||
distribution: goreleaser | ||
version: v1.23.0 | ||
args: release --clean | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
GORELEASER_CURRENT_TAG: ${{ github.ref_name }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,11 @@ | |
# Go workspace file | ||
go.work | ||
|
||
# ci | ||
bin/ | ||
|
||
# Debug | ||
__debug* | ||
.vscode/ | ||
cattle-drive | ||
cattle-drive | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
version: 1 | ||
|
||
snapshot: | ||
name_template: '{{ trimprefix .Summary "v" }}' | ||
|
||
before: | ||
hooks: | ||
- go mod tidy | ||
|
||
builds: | ||
- goos: | ||
- linux | ||
- darwin | ||
goarch: | ||
- amd64 | ||
- arm64 | ||
tags: | ||
- netgo | ||
- osusergo | ||
ldflags: | ||
- -s | ||
- -w | ||
- -X "galal-hussein/cattle-drive/pkg/version.GitCommit={{ .FullCommit }}" | ||
- -X "galal-hussein/cattle-drive/pkg/version.Version=v{{ .Version }}" | ||
|
||
archives: | ||
- format: tar.gz | ||
# this name template makes the OS and Arch compatible with the results of `uname`. | ||
name_template: >- | ||
{{ .ProjectName }}_ | ||
{{- title .Os }}_ | ||
{{- if eq .Arch "amd64" }}x86_64 | ||
{{- else if eq .Arch "386" }}i386 | ||
{{- else }}{{ .Arch }}{{ end }} | ||
{{- if .Arm }}v{{ .Arm }}{{ end }} | ||
# use zip for windows archives | ||
format_overrides: | ||
- goos: windows | ||
format: zip | ||
|
||
release: | ||
github: | ||
owner: galal-hussein | ||
name: cattle-drive | ||
prerelease: auto | ||
|
||
changelog: | ||
sort: asc | ||
filters: | ||
exclude: | ||
- "^docs:" | ||
- "^test:" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
FROM golang:1.22.0-alpine3.19 AS build | ||
RUN apk add -U --no-cache make git bash | ||
COPY . /src/cattle-drive | ||
WORKDIR /src/cattle-drive | ||
RUN ls -l | ||
RUN make build | ||
|
||
FROM alpine AS package | ||
COPY --from=build /src/cattle-drive/bin /usr/local/bin/ | ||
ENTRYPOINT ["/usr/local/bin/cattle-drive"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
default: build | ||
@echo "Run make help for info about other make targets" | ||
|
||
build: ## Build using host go tools | ||
./ops/build | ||
|
||
test: | ||
go test -v ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
|
||
source ./ops/version | ||
|
||
BUILDTAGS="netgo osusergo" | ||
GO_BUILDTAGS="${BUILD_TAGS} ${GO_BUILDTAGS} ${BUILDTAGS} ${DEBUG_TAGS}" | ||
|
||
VERSION_FLAGS=" | ||
-X ${CATTLE_DRIVE_PKG}/pkg/version.GitCommit=${REVISION} | ||
-X ${CATTLE_DRIVE_PKG}/pkg/version.Program=${PROG} | ||
-X ${CATTLE_DRIVE_PKG}/pkg/version.Version=${VERSION} | ||
" | ||
|
||
STATIC_FLAGS='-extldflags "-static"' | ||
|
||
go build \ | ||
-tags "${GO_BUILDTAGS}" \ | ||
-o bin/${PROG} \ | ||
-ldflags "${VERSION_FLAGS}" \ | ||
${GO_TAGS} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/bin/bash | ||
set -x | ||
|
||
CATTLE_DRIVE_PKG=galal-hussein/cattle-drive | ||
PROG=cattle-drive | ||
REGISTRY=docker.io | ||
REPO=${REPO:-husseingalal} | ||
GO=${GO-go} | ||
GOARCH=${GOARCH:-$("${GO}" env GOARCH)} | ||
GOOS=${GOOS:-$("${GO}" env GOOS)} | ||
if [ -z "$GOOS" ]; then | ||
if [ "${OS}" == "Windows_NT" ]; then | ||
GOOS="windows" | ||
else | ||
UNAME_S=$(shell uname -s) | ||
if [ "${UNAME_S}" == "Linux" ]; then | ||
GOOS="linux" | ||
elif [ "${UNAME_S}" == "Darwin" ]; then | ||
GOOS="darwin" | ||
elif [ "${UNAME_S}" == "FreeBSD" ]; then | ||
GOOS="freebsd" | ||
fi | ||
fi | ||
fi | ||
|
||
TREE_STATE=clean | ||
COMMIT=$DRONE_COMMIT | ||
REVISION=$(git rev-parse HEAD)$(if ! git diff --no-ext-diff --quiet --exit-code; then echo .dirty; fi) | ||
PLATFORM=${GOOS}-${GOARCH} | ||
RELEASE=${PROG}.${PLATFORM} | ||
|
||
if [ -d .git ]; then | ||
if [ -z "$GIT_TAG" ]; then | ||
GIT_TAG=$(git tag -l --contains HEAD | head -n 1) | ||
fi | ||
if [ -n "$(git status --porcelain --untracked-files=no)" ]; then | ||
DIRTY="-dirty" | ||
TREE_STATE=dirty | ||
fi | ||
|
||
COMMIT=$(git log -n3 --pretty=format:"%H %ae" | cut -f1 -d\ | head -1) | ||
if [ -z "${COMMIT}" ]; then | ||
COMMIT=$(git rev-parse HEAD || true) | ||
fi | ||
fi | ||
|
||
if [[ -n "$GIT_TAG" ]]; then | ||
VERSION=$GIT_TAG | ||
else | ||
VERSION="${VERSION}+dev.${COMMIT:0:8}$DIRTY" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package version | ||
|
||
import "strings" | ||
|
||
var ( | ||
Program = "cattle-drive" | ||
ProgramUpper = strings.ToUpper(Program) | ||
Version = "dev" | ||
GitCommit = "HEAD" | ||
) |