zoukankan      html  css  js  c++  java
  • s3-sftp-proxy goreleaser rpm &&deb 包制作

    上次写过简单的s3-sftp-proxy基于容器构建以及使用goreleaser构建跨平台二进制文件的,下边演示下关于
    rpm&&deb 包的制作,我们只需要简单的配置就可以生成方便安装的软件包

    项目代码

    https://github.com/rongfengliang/s3-sftp-proxy-docker

    环境准备

    • goreleaser 安装
      这个官方提供了不同平台的安装包,选择对应的就可以了
    • 配置项目.goreleaser.yml 文件
      内容如下:
     
    # This is an example goreleaser.yaml file with some sane defaults.
    # Make sure to check the documentation at http://goreleaser.com
    project_name: s3-sftp-proxy
    before:
      hooks:
        # you may remove this if you don't use vgo
        - sh goproxy.sh
        - go mod download
    builds:
    - env:
      - CGO_ENABLED=0
      goos:
      - freebsd
      - windows
      - darwin
      - linux
      goarch:
      - amd64
      - arm
      - arm64
    archive:
      replacements:
        darwin: Darwin
        linux: Linux
        windows: Windows
        386: i386
        amd64: x86_64
    checksum:
      name_template: 'checksums.txt'
    changelog:
      sort: asc
      filters:
        exclude:
        - '^docs:'
        - '^test:'
    nfpms:
      - 
        id: s3-sftp-proxy
        builds:
        - s3-sftp-proxy
        name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
        # Replacements for GOOS and GOARCH in the package name.
        # Keys should be valid GOOSs or GOARCHs.
        # Values are the respective replacements.
        # Default is empty.
        replacements:
          amd64: 64-bit
          386: 32-bit
          darwin: macOS
          linux: linux
        vendor: dalongrong.
        homepage: https://github.com/rongfengliang/
        # Your app's maintainer (probably you).
        # Default is empty.
        maintainer: 1141591465@qq.com
        # Your app's description.
        # Default is empty.
        description: s3-sftp-proxy
        # Your app's license.
        # Default is empty.
        license: Apache 2.0
        # Formats to be generated.
        formats:
          - deb
          - rpm
        # Override default /usr/local/bin destination for binaries
        bindir: /usr/bin
        empty_folders:
        - /var/log/s3-sftp-proxy
        config_files:
          "s3-sftp-proxy.example.toml": "/etc/s3-sftp-proxy.conf"
        # Scripts to execute during the installation of the package.
        # Keys are the possible targets during the installation process
        # Values are the paths to the scripts which will be executed
        scripts:
          postinstall: "scripts/postinstall.sh"
        # Some attributes can be overrided per package format.
        overrides:
          deb:
            empty_folders:
            - /var/log/bar
          rpm:
            replacements:
              amd64: x86_64
            name_template: "{{ .ProjectName }}-{{ .Version }}-{{ .Arch }}"
            config_files:
              "s3-sftp-proxy.example.toml": "/etc/s3-sftp-proxy.toml"
    • goreleaser版本简单说明
      对于rpm以及deb 包的生成,我们需要比较新的goreleaser版本,最好是下载官方最新的版本
    • 配置说明
      我们可以配置安装的依赖,软件安装以及卸载的自定义脚本,同时对于配置文件我们也可以通过配置本地与安装之后的目录映射
      可以参考上边yaml 文件中nfpms 的配置映射

    构建效果

    • 构建命令
     
    goreleaser release --rm-dist
    • 效果
    goreleaser release --rm-dist
       releasing using goreleaser 0.115.0...
       loading config file file=.goreleaser.yml
       RUNNING BEFORE HOOKS
          running sh goproxy.sh
          running go mod download
       LOADING ENVIRONMENT VARIABLES
       GETTING AND VALIDATING GIT STATE
          releasing v2.2, commit 396c3cd6c88030ac9b98262c51d48516442b7c58
       PARSING TAG      
       SETTING DEFAULTS 
          LOADING ENVIRONMENT VARIABLES
          SNAPSHOTING      
          GITHUB/GITLAB RELEASES
          PROJECT NAME     
          BUILDING BINARIES
          ARCHIVES         
                DEPRECATED: `archive` should not be used anymore, check https://goreleaser.com/deprecations#archive for more info.
          LINUX PACKAGES WITH NFPM
          SNAPCRAFT PACKAGES
          CALCULATING CHECKSUMS
          SIGNING ARTIFACTS
          DOCKER IMAGES    
          ARTIFACTORY      
          S3               
          BLOB             
          HOMEBREW TAP FORMULA
             optimistically guessing `brew[0].installs`, double check
          SCOOP MANIFEST   
       SNAPSHOTING      
          pipe skipped error=not a snapshot
       CHECKING ./DIST  
          --rm-dist is set, cleaning it up
       WRITING EFFECTIVE CONFIG FILE
          writing config=dist/config.yaml
       GENERATING CHANGELOG
          writing changelog=dist/CHANGELOG.md
       BUILDING BINARIES
          building binary=dist/s3-sftp-proxy_linux_arm64/s3-sftp-proxy
          building binary=dist/s3-sftp-proxy_windows_amd64/s3-sftp-proxy.exe
          building binary=dist/s3-sftp-proxy_freebsd_amd64/s3-sftp-proxy
          building binary=dist/s3-sftp-proxy_linux_amd64/s3-sftp-proxy
          building binary=dist/s3-sftp-proxy_darwin_amd64/s3-sftp-proxy
          building binary=dist/s3-sftp-proxy_freebsd_arm_6/s3-sftp-proxy
          building binary=dist/s3-sftp-proxy_linux_arm_6/s3-sftp-proxy
       ARCHIVES         
          creating archive=dist/s3-sftp-proxy_2.2_Linux_arm64.tar.gz
          creating archive=dist/s3-sftp-proxy_2.2_Windows_x86_64.tar.gz
          creating archive=dist/s3-sftp-proxy_2.2_Linux_armv6.tar.gz
          creating archive=dist/s3-sftp-proxy_2.2_Linux_x86_64.tar.gz
          creating archive=dist/s3-sftp-proxy_2.2_Darwin_x86_64.tar.gz
          creating archive=dist/s3-sftp-proxy_2.2_freebsd_armv6.tar.gz
          creating archive=dist/s3-sftp-proxy_2.2_freebsd_x86_64.tar.gz
       LINUX PACKAGES WITH NFPM
          creating arch=armhf file=dist/s3-sftp-proxy-2.2-arm.rpm package=s3-sftp-proxy-2.2-arm.rpm
          creating arch=amd64 file=dist/s3-sftp-proxy-2.2-x86_64.rpm package=s3-sftp-proxy-2.2-x86_64.rpm
          creating arch=amd64 file=dist/s3-sftp-proxy_2.2_linux_64-bit.deb package=s3-sftp-proxy_2.2_linux_64-bit.deb
          creating arch=arm64 file=dist/s3-sftp-proxy-2.2-arm64.rpm package=s3-sftp-proxy-2.2-arm64.rpm
          creating arch=armhf file=dist/s3-sftp-proxy_2.2_linux_arm.deb package=s3-sftp-proxy_2.2_linux_arm.deb
          creating arch=arm64 file=dist/s3-sftp-proxy_2.2_linux_arm64.deb package=s3-sftp-proxy_2.2_linux_arm64.deb
       SNAPCRAFT PACKAGES
          pipe skipped error=no summary nor description were provided
       CALCULATING CHECKSUMS
          checksumming file=s3-sftp-proxy-2.2-x86_64.rpm
          checksumming file=s3-sftp-proxy_2.2_Linux_x86_64.tar.gz
          checksumming file=s3-sftp-proxy_2.2_linux_64-bit.deb
          checksumming file=s3-sftp-proxy_2.2_linux_arm64.deb
          checksumming file=s3-sftp-proxy_2.2_Darwin_x86_64.tar.gz
          checksumming file=s3-sftp-proxy_2.2_freebsd_armv6.tar.gz
          checksumming file=s3-sftp-proxy_2.2_linux_arm.deb
          checksumming file=s3-sftp-proxy_2.2_Linux_arm64.tar.gz
          checksumming file=s3-sftp-proxy_2.2_freebsd_x86_64.tar.gz
          checksumming file=s3-sftp-proxy_2.2_Linux_armv6.tar.gz
          checksumming file=s3-sftp-proxy-2.2-arm.rpm
          checksumming file=s3-sftp-proxy_2.2_Windows_x86_64.tar.gz
          checksumming file=s3-sftp-proxy-2.2-arm64.rpm
       SIGNING ARTIFACTS
          pipe skipped error=artifact signing is disabled
       DOCKER IMAGES    
          pipe skipped error=docker section is not configured
       PUBLISHING       
          S3               
             pipe skipped error=s3 section is not configured
          BLOB             
             pipe skipped error=Blob section is not configured
          HTTP PUT         
             pipe skipped error=put section is not configured
          ARTIFACTORY      
             pipe skipped error=artifactory section is not configured
          DOCKER IMAGES    
          SNAPCRAFT PACKAGES
          GITHUB/GITLAB RELEASES
             creating or updating release repo=rongfengliang/s3-sftp-proxy-docker tag=v2.2
             release updated url=https://github.com/rongfengliang/s3-sftp-proxy-docker/releases/tag/v2.2
             uploading to release file=dist/checksums.txt name=checksums.txt
             uploading to release file=dist/s3-sftp-proxy_2.2_Linux_arm64.tar.gz name=s3-sftp-proxy_2.2_Linux_arm64.tar.gz
             uploading to release file=dist/s3-sftp-proxy_2.2_freebsd_armv6.tar.gz name=s3-sftp-proxy_2.2_freebsd_armv6.tar.gz
             uploading to release file=dist/s3-sftp-proxy_2.2_Windows_x86_64.tar.gz name=s3-sftp-proxy_2.2_Windows_x86_64.tar.gz
             failed to upload artifact, will retry artifact=s3-sftp-proxy_2.2_freebsd_armv6.tar.gz try=0
             failed to upload artifact, will retry artifact=s3-sftp-proxy_2.2_Windows_x86_64.tar.gz try=0
             uploading to release file=dist/s3-sftp-proxy_2.2_freebsd_armv6.tar.gz name=s3-sftp-proxy_2.2_freebsd_armv6.tar.gz
             uploading to release file=dist/s3-sftp-proxy_2.2_Windows_x86_64.tar.gz name=s3-sftp-proxy_2.2_Windows_x86_64.tar.gz
             failed to upload artifact, will retry artifact=checksums.txt try=0
             uploading to release file=dist/checksums.txt name=checksums.txt
             failed to upload artifact, will retry artifact=s3-sftp-proxy_2.2_Linux_arm64.tar.gz try=0
             uploading to release file=dist/s3-sftp-proxy_2.2_Linux_arm64.tar.gz name=s3-sftp-proxy_2.2_Linux_arm64.tar.gz
             failed to upload artifact, will retry artifact=s3-sftp-proxy_2.2_freebsd_armv6.tar.gz try=1
             uploading to release file=dist/s3-sftp-proxy_2.2_freebsd_armv6.tar.gz name=s3-sftp-proxy_2.2_freebsd_armv6.tar.gz
             failed to upload artifact, will retry artifact=s3-sftp-proxy_2.2_Windows_x86_64.tar.gz try=1
             uploading to release file=dist/s3-sftp-proxy_2.2_Windows_x86_64.tar.gz name=s3-sftp-proxy_2.2_Windows_x86_64.tar.gz
             failed to upload artifact, will retry artifact=s3-sftp-proxy_2.2_Linux_arm64.tar.gz try=1
             uploading to release file=dist/s3-sftp-proxy_2.2_Linux_arm64.tar.gz name=s3-sftp-proxy_2.2_Linux_arm64.tar.gz
             failed to upload artifact, will retry artifact=checksums.txt try=1
             uploading to release file=dist/checksums.txt name=checksums.txt
             failed to upload artifact, will retry artifact=s3-sftp-proxy_2.2_freebsd_armv6.tar.gz try=2
             uploading to release file=dist/s3-sftp-proxy_2.2_freebsd_armv6.tar.gz name=s3-sftp-proxy_2.2_freebsd_armv6.tar.gz
             failed to upload artifact, will retry artifact=s3-sftp-proxy_2.2_Windows_x86_64.tar.gz try=2
             uploading to release file=dist/s3-sftp-proxy_2.2_Windows_x86_64.tar.gz name=s3-sftp-proxy_2.2_Windows_x86_64.tar.gz
             failed to upload artifact, will retry artifact=s3-sftp-proxy_2.2_Linux_arm64.tar.gz try=2
             uploading to release file=dist/s3-sftp-proxy_2.2_Linux_arm64.tar.gz name=s3-sftp-proxy_2.2_Linux_arm64.tar.gz
             failed to upload artifact, will retry artifact=checksums.txt try=2
             uploading to release file=dist/checksums.txt name=checksums.txt
             failed to upload artifact, will retry artifact=s3-sftp-proxy_2.2_freebsd_armv6.tar.gz try=3
             uploading to release file=dist/s3-sftp-proxy_2.2_freebsd_armv6.tar.gz name=s3-sftp-proxy_2.2_freebsd_armv6.tar.gz
             failed to upload artifact, will retry artifact=s3-sftp-proxy_2.2_Linux_arm64.tar.gz try=3
             uploading to release file=dist/s3-sftp-proxy_2.2_Linux_arm64.tar.gz name=s3-sftp-proxy_2.2_Linux_arm64.tar.gz
             failed to upload artifact, will retry artifact=checksums.txt try=3
             uploading to release file=dist/checksums.txt name=checksums.txt
             failed to upload artifact, will retry artifact=s3-sftp-proxy_2.2_Windows_x86_64.tar.gz try=3
             uploading to release file=dist/s3-sftp-proxy_2.2_Windows_x86_64.tar.gz name=s3-sftp-proxy_2.2_Windows_x86_64.tar.gz
             failed to upload artifact, will retry artifact=s3-sftp-proxy_2.2_Linux_arm64.tar.gz try=4
             failed to upload artifact, will retry artifact=s3-sftp-proxy_2.2_freebsd_armv6.tar.gz try=4
             uploading to release file=dist/s3-sftp-proxy_2.2_Linux_arm64.tar.gz name=s3-sftp-proxy_2.2_Linux_arm64.tar.gz
             failed to upload artifact, will retry artifact=checksums.txt try=4
             uploading to release file=dist/s3-sftp-proxy_2.2_freebsd_armv6.tar.gz name=s3-sftp-proxy_2.2_freebsd_armv6.tar.gz
             uploading to release file=dist/checksums.txt name=checksums.txt
             failed to upload artifact, will retry artifact=s3-sftp-proxy_2.2_Windows_x86_64.tar.gz try=4
             failed to upload artifact, will retry artifact=s3-sftp-proxy_2.2_Linux_arm64.tar.gz try=5
             uploading to release file=dist/s3-sftp-proxy_2.2_Windows_x86_64.tar.gz name=s3-sftp-proxy_2.2_Windows_x86_64.tar.gz
             uploading to release file=dist/s3-sftp-proxy_2.2_Linux_arm64.tar.gz name=s3-sftp-proxy_2.2_Linux_arm64.tar.gz
             failed to upload artifact, will retry artifact=checksums.txt try=5
             failed to upload artifact, will retry artifact=s3-sftp-proxy_2.2_freebsd_armv6.tar.gz try=5
             uploading to release file=dist/checksums.txt name=checksums.txt
             uploading to release file=dist/s3-sftp-proxy_2.2_freebsd_armv6.tar.gz name=s3-sftp-proxy_2.2_freebsd_armv6.tar.gz
             failed to upload artifact, will retry artifact=s3-sftp-proxy_2.2_Windows_x86_64.tar.gz t

    参考资料

    https://github.com/rongfengliang/s3-sftp-proxy-docker
    https://github.com/goreleaser/goreleaser/releases
    https://goreleaser.com/customization

  • 相关阅读:
    .NET CORE技术路线图
    .Net Core之Configuration
    30+程序员
    Source Insight无限试用期修改方法
    WALT(Window Assisted Load Tracking)学习
    使用Mac的Remote Desktop Manager连接ubuntu16.04 & Win10的远程桌面
    进程调度函数scheduler_tick()的触发原理:周期PERIODIC定时器
    Linux、Android系统调用从上层到底层的调用路径浅析
    Ftrace的部分使用方法
    CPU efficiency测量标准:DMIPS
  • 原文地址:https://www.cnblogs.com/rongfengliang/p/11382281.html
Copyright © 2011-2022 走看看