diff --git a/.github/workflows/prs.yml b/.github/workflows/prs.yml index 93cd901..d66dac0 100644 --- a/.github/workflows/prs.yml +++ b/.github/workflows/prs.yml @@ -8,27 +8,27 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 - name: Run Pre-Commit - uses: pre-commit/action@v2.0.3 + uses: pre-commit/action@v3.0.1 build: name: Build runs-on: ubuntu-latest needs: pre-commit steps: - - name: Set up Go 1.23.1 - uses: actions/setup-go@v2 + - name: Set up Go 1.23 + uses: actions/setup-go@v5 with: - go-version: 1.23.1 + go-version: 1.23 id: go - name: Check out code into the Go module directory - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Build Binary run: go build -v . diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..48d3d80 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,87 @@ +name: Release + +on: + push: + tags: + - 'v*' + +permissions: + contents: write + +jobs: + release: + name: Build and Release + runs-on: ubuntu-latest + strategy: + matrix: + include: + - goos: linux + goarch: amd64 + suffix: linux-amd64 + - goos: linux + goarch: arm64 + suffix: linux-arm64 + - goos: linux + goarch: arm + suffix: linux-arm + - goos: linux + goarch: "386" + suffix: linux-386 + - goos: darwin + goarch: amd64 + suffix: darwin-amd64 + - goos: darwin + goarch: arm64 + suffix: darwin-arm64 + - goos: windows + goarch: amd64 + suffix: windows-amd64.exe + - goos: windows + goarch: "386" + suffix: windows-386.exe + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: 1.23 + + - name: Build binary + env: + GOOS: ${{ matrix.goos }} + GOARCH: ${{ matrix.goarch }} + run: | + go build -v \ + -ldflags="-s -w -X main.version=${{ github.ref_name }}" \ + -o checkup-${{ github.ref_name }}-${{ matrix.suffix }} \ + main.go + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: checkup-${{ github.ref_name }}-${{ matrix.suffix }} + path: checkup-${{ github.ref_name }}-${{ matrix.suffix }} + + publish: + name: Publish GitHub Release + runs-on: ubuntu-latest + needs: release + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Download all artifacts + uses: actions/download-artifact@v4 + with: + path: dist/ + merge-multiple: true + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + name: ${{ github.ref_name }} + generate_release_notes: true + files: dist/* diff --git a/makefile b/makefile index 6dfd63e..6f44502 100644 --- a/makefile +++ b/makefile @@ -1,6 +1,6 @@ .PHONY: build run compile build-linux build-windows build-darwin test -VERSION ?= 0.7.0 +VERSION ?= 0.8.0 NAME ?= "checkup" test: @@ -15,8 +15,7 @@ run: build-darwin: echo "Compiling for Darwin" GOOS=darwin GOARCH=amd64 go build -o release/$(NAME)-v${VERSION}-darwin-amd64 main.go - # GOOS=darwin GOARCH=arm go build -v -o release/$(NAME)-v${VERSION}-darwin-arm main.go - # GOOS=darwin GOARCH=arm64 go build -o release/$(NAME)-v${VERSION}-darwin-arm64 main.go + GOOS=darwin GOARCH=arm64 go build -o release/$(NAME)-v${VERSION}-darwin-arm64 main.go build-windows: echo "Compiling for Windows" diff --git a/utils/ReadExam.go b/utils/ReadExam.go index 4456918..887cbcc 100644 --- a/utils/ReadExam.go +++ b/utils/ReadExam.go @@ -3,7 +3,7 @@ package utils import ( "encoding/json" "fmt" - "io/ioutil" + "os" "path/filepath" "strings" @@ -23,7 +23,7 @@ type ExamFile struct { // ReadExam ... Help read a given file and set to a struct func ReadExam(file string) ExamFile { var exam ExamFile - examFile, err := ioutil.ReadFile(file) + examFile, err := os.ReadFile(file) ErrorCheck(err) extension := filepath.Ext(strings.TrimSpace(file)) err = fmt.Errorf("wrong Extension: %v", extension) diff --git a/utils/checkup.go b/utils/checkup.go index 18f249b..08fdf26 100644 --- a/utils/checkup.go +++ b/utils/checkup.go @@ -20,7 +20,7 @@ type CheckupResults struct { Endpoint string Code int Result int - Lantency time.Duration + Latency time.Duration Pass bool } @@ -50,7 +50,7 @@ func Checkup(healthForm CheckupRequest) CheckupResults { Endpoint: healthForm.Endpoint, Code: healthForm.Code, Result: resp.StatusCode, - Lantency: end, + Latency: end, Pass: resp.StatusCode == healthForm.Code, } diff --git a/utils/styledOutput.go b/utils/styledOutput.go index 1cb38a2..9d14222 100644 --- a/utils/styledOutput.go +++ b/utils/styledOutput.go @@ -52,7 +52,7 @@ func Show(checkups []CheckupResults) *table.Table { checkups[count].Endpoint, strconv.Itoa(checkups[count].Code), strconv.Itoa(checkups[count].Result), - strconv.FormatInt(checkups[count].Lantency.Milliseconds(), 10), + strconv.FormatInt(checkups[count].Latency.Milliseconds(), 10), strconv.FormatBool(checkups[count].Pass), ) }