Skip to content

[release] 2.2.4

[release] 2.2.4 #563

name: Automated .NET Release
on:
push:
branches:
- "main"
- "rel/**"
tags:
- "**"
workflow_dispatch:
jobs:
check_for_tag:
name: Check if tag has to be created
if: ${{ contains(github.event.head_commit.message, '[release]') || contains(github.event.head_commit.message, '[pre-release]') }}
uses: ./.github/workflows/tag-creation.yml
extract_meta:
name: Extract metadata for use
if: ${{ contains(github.event.head_commit.message, '[release]') || contains(github.event.head_commit.message, '[pre-release]') }}
runs-on: ubuntu-latest
outputs:
loc_cs: ${{ steps.loc_cs.outputs.total_lines }}
changelog: ${{ steps.changelog.outputs.changelog }}
datetime: ${{ steps.dateTime.outputs.time }}
clean_version: ${{ steps.get-version.outputs.clean_version }}
version: ${{ steps.get-version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Calculate Lines of Source Code
id: loc_cs
uses: PavanMudigonda/lines-of-code-reporter@v1.6
with:
include_lang: "C#,MSBuild script"
- name: Get correct changelog
id: changelog
run: |
if ${{ contains(github.event.head_commit.message, '[pre-release]') }}; then
echo "changelog=CHANGELOG.previews.md" >> "$GITHUB_OUTPUT"
else
echo "changelog=CHANGELOG.md" >> "$GITHUB_OUTPUT"
fi
- name: Get Date and Time
id: dateTime
uses: Kaven-Universe/github-action-current-date-time@v1
with:
format: "YYYY-MM-DDTHH:mm:ss"
- name: Get version from Directory.Build.props
id: get-version
run: |
VERSION=$(grep -oP '(?<=<Version>).*?(?=</Version>)' Directory.Build.props)
echo "version=v$VERSION" >> "$GITHUB_OUTPUT"
echo "clean_version=$VERSION" >> "$GITHUB_OUTPUT"
# build:
# name: Build RELEASE for ${{ matrix.os }} - ${{ matrix.arch }}
# needs: [check_for_tag, extract_meta]
# if: ${{ needs.check_for_tag.outputs.tag_created == 'true' && contains(github.event.head_commit.message, '[release]') }}
# runs-on: ubuntu-latest
# strategy:
# matrix:
# include:
# - os: linux
# arch: x64
# - os: linux
# arch: arm64
# - os: win
# arch: x64
# - os: win
# arch: arm64
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# - name: Setup .NET 9
# uses: actions/setup-dotnet@v4
# with:
# dotnet-version: '9'
# - name: Install GitHub CLI
# run: sudo apt-get update && sudo apt-get install -y gh
# - name: Restore, Build And Publish
# run: |
# dotnet restore /home/runner/work/AzzyBot/AzzyBot/src/AzzyBot.Bot/AzzyBot.Bot.csproj --configfile ./Nuget.config --force --no-cache --ucr
# dotnet build /home/runner/work/AzzyBot/AzzyBot/src/AzzyBot.Bot/AzzyBot.Bot.csproj -c Release --no-incremental --no-restore --no-self-contained --ucr
# dotnet publish /home/runner/work/AzzyBot/AzzyBot/src/AzzyBot.Bot/AzzyBot.Bot.csproj -c Release --no-build --no-restore --no-self-contained --ucr
# #- name: Download and extract Lavalink
# # run: |
# # mkdir -p ./artifacts/publish/AzzyBot/release/Modules/MusicStreaming/Files/plugins
# # gh release download 4.0.4 --dir './artifacts/publish/AzzyBot/release/Modules/MusicStreaming/Files' --pattern 'Lavalink.jar' --repo lavalink-devs/Lavalink
# # wget -qO ./artifacts/publish/AzzyBot/release/Modules/MusicStreaming/Files/plugins/java-lyrics-plugin-1.6.4.jar https://maven.lavalink.dev/releases/me/duncte123/java-lyrics-plugin/1.6.4/java-lyrics-plugin-1.6.4.jar
# # env:
# # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# - name: Add some basic information
# run: |
# sed -i 's\Commit not found\${{ github.sha }}\g' ./artifacts/publish/AzzyBot.Bot/release/Modules/Core/Files/AppStats.json
# sed -i 's\Compilation date not found\${{ needs.extract_meta.outputs.datetime }}\g' ./artifacts/publish/AzzyBot.Bot/release/Modules/Core/Files/AppStats.json
# sed -i 's\Lines of source code not found\${{ needs.extract_meta.outputs.loc_cs }}\g' ./artifacts/publish/AzzyBot.Bot/release/Modules/Core/Files/AppStats.json
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# - name: Archive Bot Build Artifact
# uses: actions/upload-artifact@v4
# with:
# name: release-bot-${{ matrix.os }}-${{ matrix.arch }}
# path: ./artifacts/publish/AzzyBot.Bot/release
build-docker:
name: Build docker .zip file
needs: extract_meta
if: ${{ contains(github.event.head_commit.message, '[release]') || contains(github.event.head_commit.message, '[pre-release]') }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Getting all files together
run: |
mkdir docker-zip
mv ./${{ needs.extract_meta.outputs.changelog }} ./docker-zip/CHANGELOG.md
mv ./docker-compose.yml ./docker-zip/docker-compose.yml
mv ./LICENSE ./docker-zip/LICENSE
mv ./README.md ./docker-zip/README.md
mv ./SECURITY.md ./docker-zip/SECURITY.md
mkdir -p ./docker-zip/AzzyBot/Logs
mkdir -p ./docker-zip/AzzyBot/Modules/AzuraCast/Files
mkdir -p ./docker-zip/AzzyBot/Modules/MusicStreaming/Files
mv ./src/AzzyBot.Bot/Modules/MusicStreaming/Files/application.yml ./docker-zip/AzzyBot/Modules/MusicStreaming/Files/application.yml
#mv ./src/AzzyBot/Modules/MusicStreaming/Files/docker-compose.yml ./docker-zip/AzzyBot/Modules/MusicStreaming/Files/docker-compose.yml
#wget -qO ./docker-zip/AzzyBot/Modules/MusicStreaming/Files/plugins/java-lyrics-plugin-1.6.4.jar https://maven.lavalink.dev/releases/me/duncte123/java-lyrics-plugin/1.6.4/java-lyrics-plugin-1.6.4.jar
mkdir -p ./docker-zip/AzzyBot/Settings
mv ./src/AzzyBot.Bot/Settings/AzzyBotSettings-Docker.json ./docker-zip/AzzyBot/Settings/AzzyBotSettings-Docker.json
- name: Archive docker-zip artifact
uses: actions/upload-artifact@v4
with:
name: ${{ needs.extract_meta.outputs.clean_version }}-docker
path: ./docker-zip
create_release:
name: Create GitHub Release
needs: [extract_meta, build-docker]
runs-on: ubuntu-latest
outputs:
release_version: ${{ steps.set_output.outputs.release_version }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Extract Latest Changelog Entry
id: extract_changelog
run: |
# Extract the latest changelog entry from the changelog file
latest_entry=$(awk 'BEGIN {found=0} /^## / {if (found) exit; found=1} {if (found) print}' ${{ needs.extract_meta.outputs.changelog }})
echo "$latest_entry" > latest_changelog.md
# Extract title for release
release_title=$(echo "$latest_entry" | awk 'NR==2')
# Ensure safe output handling for multiline strings
echo "latest_entry<<EOF" >> "$GITHUB_OUTPUT"
echo "$latest_entry" >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
echo "release_title=$release_title" >> "$GITHUB_ENV"
- name: Create Release
id: create_release_action
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.extract_meta.outputs.version }}
name: ${{ needs.extract_meta.outputs.clean_version }}
body_path: latest_changelog.md
prerelease: ${{ contains(github.event.head_commit.message, '[pre-release]') }}
- name: Set Release Version Output
id: set_output
run: |
echo "release_version=${{ needs.extract_meta.outputs.version }}" >> "$GITHUB_OUTPUT"
upload_assets:
name: Upload GitHub Release Assets
needs: [build-docker, create_release]
runs-on: ubuntu-latest
steps:
- name: Install GitHub CLI
run: sudo apt-get update && sudo apt-get install -y gh
- name: Download and Upload All Artifacts
run: |
# Fetch a list of all artifact details for the current workflow run
ARTIFACTS_JSON=$(gh api /repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts)
# Ensure the command above is successful and returns valid JSON before proceeding
# Iterate over each artifact to download and upload it
echo "$ARTIFACTS_JSON" | jq -c '.artifacts[]' | while read -r artifact; do
ARTIFACT_NAME=$(echo "$artifact" | jq -r '.name')
ARTIFACT_DOWNLOAD_URL=$(echo "$artifact" | jq -r '.archive_download_url')
# Download the artifact
curl -L -o "${ARTIFACT_NAME}.zip" -H "Authorization: token $GITHUB_TOKEN" "$ARTIFACT_DOWNLOAD_URL"
# Upload the artifact to the release
gh release upload ${{ needs.create_release.outputs.release_version }} "${ARTIFACT_NAME}.zip" --clobber --repo ${{ github.repository }}
done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}