Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new: use goreleaser for publishing #215

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 46 additions & 12 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ on:
push:
tags:
- 'v*.*.*'
pull_request:
branches: [master, release/*]

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

env:
CARGO: cargo
Expand All @@ -26,68 +28,70 @@ jobs:
- windows-x86
include:
- name: linux-x86-gnu
os: ubuntu-latest
runner: ubuntu-latest
family: linux
arch: x86_64
target: x86_64-unknown-linux-gnu
archiver: tar.gz
asset: hl-linux-x86_64-gnu.tar.gz
skip: true
- name: linux-x86-musl
os: ubuntu-latest
runner: ubuntu-latest
family: linux
arch: x86_64
target: x86_64-unknown-linux-musl
archiver: tar.gz
asset: hl-linux-x86_64-musl.tar.gz
cross: true
- name: linux-arm-gnu
os: ubuntu-latest
runner: ubuntu-latest
family: linux
arch: aarch64
target: aarch64-unknown-linux-gnu
archiver: tar.gz
asset: hl-linux-arm64-gnu.tar.gz
cross: true
skip: true
- name: linux-arm-musl
os: ubuntu-latest
runner: ubuntu-latest
family: linux
arch: aarch64
target: aarch64-unknown-linux-musl
archiver: tar.gz
asset: hl-linux-arm64-musl.tar.gz
cross: true
- name: macos-x86
os: macos-latest
runner: macos-latest
family: macos
arch: x86_64
target: x86_64-apple-darwin
archiver: tar.gz
asset: hl-macos-x86_64.tar.gz
- name: macos-arm
os: macos-latest
runner: macos-latest
family: macos
arch: aarch64
target: aarch64-apple-darwin
archiver: tar.gz
asset: hl-macos-arm64.tar.gz
- name: macos-universal
os: macos-latest
runner: macos-latest
family: macos
arch: '{aarch64,x86_64}'
target: '{aarch64,x86_64}-apple-darwin'
archiver: tar.gz
asset: hl-macos.tar.gz
universal: true
- name: windows-x86
os: windows-latest
runner: windows-latest
family: windows
arch: x86_64
target: x86_64-pc-windows-msvc
archiver: 7z
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 +132,39 @@ jobs:
if: matrix.archiver == 'tar.gz' && matrix.universal == true
run: tar -C ./target -cz -f ${{ matrix.asset }} hl

- name: Store artifact
if: matrix.skip != true
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 --snapshot
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} \;
51 changes: 51 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
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
repository:
owner: pamburus
name: homebrew-tap
branch: main
pull_request:
enabled: true
draft: true
url_template: "https://github.com/pamburus/hl/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")
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() {}
Loading