Skip to content

Build & Release Plugin #10

Build & Release Plugin

Build & Release Plugin #10

Workflow file for this run

# .github/workflows/build.yml
# CI/CD pipeline for Compose Manager plugin
#
# This workflow automates the release process:
# - Builds TXZ package using Docker (Slackware)
# - Calculates MD5 for integrity verification
# - Creates GitHub releases with package attached
# - Updates PLG file in dev branch
#
# Triggers:
# - New tag matching date pattern: vYYYY.MM.DD[a-z]
# - Manual workflow_dispatch for testing builds
name: Build & Release Plugin
on:
push:
tags:
- 'v20[0-9][0-9].[0-9][0-9].[0-9][0-9]*'
workflow_dispatch:
inputs:
version:
description: 'Version to build (e.g., 2026.02.01) - leave empty for test build'
required: false
default: ''
permissions:
contents: write
env:
PLUGIN_NAME: compose.manager
COMPOSE_VERSION: '2.40.3'
COMPOSE_SWITCH_VERSION: '1.0.5'
ACE_VERSION: '1.4.14'
jobs:
build:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.VERSION }}
md5: ${{ steps.hash.outputs.MD5 }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Determine version
id: version
run: |
if [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" == refs/tags/v* ]]; then
# Release tag - extract version (remove 'v' prefix)
VERSION="${GITHUB_REF#refs/tags/v}"
elif [[ -n "${{ github.event.inputs.version }}" ]]; then
# Manual input
VERSION="${{ github.event.inputs.version }}"
else
# Test build - use date + git SHA
VERSION="$(date +%Y.%m.%d)-dev.$(git rev-parse --short HEAD)"
fi
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
echo "Building version: ${VERSION}"
- name: Build TXZ package in Docker
run: |
VERSION="${{ steps.version.outputs.VERSION }}"
# Set executable permissions
chmod +x ./build_in_docker.sh
chmod +x ./source/pkg_build.sh
# Build using the Slackware Docker container
docker run --rm --tmpfs /tmp \
-v $PWD/archive:/mnt/output:rw \
-v $PWD/source:/mnt/source:ro \
-e TZ="America/New_York" \
-e COMPOSE_VERSION=${{ env.COMPOSE_VERSION }} \
-e COMPOSE_SWITCH_VERSION=${{ env.COMPOSE_SWITCH_VERSION }} \
-e ACE_VERSION=${{ env.ACE_VERSION }} \
-e OUTPUT_FOLDER="/mnt/output" \
-e PKG_VERSION="${VERSION}" \
vbatts/slackware:latest /mnt/source/pkg_build.sh
# Verify package was created
ls -la ./archive/
if [[ ! -f "./archive/${{ env.PLUGIN_NAME }}-package-${VERSION}.txz" ]]; then
echo "ERROR: Package not found!"
exit 1
fi
- name: Calculate hash
id: hash
run: |
VERSION="${{ steps.version.outputs.VERSION }}"
PACKAGE="./archive/${{ env.PLUGIN_NAME }}-package-${VERSION}.txz"
MD5=$(md5sum "$PACKAGE" | cut -d' ' -f1)
echo "MD5=${MD5}" >> $GITHUB_OUTPUT
echo "Package MD5: ${MD5}"
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: plugin-package
path: |
archive/*.txz
archive/release_info
retention-days: 30
release:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: main
token: ${{ secrets.GITHUB_TOKEN }}
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: plugin-package
path: artifacts/
- name: Prepare release notes
id: notes
run: |
VERSION="${{ needs.build.outputs.version }}"
# Read component versions from release_info
if [[ -f artifacts/release_info ]]; then
COMPONENTS=$(cat artifacts/release_info)
else
COMPONENTS="Compose v${{ env.COMPOSE_VERSION }}"
fi
# Create release body
cat > release_body.md << EOF
## Compose Manager v${VERSION}
### Installation
**Via Plugin Manager:**
\`\`\`
https://raw.githubusercontent.com/${{ github.repository }}/main/${{ env.PLUGIN_NAME }}.plg
\`\`\`
### Package Details
- **MD5:** \`${{ needs.build.outputs.md5 }}\`
### Components
${COMPONENTS}
EOF
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
name: "Compose Manager v${{ needs.build.outputs.version }}"
body_path: release_body.md
files: |
artifacts/*.txz
fail_on_unmatched_files: true
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update PLG in main branch
run: |
VERSION="${{ needs.build.outputs.version }}"
MD5="${{ needs.build.outputs.md5 }}"
# Configure git
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Update version and MD5 in PLG
sed -i \
-e "s|<!ENTITY version.*\".*\"|<!ENTITY version \"${VERSION}\"|" \
-e "s|<!ENTITY packageMD5.*\".*\"|<!ENTITY packageMD5 \"${MD5}\"|" \
${{ env.PLUGIN_NAME }}.plg
echo "Updated PLG file:"
head -20 ${{ env.PLUGIN_NAME }}.plg
# Commit and push
git add ${{ env.PLUGIN_NAME }}.plg
git commit -m "Release v${VERSION}" || echo "No changes to commit"
git push origin main