Skip to content

ci: add release-please and CI workflows #1

ci: add release-please and CI workflows

ci: add release-please and CI workflows #1

name: Release Please
on:
push:
branches: [main]
workflow_dispatch:
inputs:
force_release:
description: 'Force create a release PR even without conventional commits'
type: boolean
default: false
release_as:
description: 'Force release as specific version (e.g., 1.0.0). Leave empty for auto.'
type: string
default: ''
permissions:
contents: write
pull-requests: write
jobs:
release-please:
runs-on: ubuntu-latest
outputs:
release_created: ${{ steps.release.outputs.release_created }}
tag_name: ${{ steps.release.outputs.tag_name }}
steps:
- name: Release Please
id: release
uses: googleapis/release-please-action@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
release-as: ${{ inputs.release_as || '' }}
build:
needs: release-please
if: ${{ needs.release-please.outputs.release_created }}
runs-on: ubuntu-latest
strategy:
matrix:
binary: [nhserver, nhclient]
goarch: [amd64, arm64]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.24'
- name: Build
env:
GOOS: linux
GOARCH: ${{ matrix.goarch }}
run: |
VERSION=${{ needs.release-please.outputs.tag_name }}
OUTPUT_NAME="${{ matrix.binary }}-linux-${{ matrix.goarch }}"
go build -ldflags="-s -w -X main.version=${VERSION} -X main.buildTime=$(date -u +%Y-%m-%dT%H:%M:%SZ)" -o "${OUTPUT_NAME}" ./cmd/${{ matrix.binary }}
chmod +x "${OUTPUT_NAME}"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.binary }}-linux-${{ matrix.goarch }}
path: ${{ matrix.binary }}-linux-${{ matrix.goarch }}
upload-assets:
needs: [release-please, build]
if: ${{ needs.release-please.outputs.release_created }}
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Prepare release files
run: |
mkdir -p release
find artifacts -type f -name 'nh*' -exec cp {} release/ \;
cd release
for f in nh*; do
sha256sum "$f" > "$f.sha256"
done
- name: Upload to Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload ${{ needs.release-please.outputs.tag_name }} release/* --repo ${{ github.repository }}