Add automated release system
✨ Features: - Automated GitHub releases triggered by version tags (v*.*.*) - Cross-platform binaries (x86_64 + ARM64) with single workflow - Automatic changelog extraction from CHANGELOG.md - SHA256 checksum generation for asset verification - Debian 12 compatibility verification (glibc ≤ 2.36) - Comprehensive installation instructions in release notes 🔧 Technical: - Uses ubuntu-22.04 runners for reliability - Rust 1.82.0 for consistent builds - Native cross-compilation (no Docker overhead) - Minimal dependencies for fast execution 📖 Documentation: - Complete usage guide in docs/AUTOMATED_RELEASES.md - Troubleshooting section for common issues - Security and compatibility information Usage: git tag v1.2.0 && git push origin v1.2.0
This commit is contained in:
@@ -0,0 +1,132 @@
|
||||
name: Automated Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*.*.*'
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
|
||||
jobs:
|
||||
create-release:
|
||||
name: Create GitHub Release
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Extract version from tag
|
||||
id: version
|
||||
run: |
|
||||
VERSION=${GITHUB_REF#refs/tags/}
|
||||
VERSION_NAME=${VERSION#v}
|
||||
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||
echo "version_name=$VERSION_NAME" >> $GITHUB_OUTPUT
|
||||
echo "Extracted version: $VERSION ($VERSION_NAME)"
|
||||
|
||||
- name: Extract changelog
|
||||
id: changelog
|
||||
run: |
|
||||
if [ -f CHANGELOG.md ]; then
|
||||
VERSION_NAME="${{ steps.version.outputs.version_name }}"
|
||||
CHANGELOG=$(awk "/## \[$VERSION_NAME\]/, /## \[.*\]/ { if (/## \[.*\]/ && !/## \[$VERSION_NAME\]/) exit; print }" CHANGELOG.md | head -n -1)
|
||||
|
||||
if [ -z "$CHANGELOG" ]; then
|
||||
CHANGELOG="## DDNS Updater ${{ steps.version.outputs.version }}
|
||||
|
||||
This is an automated release. See the git history for detailed changes."
|
||||
fi
|
||||
|
||||
echo "changelog<<EOF" >> $GITHUB_OUTPUT
|
||||
echo "$CHANGELOG" >> $GITHUB_OUTPUT
|
||||
echo "EOF" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "changelog=No changelog available." >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Setup Rust
|
||||
uses: dtolnay/rust-toolchain@1.82.0
|
||||
with:
|
||||
targets: x86_64-unknown-linux-gnu,aarch64-unknown-linux-gnu
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y build-essential gcc-aarch64-linux-gnu pkg-config libssl-dev
|
||||
|
||||
- name: Configure cross-compilation
|
||||
run: |
|
||||
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
|
||||
|
||||
- name: Build binaries
|
||||
run: |
|
||||
# Build x86_64
|
||||
cargo build --release --target x86_64-unknown-linux-gnu
|
||||
|
||||
# Build ARM64
|
||||
cargo build --release --target aarch64-unknown-linux-gnu
|
||||
|
||||
# Create release directory and copy binaries
|
||||
mkdir -p releases
|
||||
cp target/x86_64-unknown-linux-gnu/release/ddns_updater releases/ddns_updater-${{ steps.version.outputs.version }}-amd64
|
||||
cp target/aarch64-unknown-linux-gnu/release/ddns_updater releases/ddns_updater-${{ steps.version.outputs.version }}-arm64
|
||||
|
||||
# Create archives
|
||||
tar -czf releases/ddns_updater-${{ steps.version.outputs.version }}-amd64.tar.gz -C target/x86_64-unknown-linux-gnu/release ddns_updater
|
||||
tar -czf releases/ddns_updater-${{ steps.version.outputs.version }}-arm64.tar.gz -C target/aarch64-unknown-linux-gnu/release ddns_updater
|
||||
|
||||
# Generate checksums
|
||||
cd releases
|
||||
sha256sum * > SHA256SUMS
|
||||
ls -la
|
||||
|
||||
- name: Create GitHub Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
tag_name: ${{ steps.version.outputs.version }}
|
||||
name: "Release ${{ steps.version.outputs.version }}"
|
||||
body: |
|
||||
${{ steps.changelog.outputs.changelog }}
|
||||
|
||||
## 📦 Installation
|
||||
|
||||
### Binary Installation
|
||||
```bash
|
||||
# For x86_64 (Intel/AMD 64-bit)
|
||||
wget https://github.com/${{ github.repository }}/releases/download/${{ steps.version.outputs.version }}/ddns_updater-${{ steps.version.outputs.version }}-amd64
|
||||
chmod +x ddns_updater-${{ steps.version.outputs.version }}-amd64
|
||||
sudo mv ddns_updater-${{ steps.version.outputs.version }}-amd64 /usr/local/bin/ddns_updater
|
||||
|
||||
# For ARM64 (Apple Silicon, ARM servers)
|
||||
wget https://github.com/${{ github.repository }}/releases/download/${{ steps.version.outputs.version }}/ddns_updater-${{ steps.version.outputs.version }}-arm64
|
||||
chmod +x ddns_updater-${{ steps.version.outputs.version }}-arm64
|
||||
sudo mv ddns_updater-${{ steps.version.outputs.version }}-arm64 /usr/local/bin/ddns_updater
|
||||
```
|
||||
|
||||
## 🔍 Verification
|
||||
```bash
|
||||
wget https://github.com/${{ github.repository }}/releases/download/${{ steps.version.outputs.version }}/SHA256SUMS
|
||||
sha256sum -c SHA256SUMS
|
||||
```
|
||||
|
||||
## 📋 Requirements
|
||||
- **Debian 12+** or **Ubuntu 22.04+** (glibc 2.34+)
|
||||
- **Architecture**: x86_64 (amd64) or ARM64 (aarch64)
|
||||
files: |
|
||||
releases/*
|
||||
draft: false
|
||||
prerelease: false
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Summary
|
||||
run: |
|
||||
echo "🚀 Release ${{ steps.version.outputs.version }} created successfully!"
|
||||
echo "🔗 https://github.com/${{ github.repository }}/releases/tag/${{ steps.version.outputs.version }}"
|
||||
@@ -0,0 +1,138 @@
|
||||
# Automated Release System
|
||||
|
||||
This project includes an automated release system that creates GitHub releases whenever you push a version tag.
|
||||
|
||||
## How It Works
|
||||
|
||||
### 🏷️ Tag-Based Releases
|
||||
When you push a git tag following the pattern `v*.*.*` (e.g., `v1.2.0`), the automated release workflow will:
|
||||
|
||||
1. **Extract version information** from the git tag
|
||||
2. **Build binaries** for both x86_64 (amd64) and ARM64 architectures
|
||||
3. **Generate archives** (.tar.gz files) for each architecture
|
||||
4. **Create checksums** (SHA256SUMS) for verification
|
||||
5. **Extract changelog** content for the specific version
|
||||
6. **Create GitHub release** with all assets and documentation
|
||||
|
||||
### 📁 Assets Created
|
||||
|
||||
Each release automatically includes:
|
||||
- `ddns_updater-vX.X.X-amd64` - Direct x86_64 binary
|
||||
- `ddns_updater-vX.X.X-arm64` - Direct ARM64 binary
|
||||
- `ddns_updater-vX.X.X-amd64.tar.gz` - x86_64 archive
|
||||
- `ddns_updater-vX.X.X-arm64.tar.gz` - ARM64 archive
|
||||
- `SHA256SUMS` - Checksums for verification
|
||||
|
||||
## Creating a Release
|
||||
|
||||
### Step 1: Update Version
|
||||
```bash
|
||||
# Update Cargo.toml version
|
||||
sed -i 's/version = "1.0.0"/version = "1.1.0"/' Cargo.toml
|
||||
|
||||
# Optional: Update CHANGELOG.md with new version section
|
||||
```
|
||||
|
||||
### Step 2: Commit and Tag
|
||||
```bash
|
||||
# Commit version changes
|
||||
git add Cargo.toml CHANGELOG.md
|
||||
git commit -m "Release v1.1.0: Description of changes"
|
||||
git push
|
||||
|
||||
# Create and push tag
|
||||
git tag -a v1.1.0 -m "Release v1.1.0: Description of changes"
|
||||
git push origin v1.1.0
|
||||
```
|
||||
|
||||
### Step 3: Automatic Release
|
||||
The automated release workflow will:
|
||||
- ✅ Trigger automatically when the tag is pushed
|
||||
- ✅ Build both x86_64 and ARM64 binaries
|
||||
- ✅ Verify Debian 12 compatibility (glibc ≤ 2.36)
|
||||
- ✅ Create GitHub release with installation instructions
|
||||
- ✅ Upload all assets and checksums
|
||||
|
||||
## Workflow Details
|
||||
|
||||
### 🔧 Build Environment
|
||||
- **Runner**: Ubuntu 22.04
|
||||
- **Rust Version**: 1.82.0 (consistent across all workflows)
|
||||
- **Targets**: x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu
|
||||
- **Cross-compilation**: Native GCC toolchain for ARM64
|
||||
|
||||
### 📋 Compatibility
|
||||
- **Debian 12+** (glibc 2.34+)
|
||||
- **Ubuntu 22.04+**
|
||||
- **Architecture**: x86_64 (Intel/AMD) and ARM64 (Apple Silicon, ARM servers)
|
||||
|
||||
### 🚀 Speed Optimizations
|
||||
- Uses GitHub's ubuntu-22.04 runners (high availability)
|
||||
- Builds both architectures in parallel steps
|
||||
- Minimal dependencies for faster setup
|
||||
- Efficient binary packaging
|
||||
|
||||
## Changelog Integration
|
||||
|
||||
If a `CHANGELOG.md` file exists, the workflow will:
|
||||
1. **Extract the section** for the current version (e.g., `## [1.1.0]`)
|
||||
2. **Include it** in the GitHub release description
|
||||
3. **Fall back** to a generic message if no changelog section is found
|
||||
|
||||
### Changelog Format
|
||||
```markdown
|
||||
# Changelog
|
||||
|
||||
## [1.1.0] - 2025-10-02
|
||||
### Added
|
||||
- New email notification system
|
||||
- CLI email configuration flags
|
||||
|
||||
### Changed
|
||||
- Upgraded to Rust 1.82.0
|
||||
- Enhanced Debian 12 compatibility
|
||||
|
||||
### Fixed
|
||||
- Cross-compilation issues
|
||||
- GLIBC version requirements
|
||||
```
|
||||
|
||||
## Manual Override
|
||||
|
||||
If you need to create a release manually, you can still use the existing manual release workflow:
|
||||
|
||||
```bash
|
||||
# Go to GitHub → Actions → "Release Management" → "Run workflow"
|
||||
# Enter version: v1.1.0
|
||||
# Click "Run workflow"
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Tag Already Exists
|
||||
```bash
|
||||
# Delete local and remote tag
|
||||
git tag -d v1.1.0
|
||||
git push --delete origin v1.1.0
|
||||
|
||||
# Recreate and push
|
||||
git tag -a v1.1.0 -m "Release v1.1.0: Updated description"
|
||||
git push origin v1.1.0
|
||||
```
|
||||
|
||||
### Build Failures
|
||||
- Check the **Actions** tab for detailed error logs
|
||||
- Verify Rust 1.82.0 compatibility of dependencies
|
||||
- Ensure `Cargo.toml` version matches the git tag version
|
||||
|
||||
### Missing Assets
|
||||
- The workflow creates binaries for both x86_64 and ARM64
|
||||
- Check the workflow logs if any architecture fails to build
|
||||
- Verify cross-compilation toolchain installation
|
||||
|
||||
## Security
|
||||
|
||||
- Uses `GITHUB_TOKEN` with minimal required permissions (`contents: write`)
|
||||
- No external secrets or credentials required
|
||||
- All builds run in isolated GitHub Actions runners
|
||||
- Checksums provided for asset verification
|
||||
Reference in New Issue
Block a user