95 lines
2.8 KiB
YAML
95 lines
2.8 KiB
YAML
name: Build and Release
|
|
|
|
# Triggered when debian/changelog changes on main — meaning version-bump.yml
|
|
# just committed a new version. Builds the .deb and publishes a GitHub Release.
|
|
# The actor guard ensures this only fires for the bot's changelog commit.
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- 'debian/changelog'
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
release:
|
|
runs-on: ubuntu-latest
|
|
if: github.actor == 'github-actions[bot]'
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Extract version from changelog
|
|
id: version
|
|
run: |
|
|
VERSION=$(grep -m1 '(' debian/changelog | sed 's/.*(\(.*\)).*/\1/')
|
|
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
|
echo "tag=v$VERSION" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Install build dependencies
|
|
run: |
|
|
sudo apt-get update -qq
|
|
sudo apt-get install -y debhelper dpkg-dev
|
|
|
|
- name: Inject version into Config.pm
|
|
env:
|
|
BUILD_VERSION: ${{ steps.version.outputs.version }}
|
|
run: |
|
|
perl -i -pe 'BEGIN { $v = $ENV{BUILD_VERSION} }
|
|
s/(our \$VERSION\s*=\s*'"'"')[^'"'"']*'"'"';/$1'"'"'$v'"'"';/
|
|
' src/node_info/files/Config.pm
|
|
|
|
- name: Generate dynamic debian rules
|
|
run: |
|
|
bash src/gen-rules.sh >> debian/rules
|
|
bash src/gen-rules.sh conffiles >> debian/pve-mod.conffiles
|
|
|
|
- name: Build deb package
|
|
run: |
|
|
dpkg-buildpackage -us -uc -b
|
|
ls -lh ../pve-mod_*.deb
|
|
|
|
- name: Extract release notes from changelog
|
|
id: notes
|
|
run: |
|
|
awk '
|
|
/^pve-mod \(/ { if (found) exit; found=1; next }
|
|
found && /^ --/ { exit }
|
|
found { print }
|
|
' debian/changelog | grep '^\s*\*' | sed 's/^\s*\* /- /' > /tmp/notes.md
|
|
[[ -s /tmp/notes.md ]] || echo "- Automated release." > /tmp/notes.md
|
|
|
|
- name: Create Git tag
|
|
env:
|
|
TAG: ${{ steps.version.outputs.tag }}
|
|
run: |
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
git tag "$TAG"
|
|
git push origin "$TAG"
|
|
|
|
- name: Collect release assets
|
|
id: assets
|
|
run: |
|
|
DEB=$(ls ../pve-mod_*.deb)
|
|
echo "deb=$DEB" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Create GitHub Release
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
TAG: ${{ steps.version.outputs.tag }}
|
|
DEB: ${{ steps.assets.outputs.deb }}
|
|
run: |
|
|
ASSETS="$DEB"
|
|
[[ -f install.sh ]] && ASSETS="$ASSETS install.sh"
|
|
|
|
gh release create "$TAG" \
|
|
--title "pve-mod $TAG" \
|
|
--notes-file /tmp/notes.md \
|
|
$ASSETS |