Skip to content

Build and Release

Build and Release #12

Workflow file for this run

name: Build and Release
on:
workflow_dispatch:
inputs:
version:
description: 'Version to build (e.g. 1.1.0)'
required: true
type: string
arch:
description: 'Architecture to build for'
required: true
default: 'All'
type: choice
options:
- All
- amd64
- aarch64
permissions:
contents: write
packages: write
jobs:
setup:
name: Setup Build Matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Set matrix
id: set-matrix
run: |
if [ "${{ github.event.inputs.arch }}" == "All" ]; then
echo 'matrix=["amd64", "aarch64"]' >> $GITHUB_OUTPUT
else
echo 'matrix=["${{ github.event.inputs.arch }}"]' >> $GITHUB_OUTPUT
fi
notify_workflow:
name: Notify Build Start
runs-on: ubuntu-latest
steps:
- name: Send Telegram Notification
run: |
curl -s -X POST "https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage" \
-F chat_id="${{ secrets.TELEGRAM_CHAT_ID }}" \
-F message_thread_id="${{ secrets.TELEGRAM_MESSAGE_THREAD_ID }}" \
-F text="
πŸš€ *Build started for Aesir!*
πŸ“¦ *Repository:* [${{ github.repository }}](https://github.com/${{ github.repository }})
πŸ—‚οΈ *Branch:* \`${{ github.ref_name }}\`
πŸ—οΈ *Version:* \`${{ github.event.inputs.version }}\`
πŸ–₯️ *Architectures:* \`${{ github.event.inputs.arch }}\`
✏️ *Commit:* [${{ github.sha }}](https://github.com/${{ github.repository }}/commit/${{ github.sha }})
[πŸ”— View GitHub Run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})" \
-F parse_mode="Markdown"
build-and-release:
name: Build and Release
runs-on: ubuntu-latest
needs: notify_workflow
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Make build script executable
run: chmod +x build.sh
- name: Build project
run: ./build.sh
- name: Verify build output amd64
if: github.event.inputs.arch == 'All' || github.event.inputs.arch == 'amd64'
run: |
if [ ! -f "bin/Release/net10.0/publish/linux-x64/Aesir" ]; then
echo "Build output not found for amd64!"
exit 1
fi
chmod +x bin/Release/net10.0/publish/linux-x64/Aesir
- name: Verify build output arm64
if: github.event.inputs.arch == 'All' || github.event.inputs.arch == 'aarch64'
run: |
if [ ! -f "bin/Release/net10.0/publish/linux-arm64/Aesir" ]; then
echo "Build output not found for arm64!"
exit 1
fi
chmod +x bin/Release/net10.0/publish/linux-arm64/Aesir
- name: Extract Latest Changelog
id: changelog
run: |
# Extract the section for the latest release (everything between the first and second '# [')
awk '/^# \[/ {if (p) exit; p=1; next} p' CHANGELOG.md > latest_changelog.txt
echo "CHANGELOG<<EOF" >> $GITHUB_OUTPUT
cat latest_changelog.txt >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create Release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create v${{ github.event.inputs.version }} \
--title "Aesir v${{ github.event.inputs.version }}" \
--notes "${{ steps.changelog.outputs.CHANGELOG }}" \
--target ${{ github.ref_name }}
- name: Prepare release assets
run: |
if [ -f "bin/Release/net10.0/publish/linux-x64/Aesir" ]; then
cp bin/Release/net10.0/publish/linux-x64/Aesir Aesir-linux-amd64
fi
if [ -f "bin/Release/net10.0/publish/linux-arm64/Aesir" ]; then
cp bin/Release/net10.0/publish/linux-arm64/Aesir Aesir-linux-aarch64
fi
- name: Upload release asset amd64
if: github.event.inputs.arch == 'All' || github.event.inputs.arch == 'amd64'
env:
GH_TOKEN: ${{ github.token }}
run: gh release upload v${{ github.event.inputs.version }} Aesir-linux-amd64 --clobber
- name: Upload release asset arm64
if: github.event.inputs.arch == 'All' || github.event.inputs.arch == 'aarch64'
env:
GH_TOKEN: ${{ github.token }}
run: gh release upload v${{ github.event.inputs.version }} Aesir-linux-aarch64 --clobber
notify_completion:
name: Notify Build Completion
needs: [setup, build-and-release, notify_workflow]
runs-on: ubuntu-latest
if: always() && (needs.build-and-release.result != 'cancelled')
steps:
- name: Determine build results
id: results
run: |
# Check the overall result of the build-and-release job
if [ "${{ needs.build-and-release.result }}" == "success" ]; then
echo "status=βœ… Build & Release completed successfully!" >> $GITHUB_OUTPUT
echo "emoji=πŸŽ‰" >> $GITHUB_OUTPUT
else
echo "status=❌ Build & Release failed!" >> $GITHUB_OUTPUT
echo "emoji=πŸ’₯" >> $GITHUB_OUTPUT
fi
- name: Send Telegram Completion Notification
run: |
DATE=$(date +'%Y-%m-%d')
curl -s -X POST "https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage" \
-F chat_id="${{ secrets.TELEGRAM_CHAT_ID }}" \
-F message_thread_id="${{ secrets.TELEGRAM_MESSAGE_THREAD_ID }}" \
-F text="
${{ steps.results.outputs.emoji }} *Aesir Workflow Finished*
πŸ“¦ *Repository:* [${{ github.repository }}](https://github.com/${{ github.repository }})
πŸ“… *Date:* $DATE
🏷️ *Version:* \`v${{ github.event.inputs.version }}\`
πŸ“‹ *Status:* ${{ steps.results.outputs.status }}
πŸ’Ύ *Download releases:* [GitHub Releases](https://github.com/${{ github.repository }}/releases/tag/v${{ github.event.inputs.version }})
[πŸ”— View GitHub Run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})" \
-F parse_mode="Markdown"