diff --git a/.github/workflows/go-tests.yaml b/.github/workflows/go-tests.yaml index 648e627..fb051f9 100644 --- a/.github/workflows/go-tests.yaml +++ b/.github/workflows/go-tests.yaml @@ -2,24 +2,24 @@ name: Go Tests on: push: - branches: [ 'main', 'develop' ] + branches: ["main", "develop"] pull_request: - branches: [ '*' ] + branches: ["*"] jobs: tests: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Set up Go - uses: actions/setup-go@v2 - with: - go-version: 1.22 - - name: Download dependencies - run: make dep - - name: Build - run: make build - - name: Test - run: make test - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v2 + - uses: actions/checkout@v2 + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.22 + - name: Download dependencies + run: make tidy + - name: Build + run: make build + - name: Test + run: make test + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v2 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index cec108b..90eeff5 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -3,7 +3,7 @@ name: Build and Release on: push: tags: - - 'v*.*.*' + - "v*.*.*" jobs: build: @@ -14,51 +14,51 @@ jobs: go-version: [1.22] steps: - - name: Checkout code - uses: actions/checkout@v3 + - name: Checkout code + uses: actions/checkout@v3 - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version: ${{ matrix.go-version }} + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: ${{ matrix.go-version }} - - name: Set Release Version - id: set_release_version - run: | - echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + - name: Set Release Version + id: set_release_version + run: | + echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV - - name: Install dependencies - run: make dep + - name: Install dependencies + run: make tidy - - name: Build - run: | - export AppVersion="${{ env.RELEASE_VERSION }}" - echo "Building version: $AppVersion" - make dist + - name: Build + run: | + export AppVersion="${{ env.RELEASE_VERSION }}" + echo "Building version: $AppVersion" + make dist - - name: Archive build artifacts - uses: actions/upload-artifact@v3 - with: - name: build - path: build - if-no-files-found: error + - name: Archive build artifacts + uses: actions/upload-artifact@v3 + with: + name: build + path: build + if-no-files-found: error release: needs: build runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v3 + - name: Checkout code + uses: actions/checkout@v3 - - name: Download build artifacts - uses: actions/download-artifact@v3 - with: - name: build - path: build + - name: Download build artifacts + uses: actions/download-artifact@v3 + with: + name: build + path: build - - name: Create GitHub Release - uses: softprops/action-gh-release@v1 - with: - files: ./build/* - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Create GitHub Release + uses: softprops/action-gh-release@v1 + with: + files: ./build/* + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/Makefile b/Makefile index 83f8543..4221f76 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION := $(or $(AppVersion), "v1.1.2") +VERSION := $(or $(AppVersion), "v0.0.0") COMMIT := $(or $(shell git rev-parse --short HEAD), "unknown") BUILDDATE := $(shell date +%Y-%m-%d) @@ -9,7 +9,7 @@ ARCHITECTURES = amd64 arm64 arm all: build -dep: +tidy: go mod tidy test: @@ -19,15 +19,27 @@ run: build ./chatz "This is test." install: build - cp chatz /usr/local/bin/chatz - cp man/chatz.1 /usr/local/share/man/man1/chatz.1 + @cp man/chatz.1 man/chatz.old + @sed -e "s|BUILDDATE|$(BUILDDATE)|g" -e "s|VERSION|$(VERSION)|g" man/chatz.old > man/chatz.1 + @cp chatz /usr/local/bin/chatz + @cp man/chatz.1 /usr/local/share/man/man1/chatz.1 + @mv man/chatz.old man/chatz.1 + @echo "chatz successfully installed." + +uninstall: + @rm /usr/local/bin/chatz + @rm /usr/local/share/man/man1/chatz.1 + @echo "chatz successfully uninstalled." build: go build -ldflags="$(LDFLAGS)" -o chatz . dist: + @cp man/chatz.1 man/chatz.old + @sed -e "s|BUILDDATE|$(BUILDDATE)|g" -e "s|VERSION|$(VERSION)|g" man/chatz.old > man/chatz.1 @for platform in $(PLATFORMS); do \ for arch in $(ARCHITECTURES); do \ + if [ "$$platform" = "darwin" ] && [ "$$arch" = "arm" ]; then continue; fi; \ extension=""; if [ "$$platform" = "windows" ]; then extension=".exe"; fi; \ CGO_ENABLED=0 GOOS=$$platform GOARCH=$$arch go build -ldflags="$(LDFLAGS)" -o build/chatz-$$platform-$$arch$$extension; \ if [ ! -f build/chatz-$$platform-$$arch ]; then continue; fi; \ @@ -36,7 +48,13 @@ dist: tar -zcvf build/chatz-$$platform-$$arch.tar.gz build/chatz man/chatz.1; \ done \ done - rm build/chatz + @rm build/chatz + @mv man/chatz.old man/chatz.1 + # Generating checksum + @cd build && sha256sum * > ../checksum-sha256sum.txt + @cd build && md5sum * > checksum-md5sum.txt + @cd build && mv ../checksum-sha256sum.txt checksum-sha256sum.txt + @echo "Checksum generated successfully." clean: rm -rf chatz build diff --git a/README.md b/README.md index 1c55d51..56a5ee8 100644 --- a/README.md +++ b/README.md @@ -40,21 +40,24 @@ brew install chatz ### Linux Installation ```sh -curl -sL https://github.com/tech-thinker/chatz/releases/download/v1.1.3/chatz-linux-amd64 -o chatz +TAG= +curl -sL "https://github.com/tech-thinker/chatz/releases/download/${TAG}/chatz-linux-amd64" -o chatz chmod +x chatz sudo mv chatz /usr/bin ``` ### MacOS Installation ```sh -curl -sL https://github.com/tech-thinker/chatz/releases/download/v1.1.3/chatz-darwin-amd64 -o chatz +TAG= +curl -sL "https://github.com/tech-thinker/chatz/releases/download/${TAG}/chatz-darwin-amd64" -o chatz chmod +x chatz sudo mv chatz /usr/bin ``` ### Windows Installation ```sh -curl -sL https://github.com/tech-thinker/chatz/releases/download/v1.1.3/chatz-windows-amd64.exe -o chatz.exe +TAG= +curl -sL "https://github.com/tech-thinker/chatz/releases/download/${TAG}/chatz-windows-amd64.exe" -o chatz.exe chatz.exe ``` diff --git a/man/chatz.1 b/man/chatz.1 index 0c7ecf8..3fe5b4f 100644 --- a/man/chatz.1 +++ b/man/chatz.1 @@ -1,4 +1,4 @@ -.TH CHATZ 1 "September 25, 2024" "Version 1.1.2" "User Commands" +.TH CHATZ 1 "BUILDDATE" "Version VERSION" "User Commands" .SH NAME chatz \- a CLI tool for sending notifications to Google Chat, Slack, Discord, Telegram etc. .SH SYNOPSIS @@ -123,4 +123,3 @@ Ensure that each service is properly configured with valid tokens and webhook UR .BR nano (1), .SH AUTHOR Written by tech-thinker, as part of the `chatz` project. -