Skip to content

Commit

Permalink
Implement automate build and publish process
Browse files Browse the repository at this point in the history
  • Loading branch information
thedevsaddam committed Dec 21, 2021
1 parent 517f663 commit ec87951
Show file tree
Hide file tree
Showing 6 changed files with 164 additions and 12 deletions.
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "monthly"
target-branch: "v3"
# Labels on pull requests for version updates only
labels:
- "go mod dependencies"
98 changes: 98 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: release

on:
push:
tags:
- "v[0-9]+.*"

jobs:
build_release:
name: build_release
runs-on: ubuntu-latest
steps:
- name: checkout and setup
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: update Golang
uses: actions/setup-go@v2
with:
go-version: '1.17.2'
- name: build binary files
run: make binary
- name: list directory
run: ls -la && ls -la bin
- name: release
uses: actions/create-release@v1
id: create_release
with:
draft: false
prerelease: false
release_name: ${{ github.ref }}
tag_name: ${{ github.ref }}
body_path: CHANGELOG.md
env:
GITHUB_TOKEN: ${{ github.token }}
- name: upload darwin_amd64 binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: bin/darwin_amd64
asset_name: darwin_amd64
asset_content_type: application/octet-stream
- name: upload darwin_arm64 binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: bin/darwin_arm64
asset_name: darwin_arm64
asset_content_type: application/octet-stream
- name: upload linux_amd64 binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: bin/linux_amd64
asset_name: linux_amd64
asset_content_type: application/octet-stream
- name: upload linux_arm64 binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: bin/linux_arm64
asset_name: linux_arm64
asset_content_type: application/octet-stream
- name: upload linux_386 binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: bin/linux_386
asset_name: linux_386
asset_content_type: application/octet-stream
- name: upload windows_386 binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: bin/windows_386.exe
asset_name: windows_386.exe
asset_content_type: application/octet-stream
- name: upload windows_amd64 binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: bin/windows_amd64.exe
asset_name: windows_amd64.exe
asset_content_type: application/octet-stream
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Automate release process
* Include arm builds
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.PHONY: all test coverage
all: test build
build:
go build -o dl
binary:
go run generate-asset.go
./build.sh
install:
go install ./...
test:
go test ./... -v -coverprofile .coverage.txt
go tool cover -func .coverage.txt
coverage: test
go tool cover -html=.coverage.txt
22 changes: 16 additions & 6 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,39 @@ go generate
# MAC
export GOARCH="amd64"
export GOOS="darwin"
export CGO_ENABLED=1
go build -ldflags "-X github.com/thedevsaddam/docgen/cmd.GitCommit=$GIT_COMMIT -X github.com/thedevsaddam/docgen/cmd.Version=$TAG -X github.com/thedevsaddam/docgen/cmd.BuildDate=$DATE" -o mac_amd64 -v .
export CGO_ENABLED=0
go build -ldflags "-X github.com/thedevsaddam/docgen/cmd.GitCommit=$GIT_COMMIT -X github.com/thedevsaddam/docgen/cmd.Version=$TAG -X github.com/thedevsaddam/docgen/cmd.BuildDate=$DATE" -o bin/darwin_amd64 -v .

export GOARCH="arm64"
export GOOS="darwin"
export CGO_ENABLED=0
go build -ldflags "-X github.com/thedevsaddam/docgen/cmd.GitCommit=$GIT_COMMIT -X github.com/thedevsaddam/docgen/cmd.Version=$TAG -X github.com/thedevsaddam/docgen/cmd.BuildDate=$DATE" -o bin/darwin_arm64 -v .

#LINUX
export GOARCH="amd64"
export GOOS="linux"
export CGO_ENABLED=0
go build -ldflags "-X github.com/thedevsaddam/docgen/cmd.GitCommit=$GIT_COMMIT -X github.com/thedevsaddam/docgen/cmd.Version=$TAG -X github.com/thedevsaddam/docgen/cmd.BuildDate=$DATE" -o linux_amd64 -v
go build -ldflags "-X github.com/thedevsaddam/docgen/cmd.GitCommit=$GIT_COMMIT -X github.com/thedevsaddam/docgen/cmd.Version=$TAG -X github.com/thedevsaddam/docgen/cmd.BuildDate=$DATE" -o bin/linux_amd64 -v

export GOARCH="arm64"
export GOOS="linux"
export CGO_ENABLED=0
go build -ldflags "-X github.com/thedevsaddam/docgen/cmd.GitCommit=$GIT_COMMIT -X github.com/thedevsaddam/docgen/cmd.Version=$TAG -X github.com/thedevsaddam/docgen/cmd.BuildDate=$DATE" -o bin/linux_arm64 -v

export GOARCH="386"
export GOOS="linux"
export CGO_ENABLED=0
go build -ldflags "-X github.com/thedevsaddam/docgen/cmd.GitCommit=$GIT_COMMIT -X github.com/thedevsaddam/docgen/cmd.Version=$TAG -X github.com/thedevsaddam/docgen/cmd.BuildDate=$DATE" -o linux_386 -v
go build -ldflags "-X github.com/thedevsaddam/docgen/cmd.GitCommit=$GIT_COMMIT -X github.com/thedevsaddam/docgen/cmd.Version=$TAG -X github.com/thedevsaddam/docgen/cmd.BuildDate=$DATE" -o bin/linux_386 -v

#WINDOWS
export GOARCH="386"
export GOOS="windows"
export CGO_ENABLED=0
go build -ldflags "-X github.com/thedevsaddam/docgen/cmd.GitCommit=$GIT_COMMIT -X github.com/thedevsaddam/docgen/cmd.Version=$TAG -X github.com/thedevsaddam/docgen/cmd.BuildDate=$DATE" -o windows_386.exe -v
go build -ldflags "-X github.com/thedevsaddam/docgen/cmd.GitCommit=$GIT_COMMIT -X github.com/thedevsaddam/docgen/cmd.Version=$TAG -X github.com/thedevsaddam/docgen/cmd.BuildDate=$DATE" -o bin/windows_386.exe -v

export GOARCH="amd64"
export GOOS="windows"
export CGO_ENABLED=0
go build -ldflags "-X github.com/thedevsaddam/docgen/cmd.GitCommit=$GIT_COMMIT -X github.com/thedevsaddam/docgen/cmd.Version=$TAG -X github.com/thedevsaddam/docgen/cmd.BuildDate=$DATE" -o windows_amd64.exe -v
go build -ldflags "-X github.com/thedevsaddam/docgen/cmd.GitCommit=$GIT_COMMIT -X github.com/thedevsaddam/docgen/cmd.Version=$TAG -X github.com/thedevsaddam/docgen/cmd.BuildDate=$DATE" -o bin/windows_amd64.exe -v

echo "Build complete"
30 changes: 24 additions & 6 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,42 @@ if [ "$VERSION" == "" ]; then
fi

if [ "$OS" == "Darwin" ]; then
exec_curl $URL/releases/download/$VERSION/mac_amd64 $TARGET
if [ "$ARCH" == "x86_64" ]; then
exec_curl $URL/releases/download/$VERSION/darwin_amd64 $TARGET
echo "$MESSAGE_START"
chmod +x $TARGET
echo "$MESSAGE_END"
docgen
dl
fi

if [ "$ARCH" == "arm64" ] || [ "$ARCH" == "aarch64" ]; then
exec_curl $URL/releases/download/$VERSION/darwin_arm64 $TARGET
echo "$MESSAGE_START"
chmod +x $TARGET
echo "$MESSAGE_END"
dl
fi

elif [ "$OS" == "Linux" ]; then
if [ "$ARCH" == "x86_64" ]; then
exec_curl $URL/releases/download/$VERSION/linux_amd64 $TARGET
echo "$MESSAGE_START"
chmod +x $TARGET
echo "$MESSAGE_END"
docgen
dl
fi

if [ "$ARCH" == "arm64" ] || [ "$ARCH" == "aarch64" ]; then
exec_curl $URL/releases/download/$VERSION/linux_arm64 $TARGET
echo "$MESSAGE_START"
chmod +x $TARGET
echo "$MESSAGE_END"
dl
fi

if [ "$ARCH" == "i368" ]; then
exec_curl $URL/releases/download/$VERSION/linux_386 $TARGET
chmod +x $TARGET
docgen
dl
fi
fi

fi

0 comments on commit ec87951

Please sign in to comment.