GOWA - WhatsApp REST API with support for UI, Multi Account, Webhooks, and MCP, and Chatwoot. Built with Golang for efficient memory use.
Go botgogolanggolang-whatsappgolang-whatsapp-apirestrest-apiwhatsappwhatsapp-apiwhatsapp-api-gowhatsapp-multi-devicewhatsapp-web-multi-device
feat: migrating to goreleaser (#322)
Aldino Kemalf4930beaf7f7
diff --git a/.github/workflows/release-linux.yml b/.github/workflows/release-linux.ymldeleted file mode 100644index 16bc7949..00000000--- a/.github/workflows/release-linux.yml+++ /dev/null@@ -1,50 +0,0 @@-name: Release Linux Version--on:- workflow_dispatch:- push:- tags:- - 'v[0-9]+.[0-9]+.[0-9]+'- branches-ignore:- - '*'--jobs:- release-linux-amd64:- if: startsWith(github.ref, 'refs/tags/v')- runs-on: ubuntu-latest- environment: production- steps:- - uses: actions/checkout@v4- - name: Golang Installation- uses: actions/setup-go@v5- with:- go-version: '1.24'- - name: Golang build- run: |- cd src && go build -o linux-amd64- - name: Deploy artifact to release ${{ github.ref_name }}- uses: AButler/[email protected]- with:- files: 'src/linux-amd64'- repo-token: ${{ secrets.GITHUB_TOKEN }}- release-tag: ${{ github.ref_name }}-- release-linux-arm64:- if: startsWith(github.ref, 'refs/tags/v')- runs-on: [ARM64]- environment: production- steps:- - uses: actions/checkout@v4- - name: Golang Installation- uses: actions/setup-go@v5- with:- go-version: '1.24'- - name: Golang build- run: |- cd src && go build -o linux-arm64- - name: Deploy artifact to release ${{ github.ref_name }}- uses: AButler/[email protected]- with:- files: 'src/linux-arm64'- repo-token: ${{ secrets.GITHUB_TOKEN }}- release-tag: ${{ github.ref_name }}\ No newline at end of filediff --git a/.github/workflows/release-mac.yml b/.github/workflows/release-mac.ymldeleted file mode 100644index bf41482b..00000000--- a/.github/workflows/release-mac.yml+++ /dev/null@@ -1,30 +0,0 @@-name: Release Mac Version--on:- workflow_dispatch:- push:- tags:- - 'v[0-9]+.[0-9]+.[0-9]+'- branches-ignore:- - '*'--jobs:- release-macos:- if: startsWith(github.ref, 'refs/tags/v')- runs-on: macos-latest- environment: production- steps:- - uses: actions/checkout@v4- - name: Golang Installation- uses: actions/setup-go@v5- with:- go-version: '1.24'- - name: Golang build- run: |- cd src && go build -o darwin-amd64- - name: Deploy artifact to release ${{ github.ref_name }}- uses: AButler/[email protected]- with:- files: 'src/darwin-amd64'- repo-token: ${{ secrets.GITHUB_TOKEN }}- release-tag: ${{ github.ref_name }}diff --git a/.github/workflows/release-windows.yml b/.github/workflows/release-windows.ymldeleted file mode 100644index 104fb9a1..00000000--- a/.github/workflows/release-windows.yml+++ /dev/null@@ -1,30 +0,0 @@-name: Release Windows Version--on:- workflow_dispatch:- push:- tags:- - 'v[0-9]+.[0-9]+.[0-9]+'- branches-ignore:- - '*'--jobs:- release-windows:- if: startsWith(github.ref, 'refs/tags/v')- runs-on: windows-latest- environment: production- steps:- - uses: actions/checkout@v4- - name: Golang Installation- uses: actions/setup-go@v5- with:- go-version: '1.24'- - name: Golang build- run: |- cd src && go build -o windows-amd64.exe- - name: Deploy artifact to release ${{ github.ref_name }}- uses: AButler/[email protected]- with:- files: 'src/windows-amd64.exe'- repo-token: ${{ secrets.GITHUB_TOKEN }}- release-tag: ${{ github.ref_name }}diff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlnew file mode 100644index 00000000..db4a7ebb--- /dev/null+++ b/.github/workflows/release.yml@@ -0,0 +1,205 @@+name: Release++on:+ workflow_dispatch:+ push:+ tags:+ - 'v[0-9]+.[0-9]+.[0-9]+'++jobs:+ build-linux-windows:+ if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')+ runs-on: ubuntu-latest+ permissions:+ contents: write+ steps:+ - uses: actions/checkout@v4++ - name: Set up Go+ uses: actions/setup-go@v5+ with:+ go-version: '1.24'++ - name: Install cross-compilation toolchains+ run: |+ sudo apt-get update+ sudo apt-get install -y \+ gcc-aarch64-linux-gnu \+ gcc-mingw-w64 \+ libc6-dev-i386-cross \+ gcc-i686-linux-gnu++ - name: Install GoReleaser+ uses: goreleaser/goreleaser-action@v5+ with:+ version: latest+ install-only: true++ - name: Create Linux/Windows GoReleaser config+ run: |+ cat > /tmp/.goreleaser-linux-windows.yml << 'EOF'+ project_name: whatsapp++ builds:+ - id: linux-amd64+ dir: ./src+ main: .+ env:+ - CGO_ENABLED=1+ - CC=gcc+ goos:+ - linux+ goarch:+ - amd64+ ldflags: -s -w+ binary: "{{ .Os }}-{{ .Arch }}"++ - id: linux-arm64+ dir: ./src+ main: .+ env:+ - CGO_ENABLED=1+ - CC=aarch64-linux-gnu-gcc+ goos:+ - linux+ goarch:+ - arm64+ ldflags: -s -w+ binary: "{{ .Os }}-{{ .Arch }}"++ - id: linux-386+ dir: ./src+ main: .+ env:+ - CGO_ENABLED=1+ - CC=i686-linux-gnu-gcc+ goos:+ - linux+ goarch:+ - "386"+ ldflags: -s -w+ binary: "{{ .Os }}-{{ .Arch }}"++ - id: windows-amd64+ dir: ./src+ main: .+ env:+ - CGO_ENABLED=1+ - CC=x86_64-w64-mingw32-gcc+ goos:+ - windows+ goarch:+ - amd64+ ldflags: -s -w+ binary: "{{ .Os }}-{{ .Arch }}"++ - id: windows-386+ dir: ./src+ main: .+ env:+ - CGO_ENABLED=1+ - CC=i686-w64-mingw32-gcc+ goos:+ - windows+ goarch:+ - "386"+ ldflags: -s -w+ binary: "{{ .Os }}-{{ .Arch }}"++ archives:+ - id: binaries+ builds:+ - linux-amd64+ - linux-arm64+ - linux-386+ - windows-amd64+ - windows-386+ format: zip+ name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"++ checksum:+ name_template: "checksums.txt"++ release:+ draft: false+ github:+ owner: "aldinokemal"+ name: "go-whatsapp-web-multidevice"+ EOF++ - name: Run GoReleaser for Linux/Windows+ env:+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}+ run: goreleaser release --config /tmp/.goreleaser-linux-windows.yml --clean --timeout 60m --skip-validate++ build-macos:+ if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')+ runs-on: macos-latest+ permissions:+ contents: write+ steps:+ - uses: actions/checkout@v4++ - name: Set up Go+ uses: actions/setup-go@v5+ with:+ go-version: '1.24'++ - name: Install GoReleaser+ uses: goreleaser/goreleaser-action@v5+ with:+ version: latest+ install-only: true++ - name: Create macOS GoReleaser config+ run: |+ cat > /tmp/.goreleaser-macos.yml << 'EOF'+ project_name: whatsapp++ builds:+ - id: darwin-amd64+ dir: ./src+ main: .+ env:+ - CGO_ENABLED=1+ goos:+ - darwin+ goarch:+ - amd64+ ldflags: -s -w+ binary: "{{ .Os }}-{{ .Arch }}"++ - id: darwin-arm64+ dir: ./src+ main: .+ env:+ - CGO_ENABLED=1+ goos:+ - darwin+ goarch:+ - arm64+ ldflags: -s -w+ binary: "{{ .Os }}-{{ .Arch }}"++ archives:+ - id: binaries+ builds:+ - darwin-amd64+ - darwin-arm64+ format: zip+ name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"++ checksum:+ name_template: "checksums-macos.txt"++ release:+ draft: false+ github:+ owner: "aldinokemal"+ name: "go-whatsapp-web-multidevice"+ EOF++ - name: Run GoReleaser for macOS+ env:+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}+ run: goreleaser release --config /tmp/.goreleaser-macos.yml --timeout 60m --skip-validate\ No newline at end of filediff --git a/.gitignore b/.gitignoreindex afb8def8..89b5fa46 100644--- a/.gitignore+++ b/.gitignore@@ -9,4 +9,5 @@ main.exesrc/pkged.gostorages.env-bin\ No newline at end of file+bin+dist\ No newline at end of filediff --git a/readme.md b/readme.mdindex ed14e39d..446c71fa 100644--- a/readme.md+++ b/readme.md@@ -14,9 +14,7 @@ Your support helps ensure the library stays maintained and receives regular upda___--@@ -36,39 +34,41 @@ Download:## Breaking Changes- `v6`- - For REST mode, you need to run `<binary> rest` instead of `<binary>`- - for example: `./whatsapp rest` instead of ~~./whatsapp~~- - For MCP mode, you need to run `<binary> mcp`- - for example: `./whatsapp mcp`-+ - For REST mode, you need to run `<binary> rest` instead of `<binary>`+ - for example: `./whatsapp rest` instead of ~~./whatsapp~~+ - For MCP mode, you need to run `<binary> mcp`+ - for example: `./whatsapp mcp`+- `v7`+ - Starting version 7.x we are using goreleaser to build the binary, so you can download the binary from [release](https://github.com/aldinokemal/go-whatsapp-web-multidevice/releases/latest)+## Feature- Send WhatsApp message via http API, [docs/openapi.yml](./docs/openapi.yaml) for more details- **MCP (Model Context Protocol) Server Support** - Integrate with AI agents and tools using standardized protocol- Mention someone- - `@phoneNumber`- - example: `Hello @628974812XXXX, @628974812XXXX`+ - `@phoneNumber`+ - example: `Hello @628974812XXXX, @628974812XXXX`- Post Whatsapp Status- Compress image before send- Compress video before send- Change OS name become your app (it's the device name when connect via mobile)- - `--os=Chrome` or `--os=MyApplication`+ - `--os=Chrome` or `--os=MyApplication`- Basic Auth (able to add multi credentials)- - `--basic-auth=kemal:secret,toni:password,userName:secretPassword`, or you can simplify- - `-b=kemal:secret,toni:password,userName:secretPassword`+ - `--basic-auth=kemal:secret,toni:password,userName:secretPassword`, or you can simplify+ - `-b=kemal:secret,toni:password,userName:secretPassword`- Customizable port and debug mode- - `--port 8000`- - `--debug true`+ - `--port 8000`+ - `--debug true`- Auto reply message- - `--autoreply="Don't reply this message"`+ - `--autoreply="Don't reply this message"`- Webhook for received message- - `--webhook="http://yourwebhook.site/handler"`, or you can simplify- - `-w="http://yourwebhook.site/handler"`+ - `--webhook="http://yourwebhook.site/handler"`, or you can simplify+ - `-w="http://yourwebhook.site/handler"`- Webhook SecretOur webhook will be sent to you with an HMAC header and a sha256 default key `secret`.You may modify this by using the option below:- - `--webhook-secret="secret"`+ - `--webhook-secret="secret"`## Configuration@@ -130,14 +130,14 @@ Note: Command-line flags will override any values set in environment variables o### Dependencies (without docker)- Mac OS:- - `brew install ffmpeg`- - `export CGO_CFLAGS_ALLOW="-Xpreprocessor"`+ - `brew install ffmpeg`+ - `export CGO_CFLAGS_ALLOW="-Xpreprocessor"`- Linux:- - `sudo apt update`- - `sudo apt install ffmpeg`+ - `sudo apt update`+ - `sudo apt install ffmpeg`- Windows (not recomended, prefer using [WSL](https://docs.microsoft.com/en-us/windows/wsl/install)):- - install ffmpeg, [download here](https://www.ffmpeg.org/download.html#build-windows)- - add to ffmpeg to [environment variable](https://www.google.com/search?q=windows+add+to+environment+path)+ - install ffmpeg, [download here](https://www.ffmpeg.org/download.html#build-windows)+ - add to ffmpeg to [environment variable](https://www.google.com/search?q=windows+add+to+environment+path)## How to usediff --git a/src/validations/send_validation.go b/src/validations/send_validation.goindex da284a40..10865cf2 100644--- a/src/validations/send_validation.go+++ b/src/validations/send_validation.go@@ -13,6 +13,22 @@ import ("github.com/go-ozzo/ozzo-validation/v4/is")+// maxDuration represents the maximum allowed duration in seconds (uint32 max).+const maxDuration int64 = 4294967295++// validateDuration validates that the duration pointer is nil or within acceptable bounds.+func validateDuration(dur *int) error {+ if dur == nil {+ return nil+ }+ if *dur < 0 || int64(*dur) > int64(maxDuration) {+ return pkgError.ValidationError(+ fmt.Sprintf("duration must be between 0 and %d seconds (0 means no expiry)", maxDuration),+ )+ }+ return nil+}+func ValidateSendMessage(ctx context.Context, request domainSend.MessageRequest) error {err := validation.ValidateStructWithContext(ctx, &request,validation.Field(&request.Phone, validation.Required),@@ -24,8 +40,8 @@ func ValidateSendMessage(ctx context.Context, request domainSend.MessageRequest)}// Custom validation for optional Duration- if request.Duration != nil && (*request.Duration < 0 || *request.Duration > 4294967295) {- return pkgError.ValidationError("duration must be between 0 and 4294967295 seconds (0 means no expiry)")+ if err := validateDuration(request.Duration); err != nil {+ return err}return nil}@@ -67,8 +83,8 @@ func ValidateSendImage(ctx context.Context, request domainSend.ImageRequest) err}// Validate duration- if request.Duration != nil && (*request.Duration < 0 || *request.Duration > 4294967295) {- return pkgError.ValidationError("duration must be between 0 and 4294967295 seconds (0 means no expiry)")+ if err := validateDuration(request.Duration); err != nil {+ return err}return nil@@ -89,8 +105,8 @@ func ValidateSendFile(ctx context.Context, request domainSend.FileRequest) errorreturn pkgError.ValidationError(fmt.Sprintf("max file upload is %s, please upload in cloud and send via text if your file is higher than %s", maxSizeString, maxSizeString))}- if request.Duration != nil && (*request.Duration < 0 || *request.Duration > 4294967295) {- return pkgError.ValidationError("duration must be between 0 and 4294967295 seconds (0 means no expiry)")+ if err := validateDuration(request.Duration); err != nil {+ return err}return nil@@ -141,8 +157,8 @@ func ValidateSendVideo(ctx context.Context, request domainSend.VideoRequest) err}}- if request.Duration != nil && (*request.Duration < 0 || *request.Duration > 4294967295) {- return pkgError.ValidationError("duration must be between 0 and 4294967295 seconds (0 means no expiry)")+ if err := validateDuration(request.Duration); err != nil {+ return err}return nil@@ -159,8 +175,8 @@ func ValidateSendContact(ctx context.Context, request domainSend.ContactRequest)return pkgError.ValidationError(err.Error())}- if request.Duration != nil && (*request.Duration < 0 || *request.Duration > 4294967295) {- return pkgError.ValidationError("duration must be between 0 and 4294967295 seconds (0 means no expiry)")+ if err := validateDuration(request.Duration); err != nil {+ return err}return nil@@ -177,8 +193,8 @@ func ValidateSendLink(ctx context.Context, request domainSend.LinkRequest) errorreturn pkgError.ValidationError(err.Error())}- if request.Duration != nil && (*request.Duration < 0 || *request.Duration > 4294967295) {- return pkgError.ValidationError("duration must be between 0 and 4294967295 seconds (0 means no expiry)")+ if err := validateDuration(request.Duration); err != nil {+ return err}return nil@@ -195,8 +211,8 @@ func ValidateSendLocation(ctx context.Context, request domainSend.LocationRequesreturn pkgError.ValidationError(err.Error())}- if request.Duration != nil && (*request.Duration < 0 || *request.Duration > 4294967295) {- return pkgError.ValidationError("duration must be between 0 and 4294967295 seconds (0 means no expiry)")+ if err := validateDuration(request.Duration); err != nil {+ return err}return nil@@ -265,8 +281,8 @@ func ValidateSendAudio(ctx context.Context, request domainSend.AudioRequest) err}}- if request.Duration != nil && (*request.Duration < 0 || *request.Duration > 4294967295) {- return pkgError.ValidationError("duration must be between 0 and 4294967295 seconds (0 means no expiry)")+ if err := validateDuration(request.Duration); err != nil {+ return err}return nil@@ -293,8 +309,8 @@ func ValidateSendPoll(ctx context.Context, request domainSend.PollRequest) errorreturn pkgError.ValidationError(err.Error())}- if request.Duration != nil && (*request.Duration < 0 || *request.Duration > 4294967295) {- return pkgError.ValidationError("duration must be between 0 and 4294967295 seconds (0 means no expiry)")+ if err := validateDuration(request.Duration); err != nil {+ return err}// validate options should be unique each other