Skip to content

Build & Release

Build & Release #7

Workflow file for this run

# 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 }}
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: windows-latest
rid: win-arm64
fw: net9.0-windows10.0.19041.0
art: win-arm64
- os: ubuntu-latest
rid: linux-x64
fw: net9.0
art: linux-x64
- os: ubuntu-latest
rid: linux-arm64
fw: net9.0
art: linux-arm64
- os: macos-latest
rid: osx-arm64
fw: net9.0-macos
art: macos-arm64
# Mobile build
- os: windows-latest
rid: android-arm64
fw: net9.0-android
art: android-arm64
steps:
# Checks out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout main repository
uses: actions/checkout@v4
# Clones a dependency repository into a specific path
- name: Checkout Sachya dependency
uses: actions/checkout@v4
with:
repository: rarisma/sachya
path: SACHYA # Matches the path casing expected by the solution file
# Sets up the .NET environment
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
# Uses the .NET version specified in global.json
global-json-file: global.json
# Enables caching for NuGet packages to speed up future builds
cache: true
# Installs the .NET Android workload only for Android builds
- name: Install Android Workload
if: contains(matrix.fw, 'android')
run: dotnet workload install android
# Restores NuGet packages for the solution, disabling locked mode to prevent errors if lock file is missing
- name: Restore dependencies
run: dotnet restore Alua.sln /p:RestoreLockedMode=false
# 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