Skip to content

build: refactor workflow for releases #16

build: refactor workflow for releases

build: refactor workflow for releases #16

Workflow file for this run

name: Build and Release
on:
push:
branches:
- main
- update-resonite-mod-updater-utils
workflow_dispatch:
jobs:
build-and-release:
runs-on: ubuntu-latest
permissions:
contents: write
env:
PROJECT: ResoniteModUpdater
DOTNET_VERSION: '8.0.x'
VPK_VERSION: '0.0.626'
DOTNET_NOLOGO: true
outputs:
version: ${{ steps.get-version.outputs.version }}
strategy:
matrix:
include:
- platform: linux-x64
self-contained: true
extra-args: ''
- platform: win-x64
self-contained: false
extra-args: '--noPortable --framework net8.0-x64-runtime'
- platform: win-x64
self-contained: true
extra-args: '--noInst --packTitle win-x64-portable'
is-portable: true
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Get Version from Project File
id: get-version
shell: bash
run: echo "version=$(grep -oE '<AssemblyVersion>[^<]+' ${{ env.PROJECT }}/${{ env.PROJECT }}.csproj | sed 's/<AssemblyVersion>//')" >> $GITHUB_OUTPUT
- name: Install Velopack CLI
run: dotnet tool install -g vpk --version ${{ env.VPK_VERSION }}
- name: Build Project
run: dotnet publish ${{ env.PROJECT }}/${{ env.PROJECT }}.csproj -c Release -o publish/${{ matrix.platform }}${{ matrix.is-portable && '-portable' || '' }} -r ${{ matrix.platform }} ${{ matrix.self-contained && '--self-contained' || '--no-self-contained' }}
- name: Download Previous Releases
run: vpk download github --repoUrl ${{ github.server_url }}/${{ github.repository }} --channel ${{ matrix.platform }}${{ matrix.is-portable && '-portable' || '' }} -o releases
- name: Pack New Release
run: vpk ${{ startsWith(matrix.platform, 'win') && '[win] ' || '' }}pack -u ${{ env.PROJECT }} -v ${{ steps.get-version.outputs.version }} -r ${{ matrix.platform }} --channel ${{ matrix.platform }}${{ matrix.is-portable && '-portable' || '' }} ${{ matrix.extra-args }} -p publish/${{ matrix.platform }}${{ matrix.is-portable && '-portable' || '' }} -o releases
- name: Rename and Update Portable Package
if: matrix.is-portable
run: |
mv releases/${{ env.PROJECT }}-${{ matrix.platform }}-portable-Portable.zip releases/${{ env.PROJECT }}-${{ matrix.platform }}-portable.zip
JSON_FILE="./releases/assets.${{ matrix.platform }}-portable.json"
sed -i 's/ResoniteModUpdater-win-x64-portable-Portable.zip/ResoniteModUpdater-win-x64-portable.zip/g' "$JSON_FILE"
- name: Cache build outputs
uses: actions/cache/save@v4
with:
path: |
releases/releases.*.json
releases/*.nupkg
releases/*.AppImage
releases/*.exe
key: ${{ runner.os }}-build-${{ matrix.platform }}${{ matrix.is-portable && '-portable' || '' }}-${{ steps.get-version.outputs.version }}
create-release:
needs: build-and-release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Restore cached build outputs
uses: actions/cache/restore@v4
with:
path: releases
key: ${{ runner.os }}-build-
restore-keys: |
${{ runner.os }}-build-linux-x64-${{ needs.build-and-release.outputs.version }}
${{ runner.os }}-build-win-x64-${{ needs.build-and-release.outputs.version }}
${{ runner.os }}-build-win-x64-portable-${{ needs.build-and-release.outputs.version }}
- name: Create Release
uses: softprops/action-gh-release@v2
with:
draft: true
prerelease: false
generate_release_notes: true
name: v${{ needs.build-and-release.outputs.version }}
tag_name: v${{ needs.build-and-release.outputs.version }}
target_commitish: ${{ github.sha }}
files: releases/**/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}