steam-deck-tools/.github/workflows/build_release.yaml
2022-12-02 19:46:39 +01:00

67 lines
2.1 KiB
YAML

on:
push:
branches:
- main
- '*-stable'
paths:
- '.github/workflows/build_release.yaml'
- 'RELEASE.md'
env:
RELEASE_NAME: SteamDeckTools
DOTNET_VERSION: '6.0.x'
jobs:
build-and-release:
runs-on: windows-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Install dependencies
run: dotnet restore
- name: Set RELEASE_VERSION
shell: bash
run: |
majorVer=$(cat VERSION)
lastVer=$(git tag --sort version:refname --list "$majorVer.*" | tail -n1)
if [[ -n "$lastVer" ]]; then
newVer=(${lastVer//./ })
newVer[-1]="$((${newVer[-1]}+1))"
nextVer="${newVer[*]}"
nextVer="${nextVer// /.}"
else
nextVer="$majorVer.0"
fi
echo "MajorVer=$majorVer LastVer=$lastVer NextVer=$nextVer"
echo "RELEASE_VERSION=$nextVer" >> $GITHUB_ENV
- name: Build Release
run: dotnet build --configuration Release --output "${{ env.RELEASE_NAME }}-${{ env.RELEASE_VERSION }}/" "/property:Version=${{ env.RELEASE_VERSION }}"
- name: Build Debug
run: dotnet build --configuration Debug --output "${{ env.RELEASE_NAME }}-${{ env.RELEASE_VERSION }}-debug/" "/property:Version=${{ env.RELEASE_VERSION }}"
- name: Test
run: dotnet test --no-restore --verbosity normal
- uses: vimtor/action-zip@v1
with:
files: ${{ env.RELEASE_NAME }}-${{ env.RELEASE_VERSION }}
dest: ${{ env.RELEASE_NAME }}-${{ env.RELEASE_VERSION }}.zip
recursive: true
- uses: vimtor/action-zip@v1
with:
files: ${{ env.RELEASE_NAME }}-${{ env.RELEASE_VERSION }}-debug
dest: ${{ env.RELEASE_NAME }}-${{ env.RELEASE_VERSION }}-debug.zip
recursive: true
- uses: ncipollo/release-action@v1
with:
tag: ${{ env.RELEASE_VERSION }}
artifacts: "*.zip"
prerelease: true
generateReleaseNotes: true
bodyFile: RELEASE.md