From 2e77d8e5c7382bb4559c367bfc6dc8d4ebf3e7bf Mon Sep 17 00:00:00 2001 From: Andriy Oblivantsev Date: Wed, 24 Jun 2026 14:46:53 +0100 Subject: [PATCH] ci: add GitHub Actions test pipeline and GoReleaser releases for oo Mirror eSlider/go-config: release-please for semver, tag-triggered GoReleaser builds cross-platform oo binaries with embedded version metadata. Co-authored-by: Cursor --- .github/workflows/release-please.yml | 26 ++++++++ .github/workflows/release.yml | 32 ++++++++++ .github/workflows/test.yml | 46 ++++++++++++++ .goreleaser.yml | 95 ++++++++++++++++++++++++++++ .release-please-manifest.json | 3 + CHANGELOG.md | 5 ++ cmd/oo/common.go | 1 + cmd/oo/version.go | 8 +++ release-please-config.json | 28 ++++++++ 9 files changed, 244 insertions(+) create mode 100644 .github/workflows/release-please.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/test.yml create mode 100644 .goreleaser.yml create mode 100644 .release-please-manifest.json create mode 100644 cmd/oo/version.go create mode 100644 release-please-config.json diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml new file mode 100644 index 0000000..031dc06 --- /dev/null +++ b/.github/workflows/release-please.yml @@ -0,0 +1,26 @@ +name: Release Please + +on: + push: + branches: [main] + +permissions: + contents: write + pull-requests: write + +jobs: + release-please: + name: Release Please + runs-on: ubuntu-latest + steps: + - name: Run release-please + uses: googleapis/release-please-action@v4 + id: release + with: + config-file: release-please-config.json + manifest-file: .release-please-manifest.json + token: ${{ secrets.RELEASE_PLEASE_TOKEN != '' && secrets.RELEASE_PLEASE_TOKEN || secrets.GITHUB_TOKEN }} + + outputs: + release_created: ${{ steps.release.outputs.release_created }} + tag_name: ${{ steps.release.outputs.tag_name }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..35b1b0f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,32 @@ +name: Release + +on: + push: + tags: ["v*"] + +permissions: + contents: write + +jobs: + goreleaser: + name: GoReleaser + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: stable + cache: true + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v6 + with: + distribution: goreleaser + version: "~> v2" + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..6b77be7 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,46 @@ +name: Tests + +on: + push: + branches: [main] + pull_request: + +permissions: + contents: read + +jobs: + test: + name: Test (Go ${{ matrix.go }}) + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + go: ["1.22", "stable"] + + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: ${{ matrix.go }} + cache: true + + - name: Verify dependencies + run: | + go mod verify + go mod download + + - name: Check go mod tidy + run: | + go mod tidy + git diff --exit-code go.mod go.sum + + - name: Vet + run: go vet ./... + + - name: Build oo + run: go build -trimpath -buildvcs=false -o /tmp/oo ./cmd/oo + + - name: Run tests + run: go test -race -shuffle=on -count=1 ./... diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..a24edb8 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,95 @@ +version: 2 + +project_name: go-onlyoffice + +before: + hooks: + - go mod tidy + - go mod verify + +builds: + - id: oo + main: ./cmd/oo + binary: oo + env: + - CGO_ENABLED=0 + goos: + - linux + - darwin + - windows + goarch: + - amd64 + - arm64 + ignore: + - goos: windows + goarch: arm64 + flags: + - -trimpath + - -buildvcs=false + ldflags: + - -s -w + - -X main.version={{.Version}} + - -X main.commit={{.Commit}} + - -X main.date={{.Date}} + +archives: + - id: oo + ids: [oo] + name_template: "oo_{{ .Version }}_{{ .Os }}_{{ .Arch }}" + format_overrides: + - goos: windows + formats: [zip] + files: + - LICENSE + - README.md + - CHANGELOG.md + +checksum: + name_template: checksums.txt + algorithm: sha256 + +snapshot: + version_template: "{{ .Tag }}-next" + +changelog: + use: github + sort: asc + groups: + - title: Features + regexp: '^.*?feat(\(.+\))??!?:.+$' + order: 0 + - title: Bug fixes + regexp: '^.*?fix(\(.+\))??!?:.+$' + order: 1 + - title: Performance + regexp: '^.*?perf(\(.+\))??!?:.+$' + order: 2 + - title: Others + order: 999 + filters: + exclude: + - "^docs:" + - "^test:" + - "^ci:" + - "^chore:" + - "^style:" + - "^build:" + - "Merge pull request" + - "Merge branch" + +release: + draft: false + prerelease: auto + mode: replace + header: | + ## `oo` {{ .Tag }} + + Install: + + ```sh + go install github.com/eslider/go-onlyoffice/cmd/oo@{{ .Tag }} + ``` + + Or download a prebuilt binary below. + footer: | + **Full Changelog**: https://github.com/eSlider/go-onlyoffice/compare/{{ .PreviousTag }}...{{ .Tag }} diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 0000000..0477999 --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "0.3.2" +} diff --git a/CHANGELOG.md b/CHANGELOG.md index 0926609..2683b09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,11 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - `oo companies dedupe|dedupe-persons`, `oo persons dedupe`, `oo contacts dedupe-info`, `oo opportunities dedupe|dedupe-members|fix-titles`, `oo crm cleanup`. +### Added — CI/CD + +- GitHub Actions: `test.yml` (vet, unit tests, `oo` build), `release-please.yml` + (semver from conventional commits), `release.yml` (GoReleaser binaries for `oo`). + ### Changed — CLI - `oo applications sync` — empty position uses company-only deal title; skips diff --git a/cmd/oo/common.go b/cmd/oo/common.go index b8cc9d7..18d09fb 100644 --- a/cmd/oo/common.go +++ b/cmd/oo/common.go @@ -21,6 +21,7 @@ var rootCmd = &cobra.Command{ Use: "oo", Short: "OnlyOffice Workspace CLI — subject-based command tree", Long: "oo is a thin CLI over github.com/eslider/go-onlyoffice.\nCommands are grouped by OnlyOffice subject (calendar, projects, tasks, users, persons, companies, opportunities, cases, crm-tasks, applications).", + Version: version, SilenceUsage: true, SilenceErrors: false, } diff --git a/cmd/oo/version.go b/cmd/oo/version.go new file mode 100644 index 0000000..e790670 --- /dev/null +++ b/cmd/oo/version.go @@ -0,0 +1,8 @@ +package main + +// Build metadata injected at release time via -ldflags (GoReleaser). +var ( + version = "dev" + commit = "none" + date = "unknown" +) diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 0000000..b65f344 --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,28 @@ +{ + "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json", + "release-type": "go", + "bump-minor-pre-major": true, + "bump-patch-for-minor-pre-major": false, + "include-v-in-tag": true, + "include-component-in-tag": false, + "pull-request-title-pattern": "chore${scope}: release ${version}", + "changelog-path": "CHANGELOG.md", + "changelog-sections": [ + { "type": "feat", "section": "Features" }, + { "type": "fix", "section": "Bug Fixes" }, + { "type": "perf", "section": "Performance Improvements" }, + { "type": "revert", "section": "Reverts" }, + { "type": "refactor", "section": "Code Refactoring" }, + { "type": "docs", "section": "Documentation" }, + { "type": "test", "section": "Tests", "hidden": true }, + { "type": "build", "section": "Build System", "hidden": true }, + { "type": "ci", "section": "Continuous Integration", "hidden": true }, + { "type": "chore", "section": "Miscellaneous", "hidden": true }, + { "type": "style", "section": "Styles", "hidden": true } + ], + "packages": { + ".": { + "package-name": "go-onlyoffice" + } + } +}