Skip to content

Build and Release

Build and Release #5

Workflow file for this run

name: Build and Release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
tag:
description: "Tag to release"
required: true
type: string
permissions:
contents: write
env:
VERSION: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag || github.ref_name }}
jobs:
build:
runs-on: self-hosted
strategy:
matrix:
include:
- goos: windows
goarch: amd64
suffix: .exe
- goos: linux
goarch: amd64
suffix: ""
- goos: darwin
goarch: amd64
suffix: ""
- goos: darwin
goarch: arm64
suffix: ""
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.25"
- name: Get dependencies
run: go mod download
- name: Build binary
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 0
run: |
BINARY_NAME="archi-${{ env.VERSION }}-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.suffix }}"
go build -ldflags="-s -w" -o "$BINARY_NAME" .
echo "BINARY_NAME=$BINARY_NAME" >> $GITHUB_ENV
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: archi-${{ env.VERSION }}-${{ matrix.goos }}-${{ matrix.goarch }}
path: ${{ env.BINARY_NAME }}
release:
needs: build
runs-on: self-hosted
if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch'
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: ./artifacts
- name: Prepare release files
run: |
mkdir -p release
find artifacts -name "archi-*" -type f -exec cp {} release/ \;
ls -la release/
- name: Generate changelog
id: changelog
run: |
VERSION="${{ env.VERSION }}"
# Get the previous tag for changelog generation
PREVIOUS_TAG=$(git tag --sort=-version:refname | grep -v "^$VERSION$" | head -n 1)
# Generate git changelog
if [ -n "$PREVIOUS_TAG" ]; then
echo "Generating changelog from $PREVIOUS_TAG to HEAD"
GIT_CHANGELOG=$(git log --pretty=format:"- %s (%h)" $PREVIOUS_TAG..HEAD 2>/dev/null || git log --pretty=format:"- %s (%h)" --max-count=10)
else
echo "No previous tag found, showing recent commits"
GIT_CHANGELOG=$(git log --pretty=format:"- %s (%h)" --max-count=10)
fi
# Generate contributors list
if [ -n "$PREVIOUS_TAG" ]; then
CONTRIBUTORS=$(git log --pretty=format:"%an" $PREVIOUS_TAG..HEAD 2>/dev/null | sort | uniq | sed 's/^/- @/' | tr '\n' ' ' || echo "")
else
CONTRIBUTORS=$(git log --pretty=format:"%an" --max-count=10 | sort | uniq | sed 's/^/- @/' | tr '\n' ' ')
fi
CHANGELOG=$(cat << EOF
## What's Changed
$GIT_CHANGELOG
## Contributors
$CONTRIBUTORS
## Download Instructions
This release includes cross-platform binaries for Windows, Linux, and macOS.
**Windows Users:**
- Download \`archi-${VERSION}-windows-amd64.exe\`
- Place in a directory and optionally add to PATH
- Run: \`archi-${VERSION}-windows-amd64.exe --help\`
**Linux Users:**
- Download \`archi-${VERSION}-linux-amd64\`
- Make executable: \`chmod +x archi-${VERSION}-linux-amd64\`
- Run: \`./archi-${VERSION}-linux-amd64 --help\`
**macOS Users:**
- Intel Macs: Download \`archi-${VERSION}-darwin-amd64\`
- Apple Silicon: Download \`archi-${VERSION}-darwin-arm64\`
- Make executable: \`chmod +x archi-${VERSION}-darwin-*\`
- Run: \`./archi-${VERSION}-darwin-* --help\`
## Features
- AI-powered directory structure analysis
- Multiple output formats (JSON, Markdown, detailed reports)
- Support for various file types (DOCX, XLSX, PDF, images)
- Architectural recommendations
- Modern CLI with subcommands
See the [README.md](https://github.com/${{ github.repository }}/blob/main/README.md) for detailed usage instructions.
EOF
)
echo "CHANGELOG<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGELOG" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.VERSION }}
name: "Archi ${{ env.VERSION }}"
body: ${{ steps.changelog.outputs.CHANGELOG }}
files: release/*
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
test:
runs-on: self-hosted
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.25"
- name: Get dependencies
run: go mod download
- name: Run tests
run: go test ./...
- name: Build test
run: go build .
- name: Test help command
run: ./archi --help