Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from alienc0der/master
cicd: added cicd pipeline
- Loading branch information
Showing
9 changed files
with
202 additions
and
13 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,64 @@ | ||
name: Build and release orchestrator | ||
|
||
on: | ||
push: | ||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
jobs: | ||
xgo: | ||
permissions: write-all | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Install zip utility | ||
run: | | ||
sudo apt update | ||
sudo apt install -y zip | ||
- name: Make version | ||
run: make version | ||
- name: Build orchestrator | ||
uses: crazy-max/ghaction-xgo@v2.4.0 | ||
with: | ||
xgo_version: latest | ||
go_version: 1.20.0 | ||
dest: build | ||
prefix: orchestrator | ||
pkg: ./main.go | ||
targets: linux/amd64,linux/arm64 | ||
v: true | ||
x: true | ||
ldflags: '-extldflags "-Wl,--allow-multiple-definition"' | ||
buildvcs: false | ||
buildmode: default | ||
trimpath: true | ||
- name: Add execute flag | ||
run: | | ||
chmod +x build/* | ||
- name: Archive files | ||
run: | | ||
cd build | ||
zip orchestrator-linux-amd64.zip orchestrator-linux-amd64 | ||
zip orchestrator-linux-arm64.zip orchestrator-linux-arm64 | ||
rm orchestrator-linux-amd64 | ||
rm orchestrator-linux-arm64 | ||
- name: Generate checksums | ||
run: | | ||
cd build | ||
echo $(sha256sum *) | ||
echo $(sha256sum *) >> SHA256CHECKSUMS.txt | ||
- name: Set version | ||
run: | | ||
ORCHESTRATOR=$(cat metadata/version.go | grep Version | awk -F '"' '{print $2}') | ||
echo "ORCHESTRATOR_VERSION=$ORCHESTRATOR" >> $GITHUB_ENV | ||
- name: Upload files to a GitHub release | ||
uses: svenstaro/upload-release-action@2.5.0 | ||
with: | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
file: build/* | ||
release_name: ${{ env.ORCHESTRATOR_VERSION }} | ||
tag: ${{ env.ORCHESTRATOR_VERSION }}-alphanet | ||
file_glob: true | ||
overwrite: true | ||
body: "" |
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 |
---|---|---|
@@ -1,11 +1,24 @@ | ||
.PHONY: all clean version | ||
|
||
GO ?= latest | ||
|
||
BINARY_NAME=orchestrator | ||
BUILDDIR = $(shell pwd)/build | ||
GIT_COMMIT=$(shell git rev-parse HEAD) | ||
GIT_COMMIT_FILE=$(shell pwd)/metadata/git_commit.go | ||
|
||
build: | ||
go build --ldflags '-extldflags "-Wl,--allow-multiple-definition"' -o ${BINARY_NAME} main.go | ||
go build --ldflags '-extldflags "-Wl,--allow-multiple-definition"' -o $(BUILDDIR)/${BINARY_NAME} main.go | ||
|
||
run: | ||
./${BINARY_NAME} | ||
|
||
version: | ||
@echo "package metadata\n" > $(GIT_COMMIT_FILE) | ||
@echo "const (" >> $(GIT_COMMIT_FILE) | ||
@echo "\tGitCommit = \"${GIT_COMMIT}\"" >> $(GIT_COMMIT_FILE) | ||
@echo ")" >> $(GIT_COMMIT_FILE) | ||
|
||
clean: | ||
go clean | ||
rm orchestrator | ||
rm $(BINARY_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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package app | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"runtime" | ||
|
||
"orchestrator/metadata" | ||
|
||
"gopkg.in/urfave/cli.v1" | ||
) | ||
|
||
var ( | ||
versionCommand = cli.Command{ | ||
Action: versionAction, | ||
Name: "version", | ||
Usage: "Print version numbers", | ||
ArgsUsage: " ", | ||
Category: "MISCELLANEOUS COMMANDS", | ||
} | ||
) | ||
|
||
func versionAction(*cli.Context) error { | ||
fmt.Printf(`orchestrator | ||
Version:%v | ||
Architecture:%v | ||
Go Version:%v | ||
Operating System:%v | ||
GOPATH:%v | ||
GOROOT:%v | ||
Commit hash:%v | ||
`, metadata.Version, runtime.GOARCH, runtime.Version(), runtime.GOOS, os.Getenv("GOPATH"), runtime.GOROOT(), metadata.GitCommit) | ||
return nil | ||
} |
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,34 @@ | ||
package app | ||
|
||
import ( | ||
"gopkg.in/urfave/cli.v1" | ||
) | ||
|
||
var ( | ||
|
||
// pprof | ||
|
||
PprofFlag = cli.BoolFlag{ | ||
Name: "pprof", | ||
Usage: "Enable the pprof HTTP server", | ||
} | ||
PprofPortFlag = cli.Uint64Flag{ | ||
Name: "pprof.port", | ||
Usage: "pprof HTTP server listening port", | ||
Value: 6060, | ||
} | ||
|
||
PprofAddrFlag = cli.StringFlag{ | ||
Name: "pprof.addr", | ||
Usage: "pprof HTTP server listening interface", | ||
Value: "127.0.0.1", | ||
} | ||
|
||
AllFlags = []cli.Flag{ | ||
|
||
// pprof | ||
PprofFlag, | ||
PprofPortFlag, | ||
PprofAddrFlag, | ||
} | ||
) |
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
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,5 @@ | ||
package metadata | ||
|
||
const ( | ||
GitCommit = "" | ||
) |
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,5 @@ | ||
package metadata | ||
|
||
const ( | ||
Version = "v0.0.1" | ||
) |