Skip to content

Check for app and firmware update. #61

Check for app and firmware update.

Check for app and firmware update. #61

Workflow file for this run

name: Build and Release
on:
push:
branches: [ main ]
tags:
- v*.*.*
pull_request:
branches: [ main ]
jobs:
prepare:
name: Prepare versions
runs-on: ubuntu-latest
outputs:
branchName: ${{ steps.version_step.outputs.branchName }}
shortSha: ${{ steps.version_step.outputs.shortSha }}
fullSemVer: ${{ steps.version_step.outputs.fullSemVer }}
assemblySemVer: ${{ steps.version_step.outputs.assemblySemVer }}
commitDate: ${{ steps.version_step.outputs.commitDate }}
artifactVersion: ${{ steps.artifact_version_step.outputs.artifactVersion }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v3.2.1
with:
versionSpec: '6.3.x'
- name: Determine Version
id: version_step # step id used as a reference for output values
uses: gittools/actions/gitversion/execute@v3.2.1
build:
name: Build
runs-on: ${{ matrix.os }}
needs: prepare
if: success()
strategy:
fail-fast: false
matrix:
runtime: [linux-x64, linux-arm64, win-x64, win-arm64, osx-x64, osx-arm64]
configuration: [Release]
include:
- runtime: linux-x64
os: ubuntu-latest
- runtime: linux-arm64
os: ubuntu-latest
- runtime: win-x64
os: windows-latest
- runtime: win-arm64
os: windows-latest
- runtime: osx-x64
os: macos-latest
- runtime: osx-arm64
os: macos-latest
env:
VERSION_SEMVER: ${{ needs.prepare.outputs.assemblySemVer }}
VERSION_FULL_SEMVER: ${{ needs.prepare.outputs.fullSemVer }}
GIT_SHORT_SHA: ${{ needs.prepare.outputs.shortSha }}
LAST_COMMIT_DATE: ${{ needs.prepare.outputs.commitDate }}
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
- name: Restore dependencies
run: dotnet restore
- name: Test
shell: bash
run: |
dotnet test --no-restore --configuration ${{ matrix.configuration }}
- name: Build
shell: bash
run: |
dotnet build --no-restore --configuration ${{ matrix.configuration }} \
-p:Version=${{ env.VERSION_FULL_SEMVER }} \
-p:AssemblyVersion=${{ env.VERSION_SEMVER }} \
-p:FileVersion=${{ env.VERSION_SEMVER }}
- name: Publish
shell: bash
run: |
dotnet publish --configuration ${{ matrix.configuration }} \
-r ${{ matrix.runtime }} \
--self-contained true \
-p:PublishSingleFile=true \
-p:IncludeNativeLibrariesForSelfExtract=true \
-p:Version=${{ env.VERSION_FULL_SEMVER }} \
-p:AssemblyVersion=${{ env.VERSION_SEMVER }} \
-p:FileVersion=${{ env.VERSION_SEMVER }}
- name: Create artifact directory
shell: bash
run: mkdir -p artifacts/${{ matrix.runtime }}/${{ matrix.configuration }}
- name: Copy artifacts
shell: bash
run: |
cp -r PostCodeSerialMonitor/bin/${{ matrix.configuration }}/net9.0/${{ matrix.runtime }}/publish/* artifacts/${{ matrix.runtime }}/${{ matrix.configuration }}/
cp PostCodeSerialMonitor/config.json artifacts/${{ matrix.runtime }}/${{ matrix.configuration }}/
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: XboxPostCodeMonitor_${{ env.GIT_SHORT_SHA }}_${{ env.LAST_COMMIT_DATE }}_${{ matrix.runtime }}
path: artifacts/${{ matrix.runtime }}/${{ matrix.configuration }}
retention-days: 5
release:
name: Release
needs: build
if: success() && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: List dir
run: ls -R
- name: Create release packages
shell: bash
run: |
# Create a directory for release packages
mkdir -p release-packages
# Get the version from the tag
VERSION=${GITHUB_REF#refs/tags/v}
# Create zip files for each platform and configuration
for platform in linux-x64 linux-arm64 win-x64 win-arm64 osx-x64 osx-arm64; do
cd artifacts/XboxPostCodeMonitor_*_$platform
rm *.pdb
zip -r "../../release-packages/XboxPostCodeMonitor-$VERSION-$platform.zip" .
cd ../..
done
- name: Create Release
uses: softprops/action-gh-release@v2
with:
files: |
release-packages/*.zip
generate_release_notes: true
fail_on_unmatched_files: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}