Prepare

Install goreleaser

1
2
3
echo 'deb [trusted=yes] https://repo.goreleaser.com/apt/ /' | sudo tee /etc/apt/sources.list.d/goreleaser.list
sudo apt update
sudo apt install goreleaser

Install nfpm

1
2
3
echo 'deb [trusted=yes] https://repo.goreleaser.com/apt/ /' | sudo tee /etc/apt/sources.list.d/goreleaser.list
sudo apt update
sudo apt install nfpm

Configuration

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# .goreleaser.yml file

nfpms:
  -
    id: a2fa
    package_name: a2fa
    file_name_template: "{{ .PackageName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
      
    homepage: https://github.com/csyezheng/a2fa
    vendor: csyezheng
    maintainer: Ye Zheng <csyezheng@gmail.com>
    description: A command line tool for generating and validating one-time password
    license: Apache 2.0

    formats:
      - deb
      - rpm
      
    release: 1
    section: utils
    priority: optional
    bindir: /usr/bin
    
    rpm:
      compression: lzma
1
2
3
4
5
6
7
8
publishers:
  - name: fury.io
    # by specifying `packages` id here goreleaser will only use this publisher
    # with artifacts identified by this id
    ids:
      - packages
    dir: "{{ dir .ArtifactPath }}"
    cmd: curl -F package=@{{ .ArtifactName }} https://{{ .Env.FURY_TOKEN }}@push.fury.io/<your_username>/ 

Building a source package

1
goreleaser build
1
goreleaser release --skip=publish

Test locally

1
dpkg -i dist/a2fa_0.16.6_linux_amd64.deb
1
# goreleaser release

Gemfury

Install the Gemfury CLI

Debian-based Linux

1
echo 'deb [trusted=yes] https://apt.fury.io/cli/ /' | sudo tee /etc/apt/sources.list.d/fury-cli.list
1
sudo apt-get update
1
sudo apt-get install fury-cli

Uploading packages

uploading packages to apt repository

1
curl -F package=@<file> https://TOKEN@apt.fury.io/csyezheng/

or using cli

1
2
fury push <file>
fury migrate <dir>

Install packages

1
echo 'deb [trusted=yes] https://apt.fury.io/csyezheng/ /' | sudo tee /etc/apt/sources.list.d/fury.list
1
sudo apt update
1
sudo apt install a2fa

GitAction

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# github action workflow file
---
name: Release
on:
  push:
    tags:
      - v*
jobs:
  goreleaser:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - name: Set up Go
        uses: actions/setup-go@v2
        with:
          go-version: 1.15
      - name: Run GoReleaser
        uses: goreleaser/goreleaser-action@v2
        with:
          version: v0.155.0
          args: release --rm-dist
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          FURY_TOKEN: ${{ secrets.FURYPUSHTOKEN }}

Packing using nFPM

1
vim Makefile
1
2
3
# Get the release dependencies we only install on linux
release_dep_linux:
	go install github.com/goreleaser/nfpm/v2/cmd/nfpm@latest
1
scripts/nfpm.yaml
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
name: a2fa
arch: amd64
platform: linux
version: 0.16.5
section: utils
priority: optional
provides:
- a2fa
maintainer: "Ye Zheng <csyezheng@gmail.com>"
description: |
  a2fa is a command line tool for generating and validating one-time password. Its purpose is to get rid of phones and be able to authenticate easily. It keeps synced with Google Authenticator, Microsoft Authenticator.
vendor: csyezheng
homepage: https://github.com/csyezheng/a2fa
license: Apache-2.0
contents:
  - src: ./a2fa
    dst: /usr/bin/a2fa
1
go build -o a2fa cmd/main.go
1
nfpm package -f scripts/nfpm.yaml -p deb -t pkgs/
1
paru -S debtap
1
sudo debtap -u
1
debtap a2fa_0.16.5_amd64.deb
1
sudo pacman -U a2fa-0.16.5-1-x86_64.pkg.tar.zst