From eb394b0f39ebe3183faa2286434a187b9244ed1a Mon Sep 17 00:00:00 2001 From: Philip Zingmark Date: Thu, 26 Dec 2024 18:59:13 +0100 Subject: [PATCH 01/10] test if this workflow is faster than matrix --- .github/workflows/go.yml | 22 +++++----------------- Makefile | 23 ++++++++++++++++++++++- 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 36ce4c3..a85cdb6 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -2,7 +2,7 @@ name: Go on: push: - branches: ["main"] + branches: ["rc"] paths-ignore: - README.md - .gitignore @@ -22,11 +22,8 @@ jobs: build: runs-on: ubuntu-latest needs: gettime - strategy: - matrix: - os: [linux, windows, darwin] - go-version: ["1.23.1"] env: + GO_VERSION: "1.23.2" TIMESTAMP: ${{ needs.gettime.outputs.timestamp }} steps: - uses: actions/checkout@v4 @@ -34,24 +31,15 @@ jobs: - name: Set up Go uses: actions/setup-go@v4 with: - go-version: ${{ matrix.go-version }} + go-version: ${{ env.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 + run: make all-platforms - name: Upload Artifacts uses: actions/upload-artifact@v4 with: - name: ${{ matrix.os }}-binaries + name: binaries path: bin/* if-no-files-found: error diff --git a/Makefile b/Makefile index b889638..5cc79ce 100644 --- a/Makefile +++ b/Makefile @@ -19,12 +19,33 @@ run: build @echo "Running the application..." @./$(BUILD_DIR)/$(BINARY_NAME) -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) . + @echo "Build complete." + +install: release @echo "installing" @mkdir -p ~/.local/kthcloud/bin @cp ./$(BUILD_DIR)/$(BINARY_NAME) ~/.local/kthcloud/bin/$(BINARY_NAME) @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_amd64_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_arm4_macos . & + @wait + @echo "All builds complete." + clean: @echo "Cleaning up..." @rm -rf $(BUILD_DIR) From 073268ddc68b54c900599ad95b58a4179e169194 Mon Sep 17 00:00:00 2001 From: Philip Zingmark Date: Thu, 26 Dec 2024 22:22:37 +0100 Subject: [PATCH 02/10] =?UTF-8?q?release=20candidate=20se=C3=A5arate=20wor?= =?UTF-8?q?kflow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/go.yml | 22 +++++++++++++++----- .github/workflows/rc.yml | 44 ++++++++++++++++++++++++++++++++++++++++ Makefile | 2 +- 3 files changed, 62 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/rc.yml diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index a85cdb6..36ce4c3 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -2,7 +2,7 @@ name: Go on: push: - branches: ["rc"] + branches: ["main"] paths-ignore: - README.md - .gitignore @@ -22,8 +22,11 @@ jobs: build: runs-on: ubuntu-latest needs: gettime + strategy: + matrix: + os: [linux, windows, darwin] + go-version: ["1.23.1"] env: - GO_VERSION: "1.23.2" TIMESTAMP: ${{ needs.gettime.outputs.timestamp }} steps: - uses: actions/checkout@v4 @@ -31,15 +34,24 @@ jobs: - name: Set up Go uses: actions/setup-go@v4 with: - go-version: ${{ env.GO_VERSION }} + go-version: ${{ matrix.go-version }} - name: Build - run: make all-platforms + 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 - name: Upload Artifacts uses: actions/upload-artifact@v4 with: - name: binaries + name: ${{ matrix.os }}-binaries path: bin/* if-no-files-found: error diff --git a/.github/workflows/rc.yml b/.github/workflows/rc.yml new file mode 100644 index 0000000..5191157 --- /dev/null +++ b/.github/workflows/rc.yml @@ -0,0 +1,44 @@ +name: RC + +on: + push: + branches: ["rc"] + paths-ignore: + - README.md + - .gitignore + #- .github/** + - LICENSE + +jobs: + gettime: + runs-on: ubuntu-latest + outputs: + timestamp: ${{ env.TIMESTAMP }} + steps: + - 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 + env: + GO_VERSION: "1.23.2" + TIMESTAMP: ${{ needs.gettime.outputs.timestamp }} + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: ${{ env.GO_VERSION }} + + - name: Build + run: make all-platforms + + - name: Upload Artifacts + uses: actions/upload-artifact@v4 + with: + name: binaries + path: bin/ + if-no-files-found: error diff --git a/Makefile b/Makefile index 5cc79ce..c648863 100644 --- a/Makefile +++ b/Makefile @@ -42,7 +42,7 @@ all-platforms: @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_amd64_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_arm4_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." From e0335a11f381b0e9d539620b52289358229a26f7 Mon Sep 17 00:00:00 2001 From: Philip Zingmark Date: Thu, 26 Dec 2024 22:24:31 +0100 Subject: [PATCH 03/10] fix workflow? --- .github/workflows/rc.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rc.yml b/.github/workflows/rc.yml index 5191157..578692f 100644 --- a/.github/workflows/rc.yml +++ b/.github/workflows/rc.yml @@ -40,5 +40,5 @@ jobs: uses: actions/upload-artifact@v4 with: name: binaries - path: bin/ + path: bin/** if-no-files-found: error From d8c82bdda3a0dea3d48b4361110df86cb7a661c1 Mon Sep 17 00:00:00 2001 From: Philip Zingmark Date: Thu, 26 Dec 2024 22:32:51 +0100 Subject: [PATCH 04/10] rm usage of makefile in workflow --- .github/workflows/rc.yml | 16 +++++++++++++++- Makefile | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rc.yml b/.github/workflows/rc.yml index 578692f..df5f07f 100644 --- a/.github/workflows/rc.yml +++ b/.github/workflows/rc.yml @@ -34,7 +34,21 @@ jobs: go-version: ${{ env.GO_VERSION }} - name: Build - run: make all-platforms + run: | + 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." + ls bin/ + + - name: List files in bin directory + run: ls -R bin - name: Upload Artifacts uses: actions/upload-artifact@v4 diff --git a/Makefile b/Makefile index c648863..5be1802 100644 --- a/Makefile +++ b/Makefile @@ -40,7 +40,7 @@ all-platforms: @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_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 From b82ee55191d992079fc9b41e2cff3935ca53d501 Mon Sep 17 00:00:00 2001 From: Philip Zingmark Date: Thu, 26 Dec 2024 22:34:37 +0100 Subject: [PATCH 05/10] fix workflow --- .github/workflows/rc.yml | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/.github/workflows/rc.yml b/.github/workflows/rc.yml index df5f07f..c09a80c 100644 --- a/.github/workflows/rc.yml +++ b/.github/workflows/rc.yml @@ -34,18 +34,7 @@ jobs: go-version: ${{ env.GO_VERSION }} - name: Build - run: | - 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." - ls bin/ + run: make all-platforms - name: List files in bin directory run: ls -R bin From 24273baea53ac7c03225d6eebee02ee667e55232 Mon Sep 17 00:00:00 2001 From: Philip Zingmark Date: Thu, 26 Dec 2024 22:41:51 +0100 Subject: [PATCH 06/10] use pure bash for workflow build step --- .github/workflows/rc.yml | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/.github/workflows/rc.yml b/.github/workflows/rc.yml index c09a80c..61aa87a 100644 --- a/.github/workflows/rc.yml +++ b/.github/workflows/rc.yml @@ -10,21 +10,10 @@ on: - LICENSE jobs: - gettime: - runs-on: ubuntu-latest - outputs: - timestamp: ${{ env.TIMESTAMP }} - steps: - - 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 env: GO_VERSION: "1.23.2" - TIMESTAMP: ${{ needs.gettime.outputs.timestamp }} steps: - uses: actions/checkout@v4 @@ -34,7 +23,23 @@ jobs: go-version: ${{ env.GO_VERSION }} - name: Build - run: make all-platforms + shell: bash + run: | + BUILD_DIR=./bin + BUILDTIMESTAMP=$(date +'%Y%m%d%H%M%S') + mkdir -p "$BUILD_DIR" + echo "Building for multiple platforms..." + platforms=("linux/amd64" "linux/arm64" "windows/amd64" "windows/arm64" "darwin/amd64" "darwin/arm64") + + for platform in "${platforms[@]}"; do + GOOS=${platform%/*} GOARCH=${platform#*/} CGO_ENABLED=0 \ + go build -mod=readonly -ldflags "-w -s -X main.buildTimestamp=$BUILDTIMESTAMP" \ + -o "$BUILD_DIR"/kthcloud_${GOARCH}_${GOOS}${GOOS/windows/.exe} . & + done + + wait + echo "All builds complete." + ls "$BUILD_DIR"/ - name: List files in bin directory run: ls -R bin From 7e6439de84923fdd17ddfade728b2476a3a040d8 Mon Sep 17 00:00:00 2001 From: Philip Zingmark Date: Thu, 26 Dec 2024 22:58:15 +0100 Subject: [PATCH 07/10] update makefile --- .github/workflows/go.yml | 2 +- .github/workflows/rc.yml | 45 +++++++++++++++++++--------------------- Makefile | 9 ++++---- 3 files changed, 27 insertions(+), 29 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 36ce4c3..43c241b 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -43,7 +43,7 @@ jobs: 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 }} ;; + GOOS=windows GOARCH=amd64 make BINARY_NAME=kthcloud_amd64_windows BUILDTIMESTAMP=${{ env.TIMESTAMP }} ;; darwin) GOOS=darwin GOARCH=arm64 make BINARY_NAME=kthcloud_arm64_macos BUILDTIMESTAMP=${{ env.TIMESTAMP }} ;; esac diff --git a/.github/workflows/rc.yml b/.github/workflows/rc.yml index 61aa87a..d79937f 100644 --- a/.github/workflows/rc.yml +++ b/.github/workflows/rc.yml @@ -10,43 +10,40 @@ on: - LICENSE jobs: + gettime: + runs-on: ubuntu-latest + outputs: + timestamp: ${{ env.TIMESTAMP }} + steps: + - 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 + strategy: + matrix: + os: [linux, windows, darwin] + arch: [amd64, arm64] + go-version: ["1.23.2"] env: - GO_VERSION: "1.23.2" + TIMESTAMP: ${{ needs.gettime.outputs.timestamp }} steps: - uses: actions/checkout@v4 - name: Set up Go - uses: actions/setup-go@v5 + uses: actions/setup-go@v4 with: - go-version: ${{ env.GO_VERSION }} + go-version: ${{ matrix.go-version }} - name: Build - shell: bash run: | - BUILD_DIR=./bin - BUILDTIMESTAMP=$(date +'%Y%m%d%H%M%S') - mkdir -p "$BUILD_DIR" - echo "Building for multiple platforms..." - platforms=("linux/amd64" "linux/arm64" "windows/amd64" "windows/arm64" "darwin/amd64" "darwin/arm64") - - for platform in "${platforms[@]}"; do - GOOS=${platform%/*} GOARCH=${platform#*/} CGO_ENABLED=0 \ - go build -mod=readonly -ldflags "-w -s -X main.buildTimestamp=$BUILDTIMESTAMP" \ - -o "$BUILD_DIR"/kthcloud_${GOARCH}_${GOOS}${GOOS/windows/.exe} . & - done - - wait - echo "All builds complete." - ls "$BUILD_DIR"/ - - - name: List files in bin directory - run: ls -R bin + 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: binaries - path: bin/** + name: ${{ matrix.os }}-binaries + path: bin/* if-no-files-found: error diff --git a/Makefile b/Makefile index 5be1802..fcf1b60 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -12,12 +13,12 @@ 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) test: @go test ./... @@ -25,13 +26,13 @@ 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) . + @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: From 62574e86d86bbcbe1b74083c1e4b4e91288e672b Mon Sep 17 00:00:00 2001 From: Philip Zingmark Date: Thu, 26 Dec 2024 23:09:58 +0100 Subject: [PATCH 08/10] improve workflow --- .github/workflows/rc.yml | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/.github/workflows/rc.yml b/.github/workflows/rc.yml index d79937f..144be48 100644 --- a/.github/workflows/rc.yml +++ b/.github/workflows/rc.yml @@ -10,33 +10,49 @@ 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: Cache Go Modules + uses: actions/cache@v3 + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: go-mod-${{ env.GO_VERSION }}-${{ hashFiles('**/go.sum') }} + restore-keys: | + go-mod-${{ env.GO_VERSION }}- + + - name: Set up Go + uses: actions/setup-go@v4 + 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] arch: [amd64, arm64] - go-version: ["1.23.2"] 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: | GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} make release BINARY_NAME=kthcloud_${{ matrix.arch }}_${{ matrix.os }} BUILDTIMESTAMP=${{ env.TIMESTAMP }} @@ -44,6 +60,6 @@ jobs: - 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 From 6458934c3e43e986d12bdea84e11631a34268aa3 Mon Sep 17 00:00:00 2001 From: Philip Zingmark Date: Thu, 26 Dec 2024 23:25:25 +0100 Subject: [PATCH 09/10] rm uneccesary cache --- .github/workflows/rc.yml | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/.github/workflows/rc.yml b/.github/workflows/rc.yml index 144be48..44fa33e 100644 --- a/.github/workflows/rc.yml +++ b/.github/workflows/rc.yml @@ -19,18 +19,8 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Cache Go Modules - uses: actions/cache@v3 - with: - path: | - ~/.cache/go-build - ~/go/pkg/mod - key: go-mod-${{ env.GO_VERSION }}-${{ hashFiles('**/go.sum') }} - restore-keys: | - go-mod-${{ env.GO_VERSION }}- - - name: Set up Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: ${{ env.GO_VERSION }} From 713c70d24a0ab2105b42651d133b1d8610974625 Mon Sep 17 00:00:00 2001 From: Philip Zingmark Date: Thu, 26 Dec 2024 23:33:40 +0100 Subject: [PATCH 10/10] fix main workflow and add support for more architecture os combos --- .github/workflows/go.yml | 46 +++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 43c241b..1f04c8a 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -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 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: @@ -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