Skip to content

Commit

Permalink
Update goreleaser, add release GitHub Action
Browse files Browse the repository at this point in the history
  • Loading branch information
mszostok committed Feb 12, 2022
1 parent 0e709b4 commit dcfa851
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 41 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Release

on:
push:
tags:
- '*'

jobs:
goreleaser:
name: Run GoReleaser
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
- name: Install upx 3.96
run: |
wget https://github.com/upx/upx/releases/download/v3.96/upx-3.96-amd64_linux.tar.xz
tar -xf upx-3.96-amd64_linux.tar.xz
mv ./upx-3.96-amd64_linux/upx /usr/local/bin/upx
upx -V
- name: Docker Login
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
distribution: goreleaser
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ scripts/
codeowners-validator
dist/
tmp/
coverage.txt
bin/
coverage.txt
95 changes: 55 additions & 40 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,64 @@
builds:
- env:
- CGO_ENABLED=0
hooks:
# Install upx first, https://github.com/upx/upx/releases
post: ./hack/compress.sh
goos:
- linux
- darwin
- windows
goarch:
- amd64
- 386
ldflags:
- -s -w -X github.com/mszostok/codeowners-validator/pkg/version.version={{.Version}} -X github.com/mszostok/codeowners-validator/pkg/version.commit={{.ShortCommit}} -X github.com/mszostok/codeowners-validator/pkg/version.buildDate={{.Date}}
# List of combinations of GOOS + GOARCH + GOARM to ignore.
# Default is empty.
ignore:
- goos: darwin
goarch: 386
archive:
replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
format_overrides:
- goos: windows
format: zip
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
- id: codeowners-validator
env:
- CGO_ENABLED=0
goos:
- linux
- darwin
- windows
goarch:
- "386"
- amd64
- arm64
ldflags:
- -s -w -X github.com/mszostok/codeowners-validator/pkg/version.version={{.Version}} -X github.com/mszostok/codeowners-validator/pkg/version.commit={{.ShortCommit}} -X github.com/mszostok/codeowners-validator/pkg/version.buildDate={{.Date}}
# List of combinations of GOOS + GOARCH + GOARM to ignore.
# Default is empty.
ignore:
- goos: windows # due to upx error: CantPackException: can't pack new-exe
goarch: arm64
hooks:
# Install upx first, https://github.com/upx/upx/releases
post: upx -9 "{{ .Path }}"

archives:
- format: binary
name_template: "{{ .Binary }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}"

dockers:
- dockerfile: Dockerfile
binaries:
ids:
- codeowners-validator
image_templates:
- "ghcr.io/mszostok/codeowners-validator:stable"
- "ghcr.io/mszostok/codeowners-validator:{{ .Tag }}"
- "ghcr.io/mszostok/codeowners-validator:v{{ .Major }}.{{ .Minor }}"
- "ghcr.io/mszostok/codeowners-validator:v{{ .Major }}"
- "mszostok/codeowners-validator:latest"
- "mszostok/codeowners-validator:{{ .Tag }}"
- "mszostok/codeowners-validator:v{{ .Major }}.{{ .Minor }}"

checksum:
name_template: 'checksums.txt'

snapshot:
name_template: "{{ .Tag }}-next"

changelog:
use: github
filters:
exclude:
- '^docs:'
- '^test:'

dist: bin

release:
# If set to true, will not auto-publish the release.
# Default is false.
draft: true
# Repo in which the release will be created.
# Default is extracted from the origin remote URL or empty if its private hosted.
github:
owner: mszostok
name: codeowners-validator

0 comments on commit dcfa851

Please sign in to comment.