Skip to content

Updates

Updates #46

Workflow file for this run

name: Build websitino (linux-static)
on:
push:
branches:
- main
tags:
- 'v*'
jobs:
build-and-export:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
# Checkout the repository
- name: Checkout code
uses: actions/checkout@v4
# Add version info if this is a release
- name: Set version info for release
if: startsWith(github.ref, 'refs/tags/')
run: |
VERSION=$(echo ${{ github.ref }} | sed 's/refs\/tags\///')
echo "enum WEBSITINO_VERSION = \"$VERSION\";" >> source/app.d
# Set up Docker build
- name: Build Docker image
run: |
echo "FROM alpine:latest
RUN apk add vim gcc musl-dev ldc dub llvm-libunwind-static openssl-libs-static gzip upx cmake make
WORKDIR /app
COPY . .
CMD [\"dub\", \"build\", \"--build=release\", \"--config=linux-static\"]" > Dockerfile
docker build -t websitino-image .
# Run the Docker container to build the project
- name: Run Docker container and build project
run: |
docker run --name websitino-container websitino-image || true
# Copy compiled file from Docker container to host
- name: Copy compiled binary
run: |
docker cp websitino-container:/app/websitino .
docker rm websitino-container
strip -s websitino
- name: Create deb package
run: |
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
VERSION=$(echo ${{ github.ref }} | sed 's/refs\/tags\/v*//')
else
VERSION="0.0.0-dev"
fi
echo "Creating deb package for version $VERSION"
mkdir -p websitino-$VERSION/DEBIAN
mkdir -p websitino-$VERSION/usr/bin
mkdir -p websitino-$VERSION/usr/share/doc/websitino
echo "Package: websitino" > websitino-$VERSION/DEBIAN/control
echo "Version: $VERSION" >> websitino-$VERSION/DEBIAN/control
echo "Section: web" >> websitino-$VERSION/DEBIAN/control
echo "Priority: optional" >> websitino-$VERSION/DEBIAN/control
echo "Architecture: amd64" >> websitino-$VERSION/DEBIAN/control
echo "Maintainer: Andrea Fontana <me@andreafontana.it>" >> websitino-$VERSION/DEBIAN/control
echo "Description: A lightweight static file server for local development. Perfect for testing static websites and serving files with minimal setup." >> websitino-$VERSION/DEBIAN/control
cp websitino websitino-$VERSION/usr/bin/
cp LICENSE websitino-$VERSION/usr/share/doc/websitino/
cp README.md websitino-$VERSION/usr/share/doc/websitino/
echo "#!/bin/bash" > websitino-$VERSION/DEBIAN/postinst
echo "chmod +x /usr/bin/websitino" >> websitino-$VERSION/DEBIAN/postinst
chmod +x websitino-$VERSION/DEBIAN/postinst
dpkg-deb --build websitino-$VERSION
rm -rf websitino-$VERSION/*
mv websitino-$VERSION.deb websitino.deb
# Upload the binary as an artifact
- name: Upload binary as artifact
uses: actions/upload-artifact@v4
with:
name: websitino
path: websitino
# Upload the deb package as an artifact
- name: Upload deb package as artifact
uses: actions/upload-artifact@v4
with:
name: websitino.deb
path: websitino.deb
- name: Pull latest changes
run: |
git checkout -- source/app.d
git fetch origin
git checkout gh-pages
git pull origin gh-pages
# Prepara la directory per GitHub Pages
- name: Prepara directory per GitHub Pages
if: startsWith(github.ref, 'refs/tags/v')
run: |
mkdir -p public/linux
cp websitino.deb public/linux/websitino.deb
cp websitino public/linux/
# Pubblica su GitHub Pages
- name: Deploy su GitHub Pages
if: startsWith(github.ref, 'refs/tags/v')
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
force_orphan: false
keep_files: true