Skip to content

Commit

Permalink
Releasing with goreleaser (#12)
Browse files Browse the repository at this point in the history
Releasing with `goreleaser`
  • Loading branch information
zdmytriv authored Apr 9, 2023
1 parent b03cf7c commit 9da6fbe
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 53 deletions.
53 changes: 0 additions & 53 deletions .github/workflows/go.yml

This file was deleted.

57 changes: 57 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: release

on:
workflow_dispatch:

release:
types:
- published

pull_request:
types:
- opened
- synchronize
- reopened

permissions:
contents: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '1.20'

- name: Test Snapshot Release
if: github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && github.ref_name != 'master')
uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
version: latest
args: release --clean --snapshot

- name: Upload Test Release Assets
if: github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && github.ref_name != 'master')
uses: actions/upload-artifact@v3
with:
name: slack-notifier
path: dist/*
retention-days: 3

- name: Public Release
if: (github.event_name == 'release' && github.event.action == 'published') || (github.event_name == 'workflow_dispatch' && github.ref_name == 'master')
uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ slack-notifier
*.out

build-harness/

dist/
35 changes: 35 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
before:
hooks:
- go mod download

builds:
- env:
- CGO_ENABLED=0
- GO111MODULE=on
goos:
- linux
- windows
- darwin
- freebsd
- openbsd
- netbsd
goarch:
- amd64
- '386'
- arm
- arm64
- s390x

source:
enabled: true
name_template: 'sources'

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

checksum:
name_template: 'checksums.txt'

snapshot:
name_template: "{{ incpatch .Version }}"

0 comments on commit 9da6fbe

Please sign in to comment.