Build & Release #11
This file contains hidden or 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 of the workflow | |
| name: Build & Release | |
| # Controls when the workflow will run | |
| on: | |
| # Allows you to run this workflow manually from the Actions tab | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Tag / version (e.g. v1.2.3)' | |
| required: true | |
| type: string | |
| # Sets permissions for the GITHUB_TOKEN for this workflow | |
| permissions: | |
| contents: write # Required for creating releases | |
| packages: read # Required for reading packages | |
| # A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
| jobs: | |
| #---------- BUILD ---------- | |
| # This job builds the application for various platforms | |
| build: | |
| # The type of runner that the job will run on | |
| runs-on: ${{ matrix.os }} | |
| # Set environment variable to disable locked mode for all dotnet commands in this job | |
| env: | |
| DOTNET_RESTORE_LOCKED_MODE: false | |
| strategy: | |
| # When set to false, a failure in one matrix job does not cancel others | |
| fail-fast: false | |
| # A matrix of configurations for this job | |
| matrix: | |
| include: | |
| # Desktop builds | |
| - os: windows-latest | |
| rid: win-x64 | |
| fw: net9.0-windows10.0.19041.0 | |
| art: win-x64 | |
| - os: macos-latest | |
| rid: osx-arm64 | |
| fw: net9.0-macos | |
| art: macos-arm64 | |
| steps: | |
| # Step 1: Checkout the main repo into a specific directory named 'AluaAchievements' | |
| - name: Checkout AluaAchievements repo | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: Rarisma/AluaAchievements | |
| path: AluaAchievements | |
| # Step 2: Checkout the second repo into a sibling directory named 'SACHYA' | |
| - name: Checkout Sachya repo | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: rarisma/sachya | |
| path: SACHYA | |
| # Step 3: Setup .NET | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '9.*.*' | |
| - name: Install .NET workloads | |
| run: dotnet workload restore | |
| # Step 4: Run dotnet restore from within the correct directory | |
| - name: Restore dependencies | |
| run: dotnet restore Alua.sln | |
| working-directory: ./AluaAchievements | |
| # Publishes the application | |
| - name: Publish application | |
| run: | | |
| dotnet publish Alua/Alua.csproj \ | |
| -c Release \ | |
| -f ${{ matrix.fw }} \ | |
| -r ${{ matrix.rid }} \ | |
| --self-contained true \ | |
| -p:PublishSingleFile=true \ | |
| -o publish \ | |
| --no-restore | |
| # Compresses the published output into a zip archive | |
| - name: Archive artifact | |
| run: | | |
| cd publish | |
| 7z a ../${{ matrix.art }}.zip ./* | |
| # Uploads the compressed artifact to be used in other jobs | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.art }} | |
| path: ${{ matrix.art }}.zip | |
| #---------- RELEASE ---------- | |
| # This job creates a GitHub release after the build job completes | |
| release: | |
| # Specifies that the 'build' job must complete successfully before this job runs | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Downloads all artifacts from the 'build' job into the 'dist' directory | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: dist | |
| # Creates a GitHub release | |
| - name: Create Release | |
| uses: ncipollo/release-action@v1 | |
| with: | |
| tag: ${{ github.event.inputs.version }} | |
| name: ${{ github.event.inputs.version }} | |
| artifacts: "dist/**/*.zip" | |
| generateReleaseNotes: true |