Skip to content

linting

linting #19

Workflow file for this run

name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
test:
runs-on: ubuntu-latest
if: >
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')) ||
(github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success') ||
github.event_name == 'pull_request'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23.0'
- name: Run tests
run: go test -race ./...
build:
needs: test
runs-on: ubuntu-latest
if: >
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')) ||
(github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success')
strategy:
matrix:
goos: [linux, darwin, windows]
goarch: [amd64, arm64]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23.0'
- name: Set up build variables
run: |
if [ "${{ github.event_name }}" = "workflow_run" ]; then
# Get the latest tag when triggered by version workflow
VERSION=$(git tag -l "v*" | sort -V | tail -1)
else
# Get version from tag ref when triggered by tag push
VERSION=${GITHUB_REF#refs/tags/}
fi
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV
echo "COMMIT_SHA=${GITHUB_SHA::8}" >> $GITHUB_ENV
# Debug output
echo "🏷️ Detected VERSION: $VERSION"
echo "📅 BUILD_DATE: $(date -u +'%Y-%m-%dT%H:%M:%SZ')"
echo "🔑 Event: ${{ github.event_name }}"
- name: Build binary
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
run: |
echo "🔍 VERSION in build step: $VERSION"
# Set binary name
binary_name="nexaa-cli"
if [ "$GOOS" = "windows" ]; then
binary_name="${binary_name}.exe"
fi
# Create output directory
output_dir="nexaa-${VERSION}-${GOOS}-${GOARCH}"
mkdir -p "$output_dir"
echo "Building for $GOOS/$GOARCH..."
# Build binary with version info
CGO_ENABLED=0 go build \
-ldflags="-s -w -X github.com/nexaa-cloud/nexaa-cli/cmd.Version=${VERSION} -X github.com/nexaa-cloud/nexaa-cli/cmd.BuildDate=${BUILD_DATE} -X github.com/nexaa-cloud/nexaa-cli/cmd.CommitSHA=${COMMIT_SHA}" \
-o "${output_dir}/${binary_name}" \
.
# Copy additional files
cp README.md "${output_dir}/"
# Create archive
if [ "$GOOS" = "windows" ]; then
zip -r "nexaa-${VERSION}-${GOOS}-${GOARCH}.zip" "${output_dir}/"
else
tar -czf "nexaa-${VERSION}-${GOOS}-${GOARCH}.tar.gz" "${output_dir}/"
fi
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: nexaa-${{ env.VERSION }}-${{ matrix.goos }}-${{ matrix.goarch }}
path: nexaa-${{ env.VERSION }}-${{ matrix.goos }}-${{ matrix.goarch }}.*
release:
needs: build
runs-on: ubuntu-latest
if: >
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')) ||
(github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success')
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up build variables
run: |
if [ "${{ github.event_name }}" = "workflow_run" ]; then
# Get the latest tag when triggered by version workflow
VERSION=$(git tag -l "v*" | sort -V | tail -1)
else
# Get version from tag ref when triggered by tag push
VERSION=${GITHUB_REF#refs/tags/}
fi
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Generate checksums
run: |
cd dist
sha256sum * > checksums.txt
cd ..
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.VERSION }}
files: |
dist/*
draft: false
prerelease: ${{ contains(env.VERSION, '-') }}
generate_release_notes: true
body: |
## Installation
Download the appropriate binary for your platform from the assets below.
### Linux
```bash
# AMD64
curl -L https://github.com/${{ github.repository }}/releases/download/${{ env.VERSION }}/nexaa-${{ env.VERSION }}-linux-amd64.tar.gz | tar xz
chmod +x nexaa-${{ env.VERSION }}-linux-amd64/nexaa-cli
sudo mv nexaa-${{ env.VERSION }}-linux-amd64/nexaa-cli /usr/local/bin/
# ARM64
curl -L https://github.com/${{ github.repository }}/releases/download/${{ env.VERSION }}/nexaa-${{ env.VERSION }}-linux-arm64.tar.gz | tar xz
chmod +x nexaa-${{ env.VERSION }}-linux-arm64/nexaa-cli
sudo mv nexaa-${{ env.VERSION }}-linux-arm64/nexaa-cli /usr/local/bin/
```
### macOS
```bash
# Intel Macs (amd64)
curl -L https://github.com/${{ github.repository }}/releases/download/${{ env.VERSION }}/nexaa-${{ env.VERSION }}-darwin-amd64.tar.gz | tar xz
chmod +x nexaa-${{ env.VERSION }}-darwin-amd64/nexaa-cli
sudo mv nexaa-${{ env.VERSION }}-darwin-amd64/nexaa-cli /usr/local/bin/
# Apple Silicon Macs (arm64)
curl -L https://github.com/${{ github.repository }}/releases/download/${{ env.VERSION }}/nexaa-${{ env.VERSION }}-darwin-arm64.tar.gz | tar xz
chmod +x nexaa-${{ env.VERSION }}-darwin-arm64/nexaa-cli
sudo mv nexaa-${{ env.VERSION }}-darwin-arm64/nexaa-cli /usr/local/bin/
```
### Windows
Download the appropriate `.zip` file for your architecture:
- **AMD64**: `nexaa-${{ env.VERSION }}-windows-amd64.zip`
- **ARM64**: `nexaa-${{ env.VERSION }}-windows-arm64.zip`
Extract the zip file and add the executable to your PATH.
### Verify installation
```bash
nexaa-cli version
```
## Checksums
Verify your download using the checksums in `checksums.txt`.
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}