Release all with goreleaser
2020-08-02 00:09:00 Author: www.hahwul.com(查看原文) 阅读量:123 收藏

The first thing I did while preparing for Dalfox 2.0 was package manager support such as brew, snap, etc. Although there is a current update command, we have not solved the side effects that result from it, so we have decided to support the package manager. I’m going to talk about the core part of this process, the goreleaser.

달폭스 2.0을 준비하면서 가장 먼저 진행한게 brew, snap등의 패키지 관리자 지원입니다. 현재 update 커맨드가 있긴하지만, 그로인해 발생하는 사이드 이펙트(go get 불가..)를 해결하지 못해서 결국은 패키지 관리자쪽을 지원하는 방향으로 잡았습니다. 이 과정에서 오늘 핵심이 되는 부분인 goreleaser에 대한 이야기를 하려고 합니다.

What is goreleaser?

Release Go projects as fast and easily as possible. GoReleaser is a release automation tool for Go projects. The goal is to simplify the build, release and publish steps while providing variant customization options for all steps.

GoReleaser is built for CI tools, you only need to download and execute it in your build script. Of course, you can also install it locally if you wish.

You can also customize your release process through a .goreleaser.yml file.

https://goreleaser.com/

My case?

저는 아래 3가지를 지원하려고 합니다. 핵심은 snap과 brew 이구요(리눅스와 맥, 윈도우는.. go install…) Support snapcraft brew docker

Install goreleaser

for my mac

$ brew install goreleaser/tap/goreleaser

for my build server(ubuntu)

$ sudo snap install --classic goreleaser
$ goreleaser --version

goreleaser version 0.140.1
commit: 47e88b9bcf6d9567ee95db4d3d1b2516734386e6
built at: 2020-07-22T12:14:56Z
built by: goreleaser

Setup in my project

Github token

export GITHUB_TOKEN="YOUR_GH_TOKEN"

Homevrew

Make tap repo

(mycase) https://github.com/hahwul/homebrew-dalfox

Snapcraft

First, we create a package from the SnapCraft website. 먼저, 웹에서 snapcraft 로그인 후 패키지를 만들어줘야합니다.

https://snapcraft.io/

and login at the terminal for push. 그리고 로컬에서 push할 수 있도록 계정 로그인을 해줍니다.

Dockerhub

snapcraft와 동일합니다.

.goreleaser.yml

https://github.com/hahwul/dalfox/blob/master/.goreleaser.yml

project_name: dalfox

before:
  hooks:
  - go mod download

builds:
  -
    main: .
    binary: dalfox
    goos:
      - windows
      - linux
      - darwin
      - freebsd
    goarch:
      - amd64
      - 386
    ignore:
      - goos: darwin
        goarch: 386
      - goos: darwin
        goarch: arm
      - goos: darwin
        goarch: arm64
      - goos: windows
        goarch: 386
      - goos: windows
        goarch: arm
      - goos: windows
        goarch: arm64
      - goos: freebsd
        goarch: arm

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

changelog:
  sort: desc
  filters:
    exclude:
    - '^MERGE'
    - "{{ .Tag }}"

release:
  github:
    owner: hahwul
    name: dalfox

brews:
  -
    name: dalfox
    tap:
      owner: hahwul
      name: homebrew-dalfox
    url_template: "https://github.com/hahwul/dalfox/releases/download/{{ .Tag }}/{{ .ArtifactName }}"
    commit_author:
      name: hahwul
      email: [email protected]
    folder: Formula
    homepage: "https://www.hahwul.com"
    description: "DalFox(Finder Of XSS) / Parameter Analysis and XSS Scanning tool based on golang"
    test: |
      system "#{bin}/dalfox version"
    install: |
      bin.install "dalfox"
snapcrafts:
  -
    name: dalfox
    # Remember you need to `snapcraft login` first.
    publish: true
    summary: DalFox(Finder Of XSS) / Parameter Analysis and XSS Scanning tool based on golang
    description: Just, XSS Scanning and Parameter Analysis tool. I previously developed XSpear, a ruby-based XSS tool, and this time, a full change occurred during the process of porting with golang!!! and created it as a new project. The basic concept is to analyze parameters, find XSS, and verify them based on DOM Parser. I talk about naming. Dal(달) is the Korean pronunciation of moon and fox was made into Fox(Find Of XSS).
    grade: stable
    confinement: strict
    license: MIT

The rules for writing… Please refer to the https://goreleaser.com/customization/docker/ 작성 규칙은 .. https://goreleaser.com/customization/docker/ 문서들을 참고해주세요.

Release

Let’s test it without deployment with the –snapshot option before we deploy it. 우선 배포하기 전에 –snapshot 옵션으로 배포없이 테스트해봅시다.

$ goreleaser --snapshot --rm-dist

   • releasing...
   • loading config file       file=.goreleaser.yml
   • running before hooks
      • running go mod download
      ...

1414

If you don’t have a problem, try distributing it right away. 문제가 없다면, 바로 배포해보세요.

1415

Because Brew did not sending PR, it connects the storage with tap and uses it. If you send the content created in Formulae as PR to homebrew-core, you can register it as a default package.

brew는 PR을 던진게 아니기 때문에 tap으로 저장소를 연결하여 사용합니다. 만약 Formulae에 작성된 내용을 homebrew-core에 PR로 보낸다면 기본 패키지로 등록할 수 있습니다. (다만 버전이 빠르게 올라오지는 못합니다. 저쪽에서도 검토하고 merge 해야해서)

Docker had a privilege issue and pushed separately without using the gooreaser. 도커는 권한 문제가 있어서 goreleaser를 사용하지 않고 별도로 푸시했습니다 :D


文章来源: https://www.hahwul.com/2020/08/01/release-all-with-goreleaser/
如有侵权请联系:admin#unsafe.sh