Skip to content

Commit

Permalink
Use goreleaser
Browse files Browse the repository at this point in the history
  • Loading branch information
dex4er committed May 15, 2023
1 parent d07d474 commit 507dfb2
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 128 deletions.
48 changes: 13 additions & 35 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,20 @@ on:
types: [checks_requested]
push: {}
jobs:
release:
name: Build release binaries
build:
runs-on: ubuntu-latest
strategy:
matrix:
os: [ 'darwin', 'windows', 'freebsd', 'netbsd', 'openbsd' ]
arch: [ 'amd64' ]
go-version: [ '1.15', '1.16', '1.17' ]
name: Build binaries
steps:
- name: Checkout the repository
uses: actions/checkout@master
- name: Setup Golang
uses: actions/setup-go@v1
- uses: actions/checkout@v3
with:
go-version: ${{ matrix.go-version }}
- run: go build -o release/powerline-go-$GOOS-$GOARCH
env:
CGO_ENABLED: 0
GOOS: ${{ matrix.os }}
GOARCH: ${{ matrix.arch }}
release-linux:
name: Build release binaries for linux
runs-on: ubuntu-latest
strategy:
matrix:
arch: [ 'amd64', 'arm64', 'arm' ]
go-version: [ '1.15', '1.16', '1.17' ]
steps:
- name: Checkout the repository
uses: actions/checkout@master
- name: Setup Golang
uses: actions/setup-go@v1
fetch-depth: 0
- run: git fetch --force --tags
- uses: actions/setup-go@v4
with:
go-version: "1.20"
- uses: goreleaser/goreleaser-action@v4
with:
go-version: ${{ matrix.go-version }}
- run: go build -o release/powerline-go-$GOOS-$GOARCH
env:
CGO_ENABLED: 0
GOOS: linux
GOARCH: ${{ matrix.arch }}
distribution: goreleaser
version: latest
args: build --clean --snapshot
- run: dist/powerline-go_linux_amd64_v1/powerline-go --help
104 changes: 11 additions & 93 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,103 +3,21 @@ on:
release:
types: [created]
jobs:
release-linux:
name: Build release binaries for linux
runs-on: ubuntu-latest
strategy:
matrix:
arch: [ 'amd64', 'arm64', 'arm' ]
steps:
- name: Checkout the repository
uses: actions/checkout@master
- name: Setup Golang
uses: actions/setup-go@v1
with:
go-version: '1.15'
- run: go build -o release/powerline-go-$GOOS-$GOARCH
env:
CGO_ENABLED: 0
GOOS: linux
GOARCH: ${{ matrix.arch }}
- name: Upload the artifacts
uses: skx/github-action-publish-binaries@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: 'release/powerline-go-*'
release-macos:
name: Build release binaries for macOS
runs-on: ubuntu-latest
strategy:
matrix:
arch: [ 'amd64' ]
# arm64 for darwin is disabled as it's not currently supported by the go
# compiler for our use case
steps:
- name: Checkout the repository
uses: actions/checkout@master
- name: Setup Golang
uses: actions/setup-go@v1
with:
go-version: '1.15'
- run: go build -o release/powerline-go-$GOOS-$GOARCH
env:
CGO_ENABLED: 0
GOOS: darwin
GOARCH: ${{ matrix.arch }}
- name: Upload the artifacts
uses: skx/github-action-publish-binaries@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: 'release/powerline-go-*'
release-windows:
name: Build release binaries for windows
release:
runs-on: ubuntu-latest
strategy:
matrix:
arch: [ 'amd64' ]
# arm64 for windows is disabled as it's not currently supported by the
# go compiler for our use case
name: Release binaries
steps:
- name: Checkout the repository
uses: actions/checkout@master
- name: Setup Golang
uses: actions/setup-go@v1
- uses: actions/checkout@v3
with:
go-version: '1.15'
- run: go build -o release/powerline-go-$GOOS-$GOARCH
env:
CGO_ENABLED: 0
GOOS: windows
GOARCH: ${{ matrix.arch }}
- name: Upload the artifacts
uses: skx/github-action-publish-binaries@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- run: git fetch --force --tags
- uses: actions/setup-go@v4
with:
args: 'release/powerline-go-*'
release-bsd:
name: Build release binaries for BSD
runs-on: ubuntu-latest
strategy:
matrix:
os: [ 'freebsd', 'netbsd', 'openbsd' ]
steps:
- name: Checkout the repository
uses: actions/checkout@master
- name: Setup Golang
uses: actions/setup-go@v1
go-version: "1.20"
- uses: goreleaser/goreleaser-action@v4
with:
go-version: '1.15'
- run: go build -o release/powerline-go-$GOOS-$GOARCH
env:
CGO_ENABLED: 0
GOOS: ${{ matrix.os }}
GOARCH: amd64
- name: Upload the artifacts
uses: skx/github-action-publish-binaries@master
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: 'release/powerline-go-*'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*.so
*.dylib
powerline-go
/dist/

# Test binary, build with `go test -c`
*.test
Expand Down
37 changes: 37 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
project_name: powerline-go
before:
hooks:
- go mod download
builds:
- binary: powerline-go
env:
- CGO_ENABLED=0
goarch:
- amd64
- arm
- arm64
- "386"
goos:
- darwin
- linux
- windows
- freebsd
- netbsd
- openbsd
ignore:
- goos: darwin
goarch: "386"
- goos: openbsd
goarch: arm
flags:
- -trimpath
ldflags:
- -s
- -w

archives:
- name_template: "{{ .ProjectName }}-{{ .Os }}-{{ .Arch }}"
format: binary

checksum:
name_template: checksums.txt

0 comments on commit 507dfb2

Please sign in to comment.