Skip to content
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
46 changes: 20 additions & 26 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,58 +10,57 @@ on:
- LICENSE

jobs:
gettime:
setup:
runs-on: ubuntu-latest
env:
GO_VERSION: 1.23.2
outputs:
timestamp: ${{ env.TIMESTAMP }}
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}

- name: Install Dependencies
run: go mod download

- name: Get current timestamp
id: timestamp
run: echo "TIMESTAMP=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_ENV

build:
runs-on: ubuntu-latest
needs: gettime
needs: setup
strategy:
matrix:
os: [linux, windows, darwin]
go-version: ["1.23.1"]
arch: [amd64, arm64]
env:
TIMESTAMP: ${{ needs.gettime.outputs.timestamp }}
TIMESTAMP: ${{ needs.setup.outputs.timestamp }}
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}

- name: Build
run: |
mkdir -p bin
case ${{ matrix.os }} in
linux)
GOOS=linux GOARCH=amd64 make BINARY_NAME=kthcloud_amd64_linux BUILDTIMESTAMP=${{ env.TIMESTAMP }} ;;
windows)
GOOS=windows GOARCH=amd64 make BINARY_NAME=kthcloud_amd64_windows.exe BUILDTIMESTAMP=${{ env.TIMESTAMP }} ;;
darwin)
GOOS=darwin GOARCH=arm64 make BINARY_NAME=kthcloud_arm64_macos BUILDTIMESTAMP=${{ env.TIMESTAMP }} ;;
esac
GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} make release BINARY_NAME=kthcloud_${{ matrix.arch }}_${{ matrix.os }} BUILDTIMESTAMP=${{ env.TIMESTAMP }}

- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}-binaries
name: ${{ matrix.arch }}_${{ matrix.os }}_bins
path: bin/*
if-no-files-found: error

release:
needs:
- gettime
- setup
- build
runs-on: ubuntu-latest
env:
TIMESTAMP: ${{ needs.gettime.outputs.timestamp }}
TIMESTAMP: ${{ needs.setup.outputs.timestamp }}
outputs:
upload_url: ${{ steps.step_upload_url.outputs.upload_url }}
steps:
Expand All @@ -71,11 +70,6 @@ jobs:
path: "./artifacts"
if-no-files-found: error

- name: Generate SHA512 checksums
run: |
cd artifacts
find . -type f -name 'kthcloud*' -exec sha512sum {} + | sed 's|^\./||' > SHA512SUMS.txt

- name: Create Release
id: create_release
uses: softprops/action-gh-release@v2
Expand Down
55 changes: 55 additions & 0 deletions .github/workflows/rc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: RC

on:
push:
branches: ["rc"]
paths-ignore:
- README.md
- .gitignore
#- .github/**
- LICENSE

jobs:
setup:
runs-on: ubuntu-latest
env:
GO_VERSION: 1.23.2
outputs:
timestamp: ${{ env.TIMESTAMP }}
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}

- name: Install Dependencies
run: go mod download

- name: Get current timestamp
id: timestamp
run: echo "TIMESTAMP=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_ENV

build:
runs-on: ubuntu-latest
needs: setup
strategy:
matrix:
os: [linux, windows, darwin]
arch: [amd64, arm64]
env:
TIMESTAMP: ${{ needs.setup.outputs.timestamp }}
steps:
- uses: actions/checkout@v4

- name: Build
run: |
GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} make release BINARY_NAME=kthcloud_${{ matrix.arch }}_${{ matrix.os }} BUILDTIMESTAMP=${{ env.TIMESTAMP }}

- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.arch }}_${{ matrix.os }}_bins
path: bin/*
if-no-files-found: error
30 changes: 26 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ BINARY_NAME=kthcloud
BUILD_DIR=bin
MAIN_FILE=main.go
BUILDTIMESTAMP=$(shell date -u +%Y%m%d%H%M%S)
EXT=$(if $(filter windows,$(GOOS)),.exe,)

# Targets
.PHONY: all clean build run
Expand All @@ -12,19 +13,40 @@ all: build
build:
@echo "Building the application..."
@mkdir -p $(BUILD_DIR)
@CGO_ENABLED=0 go build -ldflags "-X main.buildTimestamp=$(BUILDTIMESTAMP)" -o $(BUILD_DIR)/$(BINARY_NAME) .
@CGO_ENABLED=0 go build -ldflags "-X main.buildTimestamp=$(BUILDTIMESTAMP)" -o $(BUILD_DIR)/$(BINARY_NAME)$(EXT) .
@echo "Build complete."

run: build
@echo "Running the application..."
@./$(BUILD_DIR)/$(BINARY_NAME)
@./$(BUILD_DIR)/$(BINARY_NAME)$(EXT)

install: build
test:
@go test ./...

release:
@echo "Building the application..."
@mkdir -p $(BUILD_DIR)
@CGO_ENABLED=0 go build -mod=readonly -ldflags "-w -s -X main.buildTimestamp=$(BUILDTIMESTAMP)" -o $(BUILD_DIR)/$(BINARY_NAME)$(EXT) .
@echo "Build complete."

install: release
@echo "installing"
@mkdir -p ~/.local/kthcloud/bin
@cp ./$(BUILD_DIR)/$(BINARY_NAME) ~/.local/kthcloud/bin/$(BINARY_NAME)
@cp ./$(BUILD_DIR)/$(BINARY_NAME)$(EXT) ~/.local/kthcloud/bin/$(BINARY_NAME)$(EXT)
@echo "add to PATH"

all-platforms:
@echo "Building for multiple platforms..."
@mkdir -p $(BUILD_DIR)
@GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -mod=readonly -ldflags "-w -s -X main.buildTimestamp=$(BUILDTIMESTAMP)" -o $(BUILD_DIR)/kthcloud_amd64_linux . &
@GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -mod=readonly -ldflags "-w -s -X main.buildTimestamp=$(BUILDTIMESTAMP)" -o $(BUILD_DIR)/kthcloud_arm64_linux . &
@GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -mod=readonly -ldflags "-w -s -X main.buildTimestamp=$(BUILDTIMESTAMP)" -o $(BUILD_DIR)/kthcloud_amd64_windows.exe . &
@GOOS=windows GOARCH=arm64 CGO_ENABLED=0 go build -mod=readonly -ldflags "-w -s -X main.buildTimestamp=$(BUILDTIMESTAMP)" -o $(BUILD_DIR)/kthcloud_arm64_windows.exe . &
@GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -mod=readonly -ldflags "-w -s -X main.buildTimestamp=$(BUILDTIMESTAMP)" -o $(BUILD_DIR)/kthcloud_amd64_macos . &
@GOOS=darwin GOARCH=arm64 CGO_ENABLED=0 go build -mod=readonly -ldflags "-w -s -X main.buildTimestamp=$(BUILDTIMESTAMP)" -o $(BUILD_DIR)/kthcloud_arm64_macos . &
@wait
@echo "All builds complete."

clean:
@echo "Cleaning up..."
@rm -rf $(BUILD_DIR)
Expand Down
Loading