Skip to content

chore: update the release process #3

chore: update the release process

chore: update the release process #3

Workflow file for this run

name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
permissions:
contents: write
jobs:
build:
name: Build and Release
runs-on: ubuntu-latest
strategy:
matrix:
include:
- os: linux
arch: amd64
goos: linux
goarch: amd64
- os: linux
arch: arm64
goos: linux
goarch: arm64
- os: darwin
arch: amd64
goos: darwin
goarch: amd64
- os: darwin
arch: arm64
goos: darwin
goarch: arm64
- os: windows
arch: amd64
goos: windows
goarch: amd64
- os: windows
arch: arm64
goos: windows
goarch: arm64
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.24'
- name: Build binary
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 0
run: |
# Extract version from tag (remove 'v' prefix)
VERSION=${GITHUB_REF#refs/tags/v}
if [ -z "$VERSION" ] || [ "$VERSION" = "$GITHUB_REF" ]; then
VERSION="dev-$(git rev-parse --short HEAD)"
fi
LDFLAGS="-s -w -X main.version=$VERSION -X main.commit=$(git rev-parse HEAD) -X main.date=$(date -u +%Y-%m-%dT%H:%M:%SZ)"
if [ "${{ matrix.goos }}" = "windows" ]; then
go build -ldflags="$LDFLAGS" -o jh-${{ matrix.os }}-${{ matrix.arch }}.exe .
else
go build -ldflags="$LDFLAGS" -o jh-${{ matrix.os }}-${{ matrix.arch }} .
fi
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: jh-${{ matrix.os }}-${{ matrix.arch }}
path: jh-*
release:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: |
**/jh-*
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}