Skip to content

Build and Release NAS Dashboard #23

Build and Release NAS Dashboard

Build and Release NAS Dashboard #23

Workflow file for this run

name: Build and Release NAS Dashboard
on:
workflow_dispatch:
inputs:
version:
description: 'Release version (e.g., 1.0.1, 1.1.0, 2.0.0)'
required: true
type: string
env:
GO_VERSION: '1.21'
NODE_VERSION: '20'
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: Get version
id: version
run: |
VERSION="${{ github.event.inputs.version }}"
# Validate version format (should be x.y.z)
if [[ ! $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: Version must be in format x.y.z (e.g., 1.0.1)"
exit 1
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Building version: $VERSION"
- name: Install frontend dependencies
run: |
cd frontend
npm ci
- name: Build frontend
run: |
cd frontend
export APP_VERSION="v${{ steps.version.outputs.version }}"
npm run build
- name: Download Go modules
run: |
cd backend
go mod download
- name: Run tests
run: |
cd backend
go test -v ./... || true
- name: Build backend
run: |
cd backend
# Copy frontend build to backend/static for embedding
cp -r ../frontend/build static
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o arcanas cmd/server/main.go
- name: Create release directory
run: |
mkdir -p release/arcanas
cp backend/arcanas release/arcanas/
cp -r backend/static release/arcanas/ 2>/dev/null || echo "No static directory found"
cp README.md release/arcanas/ 2>/dev/null || echo "README.md not found, skipping"
# Create version info
echo "Arcanas Dashboard ${{ steps.version.outputs.version }}" > release/arcanas/VERSION
echo "Build date: $(date -u)" >> release/arcanas/VERSION
echo "Git commit: ${{ github.sha }}" >> release/arcanas/VERSION
- name: Create tarball
run: |
cd release
tar -czf arcanas-${{ steps.version.outputs.version }}-linux-amd64.tar.gz arcanas/
sha256sum arcanas-${{ steps.version.outputs.version }}-linux-amd64.tar.gz > arcanas-${{ steps.version.outputs.version }}-linux-amd64.tar.gz.sha256
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: arcanas-${{ steps.version.outputs.version }}-linux-amd64
path: |
release/arcanas-${{ steps.version.outputs.version }}-linux-amd64.tar.gz
release/arcanas-${{ steps.version.outputs.version }}-linux-amd64.tar.gz.sha256
retention-days: 30
- name: Create and push tag
run: |
# Configure git
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Fetch all remote tags
git fetch --tags --force
# Check if tag already exists locally or remotely
TAG="v${{ steps.version.outputs.version }}"
if git rev-parse "$TAG" >/dev/null 2>&1 || git ls-remote --tags origin "$TAG" | grep -q "$TAG"; then
echo "Tag $TAG already exists, using it"
else
echo "Creating new tag $TAG"
git tag -a $TAG -m "Release $TAG"
git push origin $TAG
echo "Created tag: $TAG"
# Wait for tag to be available
echo "Waiting for tag to be available..."
sleep 10
fi
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.version.outputs.version }}
files: |
release/arcanas-${{ steps.version.outputs.version }}-linux-amd64.tar.gz
release/arcanas-${{ steps.version.outputs.version }}-linux-amd64.tar.gz.sha256
generate_release_notes: true
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}