From 2c2594d76fad7adc0b3fe5929efa4eb6a82b11f0 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Thu, 27 Mar 2025 14:43:56 -0500 Subject: [PATCH] chore: finish workflows for consoles --- .github/workflows/console_pull_request.yml | 57 ++++++++++++++ .github/workflows/publish_console.yml | 91 ++++++++++++++++++++++ .gitignore | 6 ++ src/AltGen.Console/Generated/Constants.cs | 2 +- 4 files changed, 155 insertions(+), 1 deletion(-) diff --git a/.github/workflows/console_pull_request.yml b/.github/workflows/console_pull_request.yml index 240d1fb..89fe433 100644 --- a/.github/workflows/console_pull_request.yml +++ b/.github/workflows/console_pull_request.yml @@ -1 +1,58 @@ name: Console Pull Request +defaults: + run: + working-directory: ./src +on: + workflow_dispatch: + pull_request: + paths: + - src/AltGen.Console/** + - src/AltGen.Console.Tests/** + branches: + - main +jobs: + format: + name: Run dotnet format + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 9.x.x + - name: Format projects + run: | + dotnet format ./AltGen.Console/AltGen.Console.csproj --verbosity normal + dotnet format ./AltGen.Console.Tests/AltGen.Console.Tests.csproj --verbosity normal + - name: Commit Changes + run: | + git config user.name "GitHub Actions" + git config user.email "<>" + if [[ $(git status --porcelain) ]]; then + git add . + git commit -m "chore: format fixes [skip ci]" + git fetch origin + git pull --rebase origin ${{ github.head_ref }} + git push origin HEAD:${{ github.head_ref }} + fi + build_and_test: + name: Run tests + needs: format + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 9.x.x + - name: Restore dependencies + run: dotnet restore ./AltGen.Console.Tests/AltGen.Console.Tests.csproj + - name: Build project + run: dotnet build ./AltGen.Console.Tests/AltGen.Console.Tests.csproj --no-restore + - name: Test project + run: dotnet test ./AltGen.Console.Tests/AltGen.Console.Tests.csproj + diff --git a/.github/workflows/publish_console.yml b/.github/workflows/publish_console.yml index ed1af98..34afcd6 100644 --- a/.github/workflows/publish_console.yml +++ b/.github/workflows/publish_console.yml @@ -1 +1,92 @@ name: Publish Console +on: + workflow_dispatch: + push: + paths: + - src/AltGen.Console/** + - src/AltGen.Console.Tests/** + branches: + - main +jobs: + version: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.ACTIONS_PAT }} + - name: Setup .NET 9 + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 9.x + - name: Install versionize + run: dotnet tool install --global Versionize + - name: Setup git + run: | + git config --local user.email "65925598+StevanFreeborn@users.noreply.github.com" + git config --local user.name "Stevan Freeborn" + - name: Run versionize + id: versionize + run: versionize -i --exit-insignificant-commits --workingDir ./src/AltGen.Console --commit-suffix "[skip ci]" + continue-on-error: true + - name: Upload changelog + if: steps.versionize.outcome == 'success' + uses: actions/upload-artifact@v4 + with: + name: change-log + path: src/BGR.Console/CHANGELOG.md + - name: Push changes to GitHub + if: steps.versionize.outcome == 'success' + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.ACTIONS_PAT }} + branch: ${{ github.ref }} + tags: true + outputs: + is_new_version: ${{ steps.versionize.outcome == 'success' }} + publish: + needs: [version] + if: needs.version.outputs.is_new_version == 'true' + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: ${{ github.ref }} + token: ${{ secrets.ACTIONS_PAT }} + - name: Setup .NET 9 + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 9.x + - name: Build + run: dotnet build src + - name: Publish for mac-os + run: dotnet publish src/AltGen.Console/AltGen.Console.csproj -c Release -r osx-x64 --self-contained -o dist/mac-os -p:AltGenApiUri=${{ secrets.ALTGEN_API_URI }} + - name: Publish for linux-os + run: dotnet publish src/AltGen.Console/AltGen.Console.csproj -c Release -r linux-x64 --self-contained -o dist/linux-os -p:AltGenApiUri=${{ secrets.ALTGEN_API_URI }} + - name: Publish for windows-os + run: dotnet publish src/AltGen.Console/AltGen.Console.csproj -c Release -r win-x64 --self-contained -o dist/windows-os -p:AltGenApiUri=${{ secrets.ALTGEN_API_URI }} + - name: Get project version + uses: kzrnm/get-net-sdk-project-versions-action@v1 + id: get-version + with: + proj-path: src/AltGen.Console/AltGen.Console.csproj + - name: Download changlog + uses: actions/download-artifact@v4 + with: + name: change-log + path: src/AltGen.Console + - name: Create release + uses: softprops/action-gh-release@v1 + with: + token: ${{ secrets.ACTIONS_PAT }} + name: bgr v${{ steps.get-version.outputs.version }} + tag_name: v${{ steps.get-version.outputs.version }} + draft: false + body_path: src/AltGen.Console/CHANGELOG.md + files: | + dist/mac-os/AltGen.Console + dist/linux-os/AltGen.Console + dist/windows-os/AltGen.Console.exe diff --git a/.gitignore b/.gitignore index fdb040a..d35eb32 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,12 @@ appsettings*.json !appsettings.Example.json +# generated +src/AltGen.Console/Generated/**/* + +# dist +dist/**/* + # dotenv files .env diff --git a/src/AltGen.Console/Generated/Constants.cs b/src/AltGen.Console/Generated/Constants.cs index 6066b7a..4d14333 100644 --- a/src/AltGen.Console/Generated/Constants.cs +++ b/src/AltGen.Console/Generated/Constants.cs @@ -3,4 +3,4 @@ namespace AltGen.Console.Generated; static class Constants { public const string AltGenApiUri = "https://localhost:7297"; -} +} \ No newline at end of file