mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
Deleted deb/build.sh file and integrated that in actions yml
This commit is contained in:
162
.github/workflows/release-deb.yml
vendored
162
.github/workflows/release-deb.yml
vendored
@ -1,74 +1,146 @@
|
|||||||
name: Build and Release Zig Project
|
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
version:
|
||||||
|
description: 'Version to deploy (format: vX.Y.Z)'
|
||||||
|
required: true
|
||||||
|
upload:
|
||||||
|
description: 'Upload final artifacts to R2'
|
||||||
|
default: false
|
||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- 'v*'
|
- 'v[0-9]+.[0-9]+.[0-9]+'
|
||||||
|
|
||||||
|
name: Release Tag
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
setup:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
version: ${{ steps.extract_version.outputs.version }}
|
||||||
|
build: ${{ steps.extract_build_info.outputs.build }}
|
||||||
|
commit: ${{ steps.extract_build_info.outputs.commit }}
|
||||||
|
commit_long: ${{ steps.extract_build_info.outputs.commit_long }}
|
||||||
steps:
|
steps:
|
||||||
# Checkout the repository
|
- name: Validate Version Input
|
||||||
- name: Checkout Code
|
if: github.event_name == 'workflow_dispatch'
|
||||||
uses: actions/checkout@v3
|
run: |
|
||||||
|
if [[ ! "${{ github.event.inputs.version }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||||
|
echo "Error: Version must follow the format vX.Y.Z (e.g., v1.0.0)."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Install dependencies
|
echo "Version is valid: ${{ github.event.inputs.version }}"
|
||||||
|
|
||||||
|
- name: Exract the Version
|
||||||
|
id: extract_version
|
||||||
|
run: |
|
||||||
|
if [[ "${{ github.event_name }}" == "push" ]]; then
|
||||||
|
# Remove the leading 'v' from the tag
|
||||||
|
VERSION=${GITHUB_REF#refs/tags/v}
|
||||||
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||||
|
elif [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
|
||||||
|
VERSION=${{ github.event.inputs.version }}
|
||||||
|
VERSION=${VERSION#v}
|
||||||
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
echo "Error: Unsupported event type."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
# Important so that build number generation works
|
||||||
|
fetch-depth: 0
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: |
|
run: |
|
||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt install -y build-essential libbz2-dev libfreetype6-dev zlib1g-dev libpng-dev libgtk-4-dev libadwaita-1-dev git libglib2.0-dev pkg-config snapd
|
sudo apt install -y build-essential libbz2-dev libfreetype6-dev zlib1g-dev libpng-dev libgtk-4-dev libadwaita-1-dev git libglib2.0-dev pkg-config
|
||||||
sudo snap install --beta zig --classic
|
sudo snap install --beta zig --classic
|
||||||
|
|
||||||
# Run the build script to create the .deb package
|
- name: Fetch Zig Dependencies
|
||||||
- name: Print GitHub Tag
|
|
||||||
run: |
|
run: |
|
||||||
echo "GitHub Ref: $GITHUB_REF"
|
echo "Setting up Zig cache directory..."
|
||||||
echo "Tag: ${GITHUB_REF##*/}"
|
CACHE_DIR="/tmp/offline-cache"
|
||||||
|
mkdir -p "$CACHE_DIR"
|
||||||
|
|
||||||
- name: Build .deb Package
|
echo "Fetching Zig dependencies..."
|
||||||
env:
|
export ZIG_GLOBAL_CACHE_DIR="$CACHE_DIR"
|
||||||
ZIG_GLOBAL_CACHE_DIR: /tmp/offline-cache
|
./nix/build-support/fetch-zig-cache.sh
|
||||||
VERSION: ${{ github.event.inputs.version }}
|
|
||||||
|
|
||||||
|
- name: Build Application
|
||||||
run: |
|
run: |
|
||||||
chmod +x ./deb/build.sh
|
echo "Building..."
|
||||||
./deb/build.sh
|
CACHE_DIR="/tmp/offline-cache"
|
||||||
|
zig build --prefix /usr --system "$CACHE_DIR/p" -Doptimize=ReleaseFast -Dcpu=baseline -Dversion-string=${VERSION}
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Build failed!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Upload the generated .deb file as an artifact
|
- name: Build DEB Package
|
||||||
- name: Upload .deb Package
|
run: |
|
||||||
uses: actions/upload-artifact@v3
|
BUILD_DIR="$(pwd)/build"
|
||||||
|
DEB_DIR="$BUILD_DIR/${APP_NAME}_${VERSION}_${ARCH}"
|
||||||
|
DESTDIR="$DEB_DIR/usr"
|
||||||
|
BIN_DIR="$DESTDIR/bin"
|
||||||
|
DESKTOP_DIR="$DEB_DIR/usr/share/applications"
|
||||||
|
|
||||||
|
# Clean up old build directories
|
||||||
|
rm -rf "$BUILD_DIR"
|
||||||
|
|
||||||
|
# Step 1: Create directory structure
|
||||||
|
mkdir -p "$DEB_DIR"
|
||||||
|
mkdir -p "$BIN_DIR"
|
||||||
|
mkdir -p "$DESKTOP_DIR"
|
||||||
|
|
||||||
|
# Step 2: Add application binaries
|
||||||
|
cp /usr/bin/${APP_NAME} "$BIN_DIR/${APP_NAME}"
|
||||||
|
|
||||||
|
# Step 3: Add and rename desktop file
|
||||||
|
cp ./dist/linux/app.desktop "$DESKTOP_DIR/ghostty.desktop"
|
||||||
|
|
||||||
|
# Step 4: Create DEBIAN control file
|
||||||
|
mkdir -p "$DEB_DIR/DEBIAN"
|
||||||
|
cat <<EOF > "$DEB_DIR/DEBIAN/control"
|
||||||
|
Package: $APP_NAME
|
||||||
|
Version: $VERSION
|
||||||
|
Architecture: $ARCH
|
||||||
|
Maintainer: Ronit Gandhi <ronitgandhi96@gmail.com>
|
||||||
|
Description: A fast, feature-rich, and cross-platform terminal emulator that uses platform-native UI and GPU acceleration.
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Step 5: Build .deb package
|
||||||
|
dpkg-deb --build "$DEB_DIR"
|
||||||
|
|
||||||
|
- name: Upload DEB Artifact
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: ghostty-deb-package
|
name: deb-package
|
||||||
path: build/*.deb
|
path: |
|
||||||
|
$BUILD_DIR/${APP_NAME}_${VERSION}_${ARCH}.deb
|
||||||
|
|
||||||
release:
|
create-release:
|
||||||
needs: build
|
needs: setup
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
# Checkout the repository
|
- name: Download DEB Artifact
|
||||||
- name: Checkout Code
|
uses: actions/download-artifact@v4
|
||||||
uses: actions/checkout@v3
|
with:
|
||||||
|
name: deb-package
|
||||||
|
path: ./artifacts
|
||||||
|
|
||||||
# Create a Release
|
- name: Create GitHub Release
|
||||||
- name: Create Release
|
uses: actions/create-release@v3
|
||||||
uses: actions/create-release@v1
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
with:
|
with:
|
||||||
tag_name: ${{ github.ref_name }}
|
tag_name: ${{ github.ref_name }}
|
||||||
release_name: Release ${{ github.ref_name }}
|
release_name: Release ${{ github.ref_name }}
|
||||||
|
body: |
|
||||||
|
Automated release of ${{ github.ref_name }}.
|
||||||
draft: false
|
draft: false
|
||||||
prerelease: false
|
prerelease: false
|
||||||
|
generate_release_notes: true
|
||||||
# Upload the .deb file to the Release
|
assets: ./artifacts/*.deb
|
||||||
- name: Upload .deb to Release
|
|
||||||
uses: actions/upload-release-asset@v1
|
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
with:
|
|
||||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
|
||||||
asset_path: build/*.deb
|
|
||||||
asset_name: ghostty_${{ github.ref_name }}.deb
|
|
||||||
asset_content_type: application/vnd.debian.binary-package
|
|
||||||
|
92
deb/build.sh
92
deb/build.sh
@ -1,92 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Set variables
|
|
||||||
APP_NAME="ghostty"
|
|
||||||
VERSION="v1.0.0" # TODO: Have to set this to take from github-action
|
|
||||||
echo "Using version: $VERSION"
|
|
||||||
ARCH="amd64"
|
|
||||||
BUILD_DIR="$(pwd)/build"
|
|
||||||
DEB_DIR="$BUILD_DIR/${APP_NAME}_${VERSION}_${ARCH}"
|
|
||||||
CACHE_DIR="/tmp/offline-cache"
|
|
||||||
DESTDIR="$DEB_DIR/usr"
|
|
||||||
BIN_DIR="$DESTDIR/bin"
|
|
||||||
DESKTOP_DIR="$DEB_DIR/usr/share/applications"
|
|
||||||
|
|
||||||
# Clean up old build directories
|
|
||||||
rm -rf "$BUILD_DIR"
|
|
||||||
|
|
||||||
# Step 1: Create directory structure
|
|
||||||
mkdir -p "$DEB_DIR/DEBIAN"
|
|
||||||
mkdir -p "$BIN_DIR"
|
|
||||||
mkdir -p "$DESKTOP_DIR"
|
|
||||||
|
|
||||||
# Step 2: Fetch dependencies (requires internet access)
|
|
||||||
echo "Setting up Zig cache directory..."
|
|
||||||
mkdir -p "$CACHE_DIR"
|
|
||||||
|
|
||||||
echo "Fetching Zig dependencies..."
|
|
||||||
export ZIG_GLOBAL_CACHE_DIR="$CACHE_DIR"
|
|
||||||
./nix/build-support/fetch-zig-cache.sh
|
|
||||||
|
|
||||||
# Step 3: Build the application
|
|
||||||
echo "Building $APP_NAME..."
|
|
||||||
zig build --prefix /usr --system "$CACHE_DIR/p" -Doptimize=ReleaseFast -Dcpu=baseline
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "Build failed!"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Step 4: Verify that the binary was built successfully
|
|
||||||
if [ -f "/usr/bin/$APP_NAME" ]; then
|
|
||||||
# Copy the binary to the destination directory
|
|
||||||
cp "/usr/bin/$APP_NAME" "$BIN_DIR/"
|
|
||||||
else
|
|
||||||
echo "Error: Binary not found at /usr/bin/$APP_NAME"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Step 5: Create DEBIAN/control file
|
|
||||||
echo "Creating control file..."
|
|
||||||
CONTROL_FILE="$DEB_DIR/DEBIAN/control"
|
|
||||||
cat <<EOF > "$CONTROL_FILE"
|
|
||||||
Package: $APP_NAME
|
|
||||||
Version: $VERSION
|
|
||||||
Section: utils
|
|
||||||
Priority: optional
|
|
||||||
Architecture: $ARCH
|
|
||||||
Maintainer: Ronit Gandhi <ronitgandhi96@gmail.com>
|
|
||||||
Description: Ghostty - A fast, feature-rich, and cross-platform terminal emulator that uses platform-native UI and GPU acceleration.
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# Step 6: Create .desktop file for application menu/search
|
|
||||||
echo "Creating .desktop file..."
|
|
||||||
DESKTOP_FILE="$DESKTOP_DIR/$APP_NAME.desktop"
|
|
||||||
cat <<EOF > "$DESKTOP_FILE"
|
|
||||||
[Desktop Entry]
|
|
||||||
Version=1.0
|
|
||||||
Name=Ghostty
|
|
||||||
Comment=A fast, feature-rich, and cross-platform terminal emulator that uses platform-native UI and GPU acceleration.
|
|
||||||
Exec=$APP_NAME
|
|
||||||
Icon=$APP_NAME
|
|
||||||
Terminal=true
|
|
||||||
Type=Application
|
|
||||||
Categories=Utility;System;
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# Step 7: Set permissions
|
|
||||||
echo "Setting permissions..."
|
|
||||||
chmod -R 755 "$DEB_DIR"
|
|
||||||
chmod 644 "$CONTROL_FILE"
|
|
||||||
chmod 644 "$DESKTOP_FILE"
|
|
||||||
chmod +x "$BIN_DIR/$APP_NAME" # Ensure the binary is executable
|
|
||||||
|
|
||||||
# Step 8: Build .deb package
|
|
||||||
echo "Building .deb package..."
|
|
||||||
dpkg-deb --build "$DEB_DIR"
|
|
||||||
if [ $? -eq 0 ]; then
|
|
||||||
echo "$APP_NAME version $VERSION .deb package created successfully!"
|
|
||||||
echo "File: $BUILD_DIR/${APP_NAME}_${VERSION}_${ARCH}.deb"
|
|
||||||
else
|
|
||||||
echo "Failed to build .deb package!"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
Reference in New Issue
Block a user