feat: add gitea workflow
All checks were successful
Build and Release Zed Editor / check-version (push) Successful in 20s
Build and Release Zed Editor / build-and-release (push) Successful in 44s

This commit is contained in:
2025-10-13 14:05:11 +02:00
parent 7bd7a317f3
commit 45a002fd47
4 changed files with 317 additions and 35 deletions

View File

@@ -0,0 +1,149 @@
name: Build and Release Zed Editor
on:
push:
branches:
- main
schedule:
# Check daily at 2 AM for new versions
- cron: '0 2 * * *'
workflow_dispatch:
# Allow manual triggering
jobs:
check-version:
runs-on: [ubuntu-latest]
outputs:
should_build: ${{ steps.version_check.outputs.should_build }}
zed_version: ${{ steps.version_check.outputs.zed_version }}
zed_version_tag: ${{ steps.version_check.outputs.zed_version_tag }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Check versions
id: version_check
run: |
# Fetch the latest Zed version from GitHub
ZED_VERSION=$(curl -s https://api.github.com/repos/zed-industries/zed/releases/latest | jq -r '.tag_name')
ZED_VERSION_NUMBER=$(echo $ZED_VERSION | sed 's/^v//')
echo "Latest Zed version on GitHub: $ZED_VERSION"
echo "zed_version=$ZED_VERSION_NUMBER" >> $GITHUB_OUTPUT
echo "zed_version_tag=$ZED_VERSION" >> $GITHUB_OUTPUT
# Fetch the latest release on Gitea (if it exists)
GITEA_LATEST=$(curl -s "${{ gitea.api_url }}/repos/${{ gitea.repository }}/releases/latest" | jq -r '.tag_name // "none"')
echo "Latest Gitea release: $GITEA_LATEST"
# Compare versions
if [ "$ZED_VERSION" = "$GITEA_LATEST" ]; then
echo "Versions match ($ZED_VERSION). No build needed."
echo "should_build=false" >> $GITHUB_OUTPUT
else
echo "New version detected: $ZED_VERSION (current: $GITEA_LATEST)"
echo "should_build=true" >> $GITHUB_OUTPUT
fi
build-and-release:
runs-on: [ubuntu-latest]
needs: check-version
if: needs.check-version.outputs.should_build == 'true'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y wget curl jq dpkg-dev
- name: Build DEB package
run: |
make all
- name: Get package info
id: package_info
run: |
VERSION="${{ needs.check-version.outputs.zed_version }}"
DEB_FILE="build/zed-editor_${VERSION}_amd64.deb"
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "deb_path=$DEB_FILE" >> $GITHUB_OUTPUT
echo "deb_filename=zed-editor_${VERSION}_amd64.deb" >> $GITHUB_OUTPUT
# Verify that the file exists
if [ ! -f "$DEB_FILE" ]; then
echo "Error: File $DEB_FILE does not exist"
exit 1
fi
echo "Package created: $DEB_FILE"
ls -lh "$DEB_FILE"
- name: Generate release notes
id: release_notes
run: |
ZED_VERSION_TAG="${{ needs.check-version.outputs.zed_version_tag }}"
# Fetch release notes from GitHub
RELEASE_BODY=$(curl -s "https://api.github.com/repos/zed-industries/zed/releases/tags/$ZED_VERSION_TAG" | jq -r '.body // "No release notes available."')
# Create release notes for Gitea
cat > release_notes.md << 'EOF'
## Zed Editor ${{ needs.check-version.outputs.zed_version }}
Unofficial Debian package for [Zed Editor](https://zed.dev/).
### Installation
```bash
# Download and install the package
wget https://git.rawleenc.dev/${{ gitea.repository }}/releases/download/${{ needs.check-version.outputs.zed_version_tag }}/zed-editor_${{ needs.check-version.outputs.zed_version }}_amd64.deb
sudo dpkg -i zed-editor_${{ needs.check-version.outputs.zed_version }}_amd64.deb
# Or install from the APT repository (if configured)
sudo apt update
sudo apt install zed-editor
```
### Upstream Release Notes
EOF
echo "$RELEASE_BODY" >> release_notes.md
# Store the content for use in the release action
echo "notes_content<<EOF" >> $GITHUB_OUTPUT
cat release_notes.md >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create Release and upload assets
uses: akkuman/gitea-release-action@v1
with:
files: ${{ steps.package_info.outputs.deb_path }}
title: "Zed Editor ${{ needs.check-version.outputs.zed_version }}"
tag_name: ${{ needs.check-version.outputs.zed_version_tag }}
body: |
${{ steps.release_notes.outputs.notes_content }}
- name: Upload DEB package to Gitea repository
if: ${{ secrets.PACKAGE_PUB_TOKEN != '' }}
run: |
DEB_FILE="${{ steps.package_info.outputs.deb_path }}"
# Extract the username from the repository
OWNER=$(echo "${{ gitea.repository }}" | cut -d'/' -f1)
# Upload to Gitea Debian repository
curl --fail --user "$OWNER:${{ secrets.PACKAGE_PUB_TOKEN }}" \
--upload-file "$DEB_FILE" \
"${{ gitea.server_url }}/api/packages/$OWNER/debian/pool/stable/main/upload"
echo "Package successfully published to Debian repository"
- name: Upload build artifacts
uses: christopherhx/gitea-upload-artifact@v4
with:
name: zed-editor-${{ needs.check-version.outputs.zed_version }}
path: ${{ steps.package_info.outputs.deb_path }}

13
.gitignore vendored Normal file
View File

@@ -0,0 +1,13 @@
# Build artifacts
build/
# Temporary files
*.tmp
*.log
# Editor files
.vscode/
.idea/
*.swp
*.swo
*~

View File

@@ -9,57 +9,57 @@ EXTRACT_DIR = $(BUILD_DIR)/extracted
DEB_DIR = $(BUILD_DIR)/deb
CONTROL_DIR = $(DEB_DIR)/DEBIAN
# Déterminer la dernière version stable
# Determine the latest stable version
VERSION := $(shell curl -s https://api.github.com/repos/$(GITHUB_REPO)/releases/latest | jq -r '.tag_name' | sed 's/^v//')
DOWNLOAD_URL := $(shell curl -s https://api.github.com/repos/$(GITHUB_REPO)/releases/latest | jq -r '.assets[] | select(.name == "$(ARCHIVE_NAME)") | .browser_download_url')
# Nom du paquet
# Package name
PACKAGE_NAME = zed-editor
DEB_FILE = $(BUILD_DIR)/$(PACKAGE_NAME)_$(VERSION)_amd64.deb
all: deb
help:
@echo "Makefile pour créer un paquet .deb de Zed Editor"
@echo "Makefile to create a .deb package for Zed Editor"
@echo ""
@echo "Cibles disponibles:"
@echo " all - Construire le paquet .deb (cible par défaut)"
@echo " download - Télécharger l'archive depuis GitHub"
@echo " extract - Extraire l'archive"
@echo " deb - Créer le paquet .deb"
@echo " clean - Nettoyer les fichiers temporaires"
@echo " help - Afficher cette aide"
@echo "Available targets:"
@echo " all - Build the .deb package (default target)"
@echo " download - Download the archive from GitHub"
@echo " extract - Extract the archive"
@echo " deb - Create the .deb package"
@echo " clean - Clean up temporary files"
@echo " help - Display this help"
@echo ""
@echo "Version détectée: $(VERSION)"
@echo "Detected version: $(VERSION)"
# Télécharger l'archive si elle n'existe pas
# Download the archive if it doesn't exist
download: $(BUILD_DIR)/$(ARCHIVE_NAME)
$(BUILD_DIR)/$(ARCHIVE_NAME):
@echo "Téléchargement de Zed v$(VERSION)..."
@echo "Downloading Zed v$(VERSION)..."
@mkdir -p $(BUILD_DIR)
@if [ -z "$(DOWNLOAD_URL)" ]; then \
echo "Erreur: impossible de trouver l'URL de téléchargement"; \
echo "Error: unable to find download URL"; \
exit 1; \
fi
@wget -q --show-progress -O $@ "$(DOWNLOAD_URL)"
@echo "Téléchargement terminé: $@"
@echo "Download complete: $@"
# Extraire l'archive
# Extract the archive
extract: $(EXTRACT_DIR)/.extracted
$(EXTRACT_DIR)/.extracted: $(BUILD_DIR)/$(ARCHIVE_NAME)
@echo "Extraction de l'archive..."
@echo "Extracting archive..."
@mkdir -p $(EXTRACT_DIR)
@tar -xzf $(BUILD_DIR)/$(ARCHIVE_NAME) -C $(EXTRACT_DIR)
@touch $@
@echo "Extraction terminée"
@echo "Extraction complete"
# Créer le paquet .deb
# Create the .deb package
deb: $(DEB_FILE)
$(DEB_FILE): $(EXTRACT_DIR)/.extracted
@echo "Construction du paquet .deb..."
@echo "Building .deb package..."
@mkdir -p $(CONTROL_DIR)
@mkdir -p $(DEB_DIR)/opt/zed
@mkdir -p $(DEB_DIR)/usr/bin
@@ -67,23 +67,23 @@ $(DEB_FILE): $(EXTRACT_DIR)/.extracted
@mkdir -p $(DEB_DIR)/usr/share/icons/hicolor/512x512/apps
@mkdir -p $(DEB_DIR)/usr/share/icons/hicolor/1024x1024/apps
# Copier les fichiers de l'application
@echo "Copie des fichiers..."
# Copy application files
@echo "Copying files..."
@cp -r $(EXTRACT_DIR)/zed.app/* $(DEB_DIR)/opt/zed/
# Créer le lien symbolique pour le binaire
# Create symbolic link for the binary
@ln -sf /opt/zed/bin/zed $(DEB_DIR)/usr/bin/zed
# Copier les fichiers desktop et icônes
# Copy desktop file and icons
@cp $(EXTRACT_DIR)/zed.app/share/applications/zed.desktop $(DEB_DIR)/usr/share/applications/
@cp $(EXTRACT_DIR)/zed.app/share/icons/hicolor/512x512/apps/zed.png $(DEB_DIR)/usr/share/icons/hicolor/512x512/apps/
@cp $(EXTRACT_DIR)/zed.app/share/icons/hicolor/1024x1024/apps/zed.png $(DEB_DIR)/usr/share/icons/hicolor/1024x1024/apps/
# Mettre à jour le fichier .desktop pour pointer vers /opt/zed
# Update .desktop file to point to /opt/zed
@sed -i 's|Exec=.*|Exec=/opt/zed/bin/zed %U|g' $(DEB_DIR)/usr/share/applications/zed.desktop
@sed -i 's|Icon=.*|Icon=zed|g' $(DEB_DIR)/usr/share/applications/zed.desktop
# Créer le fichier de contrôle
# Create control file
@echo "Package: $(PACKAGE_NAME)" > $(CONTROL_DIR)/control
@echo "Version: $(VERSION)" >> $(CONTROL_DIR)/control
@echo "Section: editors" >> $(CONTROL_DIR)/control
@@ -95,21 +95,21 @@ $(DEB_FILE): $(EXTRACT_DIR)/.extracted
@echo " high-performance collaboration with humans and AI." >> $(CONTROL_DIR)/control
@echo "Homepage: https://zed.dev" >> $(CONTROL_DIR)/control
# Définir les permissions
# Set permissions
@chmod 755 $(DEB_DIR)/opt/zed/bin/zed
@chmod 755 $(DEB_DIR)/opt/zed/libexec/zed-editor
@find $(DEB_DIR)/opt/zed/lib -type f -name "*.so*" -exec chmod 644 {} \;
# Construire le paquet .deb
@echo "Création du paquet .deb..."
# Build the .deb package
@echo "Creating .deb package..."
@dpkg-deb --build $(DEB_DIR) $(DEB_FILE)
@echo ""
@echo "✓ Paquet créé avec succès: $(DEB_FILE)"
@echo "✓ Package successfully created: $(DEB_FILE)"
@echo ""
@echo "Pour installer: sudo dpkg -i $(DEB_FILE)"
@echo "To install: sudo dpkg -i $(DEB_FILE)"
# Nettoyer
# Clean up
clean:
@echo "Nettoyage..."
@echo "Cleaning up..."
@rm -rf $(BUILD_DIR)
@echo "Nettoyage terminé"
@echo "Cleanup complete"

122
README.md
View File

@@ -1,2 +1,122 @@
# zed-packager
# Zed Editor Packager
Automated packaging system for [Zed Editor](https://zed.dev/) for Debian/Ubuntu.
## Description
This project automatically creates `.deb` packages of Zed Editor from official GitHub releases and publishes them to a Gitea repository.
## Features
- **Automatic version detection**: Fetches the latest stable version from GitHub
- **DEB package building**: Creates a ready-to-install Debian package
- **CI/CD with Gitea Actions**: Automated workflow that:
- Checks daily for new versions
- Builds the package only if a new version is available
- Creates a Gitea release with the package
- Publishes the package to the Gitea Debian repository
## Local Usage
### Prerequisites
```bash
sudo apt-get install wget curl jq dpkg-dev
```
### Manual Building
```bash
# Build the package
make
# Or step by step
make download # Download the archive
make extract # Extract the archive
make deb # Create the .deb package
# Clean up
make clean
```
### Installation
```bash
# Install the locally created package
sudo dpkg -i build/zed-editor_*.deb
```
## Gitea Workflow
The [`.gitea/workflows/build-and-release.yml`](.gitea/workflows/build-and-release.yml) workflow runs:
- **Automatically**: Every day at 2 AM (cron)
- **Manually**: Via the Gitea interface (workflow_dispatch)
- **On push**: On every push to the `main` branch
### Required Configuration
To publish to the Gitea Debian repository, create a `PACKAGE_PUB_TOKEN` secret:
1. Generate a personal access token on Gitea with package permissions
2. Add it as a secret in the repository settings: `PACKAGE_PUB_TOKEN`
### Workflow Behavior
1. **Version check**: Compares the latest GitHub version with the latest Gitea release
2. **Early exit**: If versions match, the workflow stops immediately
3. **Build**: If a new version is detected, builds the .deb package
4. **Publishing**:
- Creates a Gitea release with the version tag
- Uploads the .deb file to the release assets
- Publishes the package to the Gitea Debian repository
## Package Structure
The package installs Zed in the following locations:
```
/opt/zed/ # Main application
/opt/zed/bin/zed # Main binary
/opt/zed/libexec/zed-editor # Editor binary
/opt/zed/lib/ # Shared libraries
/usr/bin/zed # Symbolic link
/usr/share/applications/zed.desktop # Desktop file
/usr/share/icons/hicolor/*/apps/zed.png # Icons
```
## Installation from Gitea Repository
Once the repository is configured:
```bash
# Add the repository (adapt according to your Gitea instance)
echo "deb https://git.rawleenc.dev/api/packages/YOUR_USERNAME/debian stable main" | sudo tee /etc/apt/sources.list.d/zed-editor.list
# Install
sudo apt update
sudo apt install zed-editor
```
## Makefile
The Makefile supports the following targets:
| Target | Description |
|------------|---------------------------------------------|
| `all` | Build the complete package (default target) |
| `download` | Download the archive from GitHub |
| `extract` | Extract the archive |
| `deb` | Create the .deb package |
| `clean` | Clean up temporary files |
| `help` | Display help |
## License
This project is a packaging tool. Zed Editor itself is subject to its own license.
## Notes
- The created packages are **unofficial**
- Binaries come directly from official Zed releases
- The packaging only adds system integration (desktop files, etc.)