From 865c0850dd2f973aeb010cbd83ad60b947169c59 Mon Sep 17 00:00:00 2001 From: Manuel Mayer <45011179+SuchByte@users.noreply.github.com> Date: Tue, 6 Jun 2023 15:47:45 +0200 Subject: [PATCH 1/5] Create release.yml --- .github/release.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/release.yml diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 0000000..b2a4512 --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,20 @@ +changelog: + categories: + - title: 🎉 Exciting New Features + labels: + - feature + - title: 🚀 Improvements + labels: + - improvement + - title: 🛠 Breaking Changes + labels: + - breaking-change + - title: 🐞 Bug Fixes + labels: + - bugfix + - title: 👒 Dependencies + labels: + - dependencies + - title: 🚀 Other Changes + labels: + - "*" From cd16b7c35c588b20c5e2f85589356e7bc95878fe Mon Sep 17 00:00:00 2001 From: Manuel Mayer <45011179+SuchByte@users.noreply.github.com> Date: Tue, 6 Jun 2023 15:50:48 +0200 Subject: [PATCH 2/5] Delete build-installer.yml --- .github/workflows/build-installer.yml | 43 --------------------------- 1 file changed, 43 deletions(-) delete mode 100644 .github/workflows/build-installer.yml diff --git a/.github/workflows/build-installer.yml b/.github/workflows/build-installer.yml deleted file mode 100644 index d78e3bc..0000000 --- a/.github/workflows/build-installer.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: Inno Setup Installer - -on: - workflow_call: - workflow_dispatch: - -jobs: - tests: - uses: ./.github/workflows/tests.yml - name: Build and test - build-installer: - needs: [tests] - runs-on: windows-latest - steps: - - name: Checkout Code - uses: actions/checkout@v2 - - - name: Build - run: dotnet build - - - name: Install Inno Setup - run: | - Invoke-WebRequest "http://files.jrsoftware.org/is/6/innosetup-6.2.0.exe" -OutFile "innosetup.exe" - Start-Process -FilePath .\innosetup.exe -ArgumentList "/VERYSILENT /SUPPRESSMSGBOXES /SP- /NOCANCEL /NOICONS" -Wait - - - name: Build Installer - run: | - "& '$env:ISCC_PATH' 'MacroDeck.Setup\Macro Deck.iss" - - - name: Search for Installer - id: search - run: | - $installer = Get-ChildItem -Path .\Output -Filter *.exe | Select-Object -Last 1 - Write-Output "##vso[task.setvariable variable=INSTALLER_NAME]$($installer.Name)" - - - name: Upload Installer Artifact - uses: actions/upload-artifact@v2 - with: - name: ${{ env.INSTALLER_NAME }} - path: Output/${{ env.INSTALLER_NAME }} - - env: - ISCC_PATH: 'C:\Program Files (x86)\Inno Setup 6\ISCC.exe' From d92460bfd5871e89b2b4b9386fdbdc5ec33b81dd Mon Sep 17 00:00:00 2001 From: Manuel Mayer <45011179+SuchByte@users.noreply.github.com> Date: Tue, 6 Jun 2023 15:50:54 +0200 Subject: [PATCH 3/5] Delete tests.yml --- .github/workflows/tests.yml | 50 ------------------------------------- 1 file changed, 50 deletions(-) delete mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml deleted file mode 100644 index b365aab..0000000 --- a/.github/workflows/tests.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: Build and test - -on: - workflow_call: - workflow_dispatch: - pull_request: - branches: - - '**' - - '!develop' - - '!main' - push: - branches: - - '**' - - '!develop' - -jobs: - build: - strategy: - matrix: - configuration: [Release] - runs-on: windows-latest - permissions: - contents: read - packages: write - id-token: write - env: - Solution_Name: MacroDeck.sln # Replace with your solution name, i.e. MyWpfApp.sln. - Test_Project_Path: MacroDeck.Tests # Replace with the path to your test project, i.e. MyWpfApp.Tests\MyWpfApp.Tests.csproj. - Wap_Project_Directory: MacroDeck # Replace with the Wap project directory relative to the solution, i.e. MyWpfApp.Package. - Wap_Project_Path: MacroDeck/MacroDeck.csproj # Replace with the path to your Wap project, i.e. MyWpf.App.Package\MyWpfApp.Package.wapproj. - - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - # Install the .NET Core workload - - name: Install .NET Core - uses: actions/setup-dotnet@v3 - with: - dotnet-version: 3.1.x - - # Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild - - name: Setup MSBuild.exe - uses: microsoft/setup-msbuild@v1.3.1 - - # Execute all unit tests in the solution - - name: Execute unit tests - run: dotnet test From 2e62381b5b1448221b926c601d7cae6e1e2214a1 Mon Sep 17 00:00:00 2001 From: Manuel Mayer Date: Tue, 6 Jun 2023 15:52:26 +0200 Subject: [PATCH 4/5] Update workflows --- .github/workflows/check-version.yml | 23 +++++++ .github/workflows/ci.yml | 18 ++++++ .github/workflows/push-version.yml | 61 ++++++++++++++++++ .github/workflows/release-windows.yml | 92 +++++++++++++++++++++++++++ .github/workflows/release.yml | 25 ++++++++ .github/workflows/tests.yml | 18 ++++++ 6 files changed, 237 insertions(+) create mode 100644 .github/workflows/check-version.yml create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/push-version.yml create mode 100644 .github/workflows/release-windows.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/check-version.yml b/.github/workflows/check-version.yml new file mode 100644 index 0000000..c76d42f --- /dev/null +++ b/.github/workflows/check-version.yml @@ -0,0 +1,23 @@ +name: Build Windows Installer + +on: + workflow_call: + inputs: + version: + description: 'Version' + required: true + type: string + +jobs: + check-release-name: + runs-on: ubuntu-latest + + steps: + - name: Check version on update API + run: | + VERSION_CHECK=$(curl -s "https://update.api.macro-deck.app/versionname/validate/${{ inputs.version }}") + + if [[ "$VERSION_CHECK" != "true" ]]; then + echo "Version '${{ inputs.version }}' is not valid according to the update API." + exit 1 + fi diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..8e4d9fc --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,18 @@ +name: CI + +on: + workflow_call: + pull_request: + branches: + - 'main' + - 'develop' + push: + branches: + - '!main' + - '!develop' + +jobs: + tests: + name: Execute Tests + uses: ./.github/workflows/tests.yml + secrets: inherit diff --git a/.github/workflows/push-version.yml b/.github/workflows/push-version.yml new file mode 100644 index 0000000..fd80c48 --- /dev/null +++ b/.github/workflows/push-version.yml @@ -0,0 +1,61 @@ +name: Push Version + +on: + workflow_call: + inputs: + platform: + required: true + type: string + version: + required: true + type: string + filename: + required: true + type: string + filehash: + required: true + type: string + filesize: + required: true + type: number + +jobs: + push-version: + runs-on: ubuntu-latest + + steps: + - name: Validate Input + run: | + if [[ -z "${{ inputs.platform }}" ]];then + echo "::error::Missing required key 'platform' input!" + exit 1 + elif [[ -z "${{ inputs.version }}" ]];then + echo "::error::Missing required key 'version' input!" + exit 1 + elif [[ -z "${{ inputs.filename }}" ]];then + echo "::error::Missing required key 'filename' input!" + exit 1 + fi + elif [[ -z "${{ inputs.filehash }}" ]];then + echo "::error::Missing required key 'filehash' input!" + exit 1 + fi + elif [[ -z "${{ inputs.filesize }}" ]];then + echo "::error::Missing required key 'filesize' input!" + exit 1 + fi + shell: bash + + - name: Update version on the api + run: > + curl -X 'POST' \ + 'https://update.api.macro-deck.app/files/${{ inputs.version }}/${{ inputs.platform }}' + -H 'accept: */*' + -H 'x-admin-token: ${{ secrets.UPDATE_SERVICE_TOKEN }}' + -H 'Content-Type: application/json' + -d '{ + "fileName": ${{ inputs.filename }}, + "fileProvider": "GitHub", + "fileHash": ${{ inputs.filehash }}, + "fileSize": ${{ inputs.filesize }} + }' diff --git a/.github/workflows/release-windows.yml b/.github/workflows/release-windows.yml new file mode 100644 index 0000000..ee4a2dd --- /dev/null +++ b/.github/workflows/release-windows.yml @@ -0,0 +1,92 @@ +name: Build and Release Windows Installer + +on: + workflow_call: + inputs: + version: + required: true + type: string + channel: + required: false + default: 'Release' + type: string + +jobs: + build-windows-installer: + name: Build Windows Installer + runs-on: windows-latest + + env: + ISCC_PATH: 'C:\Program Files (x86)\Inno Setup 6\ISCC.exe' + INNO_SETUP_DIR: 'C:\Program Files (x86)\Inno Setup 6' + + steps: + - name: Checkout Code + uses: actions/checkout@v2 + + - name: Verify Inno Setup installation + run: | + Write-Output "Inno Setup path: '${{ env.ISCC_PATH }}'" + if (Test-Path '${{ env.ISCC_PATH }}') { + Write-Output "Inno Setup is installed." + } else { + Write-Output "Inno Setup installation is not installed." + exit 1 + } + + - name: Update project version + run: | + [xml]$csproj = Get-Content -Path "${{ github.workspace }}\MacroDeck\MacroDeck.csproj" + $csproj.Project.PropertyGroup.Version = "${{ inputs.version }}" + $csproj.OuterXml | Set-Content -Path "${{ github.workspace }}\MacroDeck\MacroDeck.csproj" + shell: pwsh + + - name: Build Macro Deck for Windows + run: | + dotnet restore ".\MacroDeck\MacroDeck.csproj" + dotnet build ".\MacroDeck\MacroDeck.csproj" -c Release -o ".\MacroDeck\bin\Release" -r win-x64 + dotnet publish ".\MacroDeck\MacroDeck.csproj" -c Release -o ".\MacroDeck\bin\Publish" -r win-x64 --self-contained true -p:IncludeNativeLibrariesForSelfExtract=true + copy ".\MacroDeck\bin\Release\Macro Deck 2.dll" ".\MacroDeck\bin\Publish" + shell: cmd + + - name: Build Macro Deck installer for Windows + run: | + "${{ env.ISCC_PATH }}" /F"macro-deck-${{ inputs.version }}-win" "MacroDeck.Setup\Macro Deck.iss" + shell: cmd + + - name: Calculate file hash + id: filehash + run: | + $filehash = Get-FileHash -Algorithm SHA256 -Path "MacroDeck.Setup\Result\macro-deck-${{ inputs.version }}-win.exe" | ForEach-Object Hash + echo "::set-output name=filehash::$filehash" + shell: pwsh + + - name: Calculate file size + id: filesize + run: | + $filesize = (Get-Item "MacroDeck.Setup\Result\macro-deck-${{ inputs.version }}-win.exe").Length + echo "::set-output name=filesize::$filesize" + shell: pwsh + + - name: Upload Windows installer to release + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: 'MacroDeck.Setup\Result\macro-deck-${{ inputs.version }}-win.exe' + asset_name: macro-deck-${{ inputs.version }}-win.exe + asset_content_type: application/octet-stream + + push_version: + name: Push Version + needs: build-windows-installer + uses: ./.github/workflows/push-version.yml + secrets: inherit + with: + platform: 'WinX64' + version: ${{ inputs.version }} + filename: macro-deck-${{ inputs.version }}-win.exe + filehash: ${{ needs.build-windows-installer.outputs.filehash }} + filesize: ${{ needs.build-windows-installer.outputs.filesize }} + diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..c1a8152 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,25 @@ +name: Release + +on: + release: + types: [published] + +jobs: + check_version: + name: Check Version Name + uses: ./.github/workflows/check-version.yml + with: + version: ${{ github.event.release.name }} + tests: + name: Execute Tests + needs: [check_version] + uses: ./.github/workflows/tests.yml + secrets: inherit + release-windows: + name: Release Windows + uses: ./.github/workflows/release-windows.yml + needs: [check_version, tests] + secrets: inherit + with: + version: ${{ github.event.release.name }} + channel: ${{ github.event.release.prerelease && 'Preview' || 'Release' }} \ No newline at end of file diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..558813a --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,18 @@ +name: Run Tests + +on: + workflow_call: + +jobs: + build: + runs-on: windows-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Execute unit tests + run: | + dotnet restore "MacroDeck.Tests\MacroDeck.Tests.csproj" + dotnet test "MacroDeck.Tests\MacroDeck.Tests.csproj" + shell: cmd From fd9e232f8cd780abe06e8136b1b1b9f2177c7545 Mon Sep 17 00:00:00 2001 From: Manuel Mayer Date: Tue, 6 Jun 2023 15:55:24 +0200 Subject: [PATCH 5/5] Update workflows --- ...ase-windows.yml => build-push-windows.yml} | 27 ++-- .github/workflows/create-release.yml | 134 ++++++++++++++++++ .github/workflows/push-version.yml | 61 -------- .../{release.yml => release-created.yml} | 10 +- 4 files changed, 154 insertions(+), 78 deletions(-) rename .github/workflows/{release-windows.yml => build-push-windows.yml} (83%) create mode 100644 .github/workflows/create-release.yml delete mode 100644 .github/workflows/push-version.yml rename .github/workflows/{release.yml => release-created.yml} (77%) diff --git a/.github/workflows/release-windows.yml b/.github/workflows/build-push-windows.yml similarity index 83% rename from .github/workflows/release-windows.yml rename to .github/workflows/build-push-windows.yml index ee4a2dd..f823d97 100644 --- a/.github/workflows/release-windows.yml +++ b/.github/workflows/build-push-windows.yml @@ -77,16 +77,17 @@ jobs: asset_path: 'MacroDeck.Setup\Result\macro-deck-${{ inputs.version }}-win.exe' asset_name: macro-deck-${{ inputs.version }}-win.exe asset_content_type: application/octet-stream - - push_version: - name: Push Version - needs: build-windows-installer - uses: ./.github/workflows/push-version.yml - secrets: inherit - with: - platform: 'WinX64' - version: ${{ inputs.version }} - filename: macro-deck-${{ inputs.version }}-win.exe - filehash: ${{ needs.build-windows-installer.outputs.filehash }} - filesize: ${{ needs.build-windows-installer.outputs.filesize }} - + + - name: Push Update to the API + run: > + curl -X 'POST' \ + 'https://update.api.macro-deck.app/files/${{ inputs.version }}/${{ inputs.platform }}' + -H 'accept: */*' + -H 'x-admin-token: ${{ secrets.UPDATE_SERVICE_TOKEN }}' + -H 'Content-Type: application/json' + -d '{ + "fileName": ${{ inputs.filename }}, + "fileProvider": "GitHub", + "fileHash": ${{ inputs.filehash }}, + "fileSize": ${{ inputs.filesize }} + }' diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml new file mode 100644 index 0000000..97015c0 --- /dev/null +++ b/.github/workflows/create-release.yml @@ -0,0 +1,134 @@ +name: Create Release + +on: + workflow_dispatch: + inputs: + releaseType: + type: choice + options: + - major + - minor + - patch + - major_beta + - minor_beta + description: 'Release type (major, minor, patch, major_beta, minor_beta)' + required: true + +jobs: + release: + name: "Create Version" + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Get Next Version From Update API + run: | + RELEASE_TYPE=${{ github.event.inputs.releaseType }} + BASE_URL="https://update.api.macro-deck.app/versionname/next" + case "${RELEASE_TYPE}" in + "major") + URL="${BASE_URL}/major" + ;; + "minor") + URL="${BASE_URL}/minor" + ;; + "patch") + URL="${BASE_URL}/patch" + ;; + "major_beta") + URL="${BASE_URL}/major/beta" + ;; + "minor_beta") + URL="${BASE_URL}/minor/beta" + ;; + *) + echo "Invalid release type: ${RELEASE_TYPE}" + exit 1 + ;; + esac + RESPONSE=$(curl -s $URL) + VERSION_NAME=$(echo $RESPONSE | jq -r '.versionName') + echo "VERSION_NAME=${VERSION_NAME}" >> $GITHUB_ENV + IS_BETA=$(echo $RESPONSE | jq -r '.isBetaVersion') + echo "IS_BETA=${IS_BETA}" >> $GITHUB_ENV + + - name: "Create Tag And Release" + uses: "actions/github-script@v6.4.1" + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + await github.request('POST /repos/${{github.repository}}/releases', { + name: process.env.VERSION_NAME, + tag_name: "v" + process.env.VERSION_NAME, + generate_release_notes: true, + prerelease: process.env.IS_BETA === "true" + }); + + - name: Announce Release In Discord + uses: fjogeleit/http-request-action@v1 + if: ${{ env.IS_BETA == 'false' }} + continue-on-error: true + with: + url: 'https://bot.api.macro-deck.app/webhook/macro-deck-release' + method: 'POST' + bearerToken: ${{ secrets.WEBHOOK_KEY }} + customHeaders: '{"Content-Type": "application/json"}' + data: | + { + "toEveryone": false, + "embed": { + "color": { + "r": 0, + "g": 1, + "b": 0 + }, + "description": "**${{ env.VERSION_NAME }} is now released!**", + "fields": [ + { + "name": "Channel", + "value": "Release", + "inline": false + }, + { + "name": "Changelog", + "value": "https://github.com/Macro-Deck-App/Macro-Deck/releases/tag/v${{ env.VERSION_NAME }}", + "inline": false + } + ] + } + } + + - name: Announce Beta Release In Discord + uses: fjogeleit/http-request-action@v1 + if: ${{ env.IS_BETA == 'true' }} + continue-on-error: true + with: + url: 'https://bot.api.macro-deck.app/webhook/macro-deck-beta-release' + method: 'POST' + bearerToken: ${{ secrets.WEBHOOK_KEY }} + customHeaders: '{"Content-Type": "application/json"}' + data: | + { + "toEveryone": false, + "embed": { + "color": { + "r": 1, + "g": 1, + "b": 0 + }, + "description": "**${{ env.VERSION_NAME }} is now released!**", + "fields": [ + { + "name": "Channel", + "value": "Beta", + "inline": false + }, + { + "name": "Changelog", + "value": "https://github.com/Macro-Deck-App/Macro-Deck/releases/tag/v${{ env.VERSION_NAME }}", + "inline": false + } + ] + } + } diff --git a/.github/workflows/push-version.yml b/.github/workflows/push-version.yml deleted file mode 100644 index fd80c48..0000000 --- a/.github/workflows/push-version.yml +++ /dev/null @@ -1,61 +0,0 @@ -name: Push Version - -on: - workflow_call: - inputs: - platform: - required: true - type: string - version: - required: true - type: string - filename: - required: true - type: string - filehash: - required: true - type: string - filesize: - required: true - type: number - -jobs: - push-version: - runs-on: ubuntu-latest - - steps: - - name: Validate Input - run: | - if [[ -z "${{ inputs.platform }}" ]];then - echo "::error::Missing required key 'platform' input!" - exit 1 - elif [[ -z "${{ inputs.version }}" ]];then - echo "::error::Missing required key 'version' input!" - exit 1 - elif [[ -z "${{ inputs.filename }}" ]];then - echo "::error::Missing required key 'filename' input!" - exit 1 - fi - elif [[ -z "${{ inputs.filehash }}" ]];then - echo "::error::Missing required key 'filehash' input!" - exit 1 - fi - elif [[ -z "${{ inputs.filesize }}" ]];then - echo "::error::Missing required key 'filesize' input!" - exit 1 - fi - shell: bash - - - name: Update version on the api - run: > - curl -X 'POST' \ - 'https://update.api.macro-deck.app/files/${{ inputs.version }}/${{ inputs.platform }}' - -H 'accept: */*' - -H 'x-admin-token: ${{ secrets.UPDATE_SERVICE_TOKEN }}' - -H 'Content-Type: application/json' - -d '{ - "fileName": ${{ inputs.filename }}, - "fileProvider": "GitHub", - "fileHash": ${{ inputs.filehash }}, - "fileSize": ${{ inputs.filesize }} - }' diff --git a/.github/workflows/release.yml b/.github/workflows/release-created.yml similarity index 77% rename from .github/workflows/release.yml rename to .github/workflows/release-created.yml index c1a8152..970f43e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release-created.yml @@ -1,4 +1,4 @@ -name: Release +name: Release Created on: release: @@ -10,16 +10,18 @@ jobs: uses: ./.github/workflows/check-version.yml with: version: ${{ github.event.release.name }} + tests: name: Execute Tests needs: [check_version] uses: ./.github/workflows/tests.yml secrets: inherit + release-windows: - name: Release Windows - uses: ./.github/workflows/release-windows.yml + name: Build and Push Macro Deck for Windows + uses: ./.github/workflows/build-push-windows.yml needs: [check_version, tests] secrets: inherit with: version: ${{ github.event.release.name }} - channel: ${{ github.event.release.prerelease && 'Preview' || 'Release' }} \ No newline at end of file + channel: ${{ github.event.release.prerelease && 'Preview' || 'Release' }}