Forgot a setting #254
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]') | |
uses: ./.github/workflows/tag-creation.yml | |
build: | |
name: Build RELEASE for ${{ matrix.os }} - ${{ matrix.arch }} | |
needs: check_for_tag | |
if: ${{ needs.check_for_tag.outputs.tag_created }} == "true" | |
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 8.0.x | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: '8.0.x' | |
- name: Install GitHub CLI | |
run: sudo apt-get update && sudo apt-get install -y gh | |
- name: Publish Release | |
run: | | |
dotnet publish -c Release -r ${{ matrix.os }}-${{ matrix.arch }} | |
- name: Download and extract Lavalink | |
run: | | |
mkdir -p ./artifacts/publish/AzzyBot/release_${{ matrix.os }}-${{ matrix.arch }}/Modules/MusicStreaming/Files/plugins | |
gh release download 4.0.4 --dir './artifacts/publish/AzzyBot/release_${{ matrix.os }}-${{ matrix.arch }}/Modules/MusicStreaming/Files' --pattern 'Lavalink.jar' --repo lavalink-devs/Lavalink | |
wget -qO ./artifacts/publish/AzzyBot/release_${{ matrix.os }}-${{ matrix.arch }}/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: Calculate Lines of Source Code | |
id: loc_cs | |
uses: PavanMudigonda/lines-of-code-reporter@v1.6 | |
with: | |
exclude_dir: "AzzyBot" | |
include_lang: "C#,MSBuild script" | |
- name: Get Date and Time | |
id: dateTime | |
uses: Kaven-Universe/github-action-current-date-time@v1 | |
with: | |
format: "YYYY-MM-DDTHH:mm:ss" | |
- name: Add some basic information | |
run: | | |
sed -i 's\Commit not found\${{ github.sha }}\g' ./artifacts/publish/AzzyBot/release_${{ matrix.os }}-${{ matrix.arch }}/Modules/Core/Files/AzzyBot.json | |
sed -i 's\Compilation date not found\${{ steps.dateTime.outputs.time }}\g' ./artifacts/publish/AzzyBot/release_${{ matrix.os }}-${{ matrix.arch }}/Modules/Core/Files/AzzyBot.json | |
sed -i 's\Lines of source code not found\${{ steps.loc_cs.outputs.total_lines }}\g' ./artifacts/publish/AzzyBot/release_${{ matrix.os }}-${{ matrix.arch }}/Modules/Core/Files/AzzyBot.json | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Archive Build Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: release-${{ matrix.os }}-${{ matrix.arch }} | |
path: ./artifacts/publish/AzzyBot/release_${{ matrix.os }}-${{ matrix.arch }} | |
build-docker: | |
name: Build docker .zip file | |
if: contains(github.event.head_commit.message, '[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 ./CHANGELOG.md ./docker-zip/CHANGELOG.md | |
mv ./CHANGELOG_HISTORY.md ./docker-zip/CHANGELOG_HISTORY.md | |
mv ./docker-compose.dev.yml ./docker-zip/docker-compose.dev.yml | |
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/Customization | |
mv ./AzzyBot/Customization/* ./docker-zip/AzzyBot/Customization | |
mkdir -p ./docker-zip/AzzyBot/Modules/AzuraCast/Files | |
mv ./AzzyBot/Modules/AzuraCast/Files/* ./docker-zip/AzzyBot/Modules/AzuraCast/Files | |
mkdir -p ./docker-zip/AzzyBot/Modules/MusicStreaming/Files/plugins | |
mv ./AzzyBot/Modules/MusicStreaming/Files/application.yml ./docker-zip/AzzyBot/Modules/MusicStreaming/Files/application.yml | |
mv ./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 ./AzzyBot/Settings/appsettings.json ./docker-zip/AzzyBot/Settings/appsettings.json | |
- name: Archive docker-zip artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: release-docker | |
path: ./docker-zip | |
extract_version: | |
name: Get Release Version | |
needs: check_for_tag | |
runs-on: ubuntu-latest | |
outputs: | |
clean_version: ${{ steps.set-version.outputs.clean_version }} | |
version: ${{ steps.set-version.outputs.version }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Get version from csproj | |
uses: kzrnm/get-net-sdk-project-versions-action@v2 | |
id: get-version | |
with: | |
proj-path: AzzyBot/AzzyBot.csproj | |
- name: Set version | |
id: set-version | |
run: | | |
echo "version=v${{ steps.get-version.outputs.version }}" >> "$GITHUB_OUTPUT" | |
echo "clean_version=${{ steps.get-version.outputs.version }}" >> "$GITHUB_OUTPUT" | |
create_release: | |
name: Create GitHub Release | |
needs: [build, extract_version] | |
runs-on: ubuntu-latest | |
outputs: | |
release_version: ${{ steps.set_output.outputs.release_version }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Create Release | |
id: create_release_action | |
uses: softprops/action-gh-release@v2 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ needs.extract_version.outputs.version }} | |
name: ${{ needs.extract_version.outputs.clean_version }} | |
body_path: CHANGELOG.md | |
draft: false | |
prerelease: false | |
- name: Set Release Version Output | |
id: set_output | |
run: | | |
echo "release_version=${{ needs.extract_version.outputs.version }}" >> "$GITHUB_OUTPUT" | |
upload_assets: | |
name: Upload GitHub Release Assets | |
needs: [create_release, build] | |
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" --repo ${{ github.repository }} | |
done | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |