Skip to content

Commit

Permalink
new: use goreleaser for publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
pamburus committed Apr 28, 2024
1 parent 17dd91f commit 76231ac
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 6 deletions.
35 changes: 32 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ on:
- 'v*.*.*'

jobs:
publish:
name: Publish for ${{ matrix.name }}
build:
name: Build for ${{ matrix.name }}
runs-on: ${{ matrix.os }}

env:
Expand Down Expand Up @@ -87,7 +87,7 @@ jobs:
asset: hl-windows.zip

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
Expand Down Expand Up @@ -128,9 +128,38 @@ jobs:
if: matrix.archiver == 'tar.gz' && matrix.universal == true
run: tar -C ./target -cz -f ${{ matrix.asset }} hl

- name: Store artifact
uses: actions/upload-artifact@v4
with:
name: hl-${{ matrix.arch }}-${{ matrix.family }}
path: target/${{ matrix.target }}/release/hl${{ matrix.family == 'windows' && '.exe' || '' }}
retention-days: 1

- name: Upload binaries to release
if: startsWith(github.ref, 'refs/tags/v')
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ matrix.asset }}
tag: ${{ github.ref }}

publish:
name: Publish
needs: [build]
runs-on: ubuntu-22.04
steps:
- name: Checkout Git repo
uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: artifacts
- name: Set up Go
uses: actions/setup-go@v5
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
args: release --clean --skip=validate
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21 changes: 21 additions & 0 deletions .goreleaser-hook.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

go_arch=$1
go_os=$2
project_name=$3

# Make Go -> Rust arch/os mapping
case $go_arch in
amd64) rust_arch='x86_64' ;;
arm64) rust_arch='aarch64' ;;
*) echo "unknown arch: $go_arch" && exit 1 ;;
esac
case $go_os in
linux) rust_os='linux' ;;
darwin) rust_os='macos' ;;
windows) rust_os='windows' ;;
*) echo "unknown os: $go_os" && exit 1 ;;
esac

# Find artifacts and uncompress in the corresponding directory
find artifacts -type f -name "${project_name}-${rust_arch}-${rust_os}" -exec mv {} dist/${project_name}_${go_os}_${go_arch} \;
54 changes: 54 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
project_name: hl
builds:
- main: build/goreleaser/stub.go
goos:
- linux
- darwin
- windows
goarch:
- amd64
- arm64
binary: hl
ignore:
- goos: windows
goarch: arm64
hooks:
post:
- ./.goreleaser-hook.sh {{ .Arch }} {{ .Os }} {{ .ProjectName }}
checksum:
name_template: "checksums.txt"
changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
brews:
- name: hl
tap:
owner: pamburus
name: tap
url_template: "https://github.com/pamburus/tap/releases/download/{{ .Tag }}/{{ .ArtifactName }}"
commit_author:
name: Pavel Ivanov
email: [email protected]
commit_msg_template: "Brew formula update for {{ .ProjectName }} version {{ .Tag }}"
directory: Formula
homepage: "https://github.com/pamburus/hl"
description: "Log viewer for JSON and logfmt logs"
license: "MIT"
skip_upload: auto
custom_block: |
head "https://github.com/pamburus/hl.git"
test: |
system "#{bin}/hl --version"
install: |
system "cargo", "install", *std_cargo_args
generate_completions_from_executable(bin/"hl", "--shell-completions")
repository:
owner: pamburus
name: homebrew-tap
branch: main
pull_request:
enabled: true
draft: true
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ members = [".", "crate/encstr"]
[workspace.package]
repository = "https://github.com/pamburus/hl"
authors = ["Pavel Ivanov <[email protected]>"]
version = "0.28.0"
version = "0.28.1-beta.1"
edition = "2021"
license = "MIT"

Expand Down
3 changes: 3 additions & 0 deletions build/goreleaser/stub.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package main

func main() {}

0 comments on commit 76231ac

Please sign in to comment.