94 lines
2.5 KiB
YAML
94 lines
2.5 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
tags:
|
|
- 'v*'
|
|
pull_request:
|
|
branches: [ '**' ]
|
|
workflow_dispatch:
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
quality-and-release:
|
|
name: Quality & Release
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: '1.24'
|
|
cache: true
|
|
|
|
- name: Tidy
|
|
run: go mod tidy
|
|
|
|
- name: Run Linter
|
|
uses: golangci/golangci-lint-action@v8
|
|
with:
|
|
version: v2.11.4
|
|
|
|
- name: Run Tests
|
|
run: go test -v ./...
|
|
|
|
- name: Build Binaries
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
run: |
|
|
mkdir -p dist
|
|
platforms=("linux/amd64" "linux/arm64" "darwin/amd64" "darwin/arm64")
|
|
for platform in "${platforms[@]}"; do
|
|
os_arch=(${platform//\// })
|
|
GOOS=${os_arch[0]}
|
|
GOARCH=${os_arch[1]}
|
|
output_name="iris"
|
|
[ "$GOOS" == "windows" ] && output_name="iris.exe"
|
|
|
|
echo "Building $GOOS/$GOARCH..."
|
|
GOOS=$GOOS GOARCH=$GOARCH go build \
|
|
-ldflags="-s -w -X github.com/versenilvis/iris/root.Version=${{ github.ref_name }}" \
|
|
-trimpath -o "dist/$output_name" ./cmd/iris
|
|
|
|
cd dist
|
|
tar -czf "iris_${GOOS}_${GOARCH}.tar.gz" "$output_name"
|
|
rm "$output_name"
|
|
cd ..
|
|
done
|
|
|
|
- name: Prepare Release Notes
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
run: |
|
|
# Generate standard GitHub release notes
|
|
GEN_NOTES=$(gh api repos/${{ github.repository }}/releases/generate-notes -f tag_name=${{ github.ref_name }} --jq .body)
|
|
cat <<EOF > release_notes.md
|
|
$GEN_NOTES
|
|
|
|
## Installation
|
|
\`\`\`bash
|
|
curl -sS https://raw.githubusercontent.com/versenilvis/iris/main/scripts/install.sh | sh
|
|
\`\`\`
|
|
EOF
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Create GitHub Release
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
uses: softprops/action-gh-release@v1
|
|
with:
|
|
name: ${{ github.ref_name }}
|
|
body_path: release_notes.md
|
|
files: dist/*.tar.gz
|
|
generate_release_notes: false
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|