# Copyright © 2023 OpenIM open source community. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com
before:
  hooks:
    # You may remove this if you don't use go modules.
    - go mod tidy
    # you may remove this if you don't need go generate
    - go generate ./...



git:
  # What should be used to sort tags when gathering the current and previous
  # tags if there are more than one tag in the same commit.
  #
  # Default: '-version:refname'
  tag_sort: -version:creatordate

  # What should be used to specify prerelease suffix while sorting tags when gathering
  # the current and previous tags if there are more than one tag in the same commit.
  #
  # Since: v1.17
  prerelease_suffix: "-"

  # Tags to be ignored by GoReleaser.
  # This means that GoReleaser will not pick up tags that match any of the
  # provided values as either previous or current tags.
  #
  # Templates: allowed.
  # Since: v1.21.
  ignore_tags:
    - nightly
    # - "{{.Env.IGNORE_TAG}}"

report_sizes: true

builds:
  - binary: openim-sdk-core
    id: openim-sdk-core
    main: ./cmd/main.go
    goos:
      - linux
    goarch:
      - amd64
      - arm64
    goarm:
      - "6"
      - "7"
  - id: openIM.wasm
    main: wasm/cmd/main.go  # 指定 wasm 主文件路径
    binary: openIM.wasm
    ldflags: "-s -w"
    goos:
      - js
    goarch:
      - wasm

archives:
  - format: tar.gz
    # this name template makes the OS and Arch compatible with the results of uname.
    name_template: >-
      {{ .ProjectName }}_
      {{- title .Os }}_
      {{- if eq .Arch "amd64" }}x86_64
      {{- else if eq .Arch "386" }}i386
      {{- else }}{{ .Arch }}{{ end }}
      {{- if .Arm }}v{{ .Arm }}{{ end }}
    # use zip for windows archives
    files:
      - LICENSE
      - README.md
      # a more complete example, check the globbing deep dive below
      - src: "*.md"
        dst: docs

        # Strip parent folders when adding files to the archive.
        strip_parent: true

        # File info.
        # Not all fields are supported by all formats available formats.
        #
        # Default: copied from the source file
        info:
          # Templates: allowed (since v1.14)
          owner: root

          # Templates: allowed (since v1.14)
          group: root

          # Must be in time.RFC3339Nano format.
          #
          # Templates: allowed (since v1.14)
          mtime: "{{ .CommitDate }}"

          # File mode.
          mode: 0644

    format_overrides:
    - goos: windows
      format: zip

changelog:
  sort: asc
  use: github
  filters:
    exclude:
      - "^test:"
      - "^chore"
      - "merge conflict"
      - Merge pull request
      - Merge remote-tracking branch
      - Merge branch
      - go mod tidy
  groups:
    - title: Dependency updates
      regexp: '^.*?(feat|fix)\(deps\)!?:.+$'
      order: 300
    - title: "New Features"
      regexp: '^.*?feat(\([[:word:]]+\))??!?:.+$'
      order: 100
    - title: "Security updates"
      regexp: '^.*?sec(\([[:word:]]+\))??!?:.+$'
      order: 150
    - title: "Bug fixes"
      regexp: '^.*?fix(\([[:word:]]+\))??!?:.+$'
      order: 200
    - title: "Documentation updates"
      regexp: ^.*?doc(\([[:word:]]+\))??!?:.+$
      order: 400
    - title: "Build process updates"
      regexp: ^.*?build(\([[:word:]]+\))??!?:.+$
      order: 400
    - title: Other work
      order: 9999


nfpms:
  - id: packages
    builds:
      - openim-sdk-core
      - openIM.wasm
    # Your app's vendor.
    vendor: OpenIMSDK
    homepage: https://github.com/openimsdk/openim-sdk-core
    maintainer: kubbot <https://github.com/kubbot>
    description: |-
      Auto sync github labels
      kubbot && openimbot
    license: Apache-2.0
    formats:
      - apk
      - deb
      - rpm
      - termux.deb # Since: v1.11
      - archlinux # Since: v1.13
    dependencies:
      - git
    recommends:
      - golang


# The lines beneath this are called `modelines`. See `:help modeline`
# Feel free to remove those if you don't want/use them.
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj

# Default: './dist'
dist: ./_output/dist

# .goreleaser.yaml
milestones:
  # You can have multiple milestone configs
  -
    # Repository for the milestone
    # Default is extracted from the origin remote URL
    repo:
      owner: user
      name: repo

    # Whether to close the milestone
    close: true

    # Fail release on errors, such as missing milestone.
    fail_on_error: false

    # Name of the milestone
    #
    # Default: '{{ .Tag }}'
    name_template: "Current Release"

# publishers:
#   - name: "fury.io"
#     ids:
#       - packages
#     dir: "{{ dir .ArtifactPath }}"
#     cmd: |
#       bash -c '
#       if [[ "{{ .Tag }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
#         curl -F package=@{{ .ArtifactName }} https://{{ .Env.FURY_TOKEN }}@push.fury.io/{{ .Env.USERNAME }}/
#       else
#         echo "Skipping deployment: Non-production release detected"
#       fi'

checksum:
  name_template: "{{ .ProjectName }}_checksums.txt"
  algorithm: sha256

release:
  prerelease: auto
